-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FlxColorUtil and FlxColor #1027
Comments
Agreed, FlxColorUtil is kinda redundant, FlxColor is a much better place for all of that good stuff. |
I don't like that idea - I don't want to mix color constants with utility functions. Auto completion is so much more helpful if you keep them seperated. |
|
@Gama11 All the colors like "charcoal", "wheat" and "ivory" seem a bit unnecessary. If a dev has a color in mind, they will not likely find any such colors via autocomplete as these names are not colors. (If somebody has a dark grey in mind, are they likely to type "FlxColor.ch"?) They could, perhaps, find them if the browse the autocomplete list or the FlxColor api, but that's likely just going to be way more effort than just using a tool to figure out your own color or experimenting with rgb values. Then there's "FlxColor.TRANSPARENT", which presumably exists to alleviate the arduous task of typing "0". Also, not wanting to mix utility constants with utility functions does make it harder to find the functions. I don't think it's wise to separate things based on whether or not they're functions or constants. They should be separated based on what their intended use is: what does the developer require? Currently, if a dev wants a color, there are way too many options, and they all obscure each other. There are too many constants, too many functions, and too many classes. Autocomplete already takes a massive hit from this complexity. @sruloart's suggestion is nice. I was wondering about a way of being able to store your own presets. I don't consider the autocomplete thing to be a big issue, but it would be even smaller with fewer presets. We could also put presets in an object, like FlxColor.presets.RED. This is possibly unnecessary, but if we were to add some kind of customizable palette it would probably make sense to put presets in there, e.g. FlxColor.palette.red or FlxG.color.red. |
Guys, I'm looking for opinions on how color presets should be accessed now that FlxColor is instantiable and has a few new static methods. In order for presets to be useable as default params, and to give autocomplete suggestions, the presets need to be static. The new static methods of FlxColor are: fromRGB, fromHSB, fromHSL, fromCMYK, fromInt, interpolate, and gradient. Options for preset access include FlxColor.RED, FlxColorPreset.RED and FlxColor.preset.RED. The first won't break anything, but is potentially less good for autocomplete. Right now I'm thinking that wouldn't matter so much, though. It is at least consistent in the fact that everything static in FlxColor is used to get a FlxColor instance (or multiple in the case of gradient). There are 44 presets in total. |
I don't think I understand the all presets thing (44 presets?). Can you give an example? What, Why and How. |
@sruloart http://api.haxeflixel.com/types/flixel/util/FlxColor.html Currently FlxColor is nothing but a bunch of preset colors. For what you wanted to do before, by the way, I'd recommend making a class of static vars for your own presets. The main benefit being that it will give you autocomplete suggestions, whereas having dynamic palettes will not. Furthermore you cannot use the values from a dynamic palette as default method parameters. |
|
I'm wondering if FlxColor and FlxColorUtil are a little overcomplicated. FlxColor, which is likely the first place anyone would go to try to make a color, doesn't contain anything but presets. To make a color from rgb values you have to go to FlxColorUtil, at which point you are flooded with options, some of which seem redundant.
For example, let's say we just want to make a simple color from RGB values, and possibly an alpha. We can use:-
Why not something nice and simple in FlxColor? Like this perhaps:
Then we have things like:-
Neither of the first two specifically take ARGB values, and yet they have ARGB in the name. The third isn't a "color" to hex at all, rather it is a byte (or value from 0-255) to hex string, and is used by the first two, but isn't really a color only thing.
Then there's a load of permutations for conversions of color representations:-
Are these useful? ARGB and RGB are both just ints, and all this "conversion" does is set the alpha to 255. Seeing as there already exists methods for getting HSV or ARGB objects from color ints, the others also don't seem necessary.
If there were simply functions for getting colors for each method (getRGB, getHSV, etc..) that return an argb Int, and "to" functions for turning an Int into the desired representation, then every combination of conversions would be possible by doing things like toHSV(RGB(r, g, b)).
In summary, the colors stuff seems a bit excessive. I'm wondering if it might be possible to make it a bit for efficient. Perhaps, FlxColorUtil could in fact be merged into just FlxColor?
The text was updated successfully, but these errors were encountered: