Comments (6)
We can hammer out details on what goes on inside the FlxColor
instances later. For example, it would be a better idea to store a color generated with fromHSB
with the actual HSB values instead of loosing accuracy by converting it to a uint
and storing it that way.
Also, Flixel would probably still continue to use uints
when storing colors internally (exhibit A) for performance reasons, but users of the library are more than welcome to use FlxColor
instances in their games if performance isn't an issue.
Any thoughts? Would it help make Flixel more logically organized, or just complicate things?
from flixel.
That's great! I would definitely make Flixel more logically organized. My only concern was the performance hit, but if we stick with uint
for color internally, there will be no problems.
from flixel.
I've actually been working on this is HaxeFlixel, and strangely, it's very much as you have described, except there is no such thing as converting a color, because a FlxColor can automatically pretend to have any rgb/hsb/hsl/cmyk property. HaxeFlixel/flixel#1027
I will be pushing both a completely revamped FlxColor and demo for FlxColor pretty shortly. It includes the ability to get and set any rgb/hsb/hsl value, though precision is lost as the underlying type is an Int (see below). I've added additional features for creating gradients with optional easing functions.
Using a little haxe magic, FlxColor is actually an Int in disguise, so it is interchangeable with Ints/hex literals. For example, you can do:
var myColor:FlxColor = 0xff123456;
trace(myColor.hue);
Basically it provides the convenience of FlxColor methods, without losing the int performance and functionality. I'm not sure how much of it will be portable to as3, but before anyone starts duplicating work, you may want to wait and see how much can be reused. ;)
from flixel.
I've made a pull request to HaxeFlixel with instantiable FlxColors: HaxeFlixel/flixel#1113
from flixel.
I've actually been working on this is HaxeFlixel, and strangely, it's very much as you have described
Do you mind if I pretty much steal the entire class for AS3 Flixel? That way, the two libraries match which will help both users and tutorial writers.
It includes the ability to get and set any rgb/hsb/hsl value, though precision is lost as the underlying type is an Int (see below).
I'm not a fan of loosing precision unnecessarily, so for the AS3 version, I have a different plan of approach which should work.
Using a little haxe magic, FlxColor is actually an Int in disguise, so it is interchangeable with Ints/hex literals.
That so cool! Haxe has so many cool features, I don't know why I haven't switched over yet. Alas, Flash doesn't have anything like that (well, we could pervert the prototype
chain for AS3's uint
class, but that's just wrong in my eyes).
from flixel.
You are welcome to try to take as much as you can from HaxeFlixel's FlxColor, however, I'm not sure some of it will translate so well to AS3, considering a lot of the implementation ended up being centered around the use of the haxe abstract.
Also, it's possibly worth considering the performance implications of mimicking the behavior. The benefit that comes with the small loss of precision in HaxeFlixel's FlxColor provides the benefit of keeping the performance as if only ints were ever used. There is no data other than a single int, and no complex data type instantiated. In HaxeFlixel, this has meant that FlxColor has replaced everywhere that used to use an int or uint as a color without any loss to performance, whereas in AS3 Flixel, it might be best to use FlxColor only for when conversions are required?
As I say, you are welcome to use of it what you can. The conversion algorithms themselves should port pretty easily. :)
from flixel.
Related Issues (20)
- Use bitwise operators for faster Math functions HOT 6
- Add FlxRandom seeded random generator HOT 13
- Add ray casting with soft shadows HOT 6
- Centralize all input handling in FlxG.input HOT 2
- Achievements in Flixel HOT 3
- FlxTween Enhancement HOT 11
- Overhaul the built-in debugger HOT 7
- Community Notice Board HOT 3
- FlxTilemap() can't draw one-column tilemap - BitmaData exception HOT 4
- Create flixel-demos repository
- Bump version 2.58 to 3.0 HOT 2
- Add property "position" to FlxSprite HOT 4
- Implement FlxG.assets
- Dev branch lacks clear notice of Genome2d Dependency HOT 1
- Cannot get to compile against Genome2d SWC HOT 11
- FlxRandom has ASDoc validation errors HOT 3
- Context3D "Texture too big" error HOT 7
- [GPU build] calcFrame() wrong order HOT 2
- Current state of Flixel on GPU? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flixel.