-
Notifications
You must be signed in to change notification settings - Fork 2.3k
rendlay.cpp: Add support in the layout color component to specify colors by hex rgb(a) values. #14544
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
base: master
Are you sure you want to change the base?
Conversation
|
Maybe instead of using the hex word just use # before the number within the quotes like SVG does. |
The colour has to be specified as some attribute of the In SVG or HTML, the colour is applied through a But here, where we're not looking to handle named colours on an overloaded attribute, we don't need the |
It isn't needed, but inconsistent semantics in that regard violates the fundamental rule of UX, the Principle of Least Surprise. Will it at least still work in those situations if there is a leading hash mark? If yes, I see no reason why this can't go in. If not, please add functionality to discard a leading hash mark. |
|
Better not name the parameter hex, go for something more descriptive like rgb and rgba. In MAME lay files, it's a |
|
All due respect to @cuavas, as I'm not sure it was his choice or if this pre-dates his involvement with the layout system, but using # as a prefix for decimal numbers makes MAME an outlier. The majority of art packages, as well as the whole wide world of the web, uses # as the prefix for hex color constants. It would be a breaking change, but rather than digging our heels in on making MAME more awkward for new contributors by forging our own UX path that isn't reflective of most common use cases, it would be a good time to re-think the representation of color constants in layout files. |
|
The point of the # was to use standard nomenclature that is already used in many places. In Photoshop the hex values can be obtained directly from the palette tool (this is how I get my color values for the layouts). The other standard is RGB. The way MAME requires a number from 0 to 1 for colors is pushing more non-standard 'invented-for-MAME b.s.' that over-complicates something that was solved 160 years ago LOL. To get those numbers you have to take the common separate RGB values and divide each one by 255 which gets annoying very quickly. |
I chose
By using the attribute In the particular case of layouts, it also avoids any ambiguity of the
Animation continues to work. Look at the (piano) keys on any of the keyboards: their colour is animated depending on the position where you press (or mouse down) on the key, and further animated if you move the touch/mouse up / down. Each key looks like: <element ref="keyshape_0" id="full_keyboard_key_0" clickthrough="no">
<bounds x="0" y="0" width="22.5" height="138" />
<color state="0" hex="f2f2e6" />
<color state="1" hex="2c44ad" />
<color state="127" hex="19a14d" />
<color state="128" hex="e6ce48" />
<color state="255" hex="ce3f06" />
</element>Colour is then animated by the Lua script: key.item:set_animation_state_callback(function()
new_state = 0
if key.pressure > 0 then
new_state = 128 + key.pressure
elseif key.velocity > 0 then
new_state = key.velocity
else
new_state = 0
end
if new_state ~= key.animation_state then
key.animation_state = new_state
end
return new_state
end)So what is animated is the animation state, and the layout system uses the |
|
Why not use |
The
I am not trying here to make any fundamental changes to the layout rendering system - just to allow specifying colours as a single hex value, rather than requiring a combination of up to four different values. |
b7e7e88 to
3ef924d
Compare
…ors by hex rgb(a) values. Also uses the Ensoniq VFX family of layouts to show it working, as well as documenting it.
a4e138d to
5902ba9
Compare
Also uses the Ensoniq VFX family of layouts to show it working, and adds a bit to the documentation.