The Daily Click ::. Forums ::. Klik Coding Help ::. Not Understanding Decimal Color Values.
 

Post Reply  Post Oekaki 
 

Posted By Message

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
16th February, 2013 at 16/02/2013 19:00:31 -

I'm using the background gradient object, and I've been trying to alter the 2-color gradient at runtime, but it seems all that MMF2 will accept for the extension is a decimal color value. I'm horrible at effectively reading decimal color values, but I know how to convert between hex and decimal, so I've been taking set hex color values out of photoshop and converting them to decimal values.

Every decimal color in the set of ten either references to some version of blue or black. Problem is, when I plug these converted decimal color values into MMF2 and run the app, I get orange. I've gone back and checked all of my color values, and it seems each and every one of them still reference some kind of blue. Is this the plugin or MMF2 itself acting screwy?

Color 1 | Color 2
4682737 | 2667998
4221145 | 2401240
3759553 | 2134482
3297961 | 1867724
2836369 | 1600966
2374777 | 1334208
1913185 | 1067450
1451593 | 800692
990001 | 533934
396569 | 267173

Color 1 should fade from a dark blue to nearly black.
Color 2 should fade from a light blue to a dark blue.
I've checked and double-checked the values and they all seem to be various shades of blue until I try running my app.

I've even screen capped each step of the gradient transition in MMF2, taken it into photoshop, pulled the hex value off of the orange, reconverted to decimal and the decimal value that the GBO uses doesn't appear anywhere in the list of values I've created. Example, the first color transition changes to 14248000 even though I've manually set it to 4682737. What the hell?

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
16th February, 2013 at 16/02/2013 19:15:42 -

Just to clarify, I've got this event group scripted really simplistically just to ensure I'm not the one screwing all this up. Eventually, I'll change the event scripting so it's not timer-based, but for right now I'm just trying to troubleshoot. Here's what it looks like:

Start of Frame -> Background Gradient Object (BGO) set Color 1 to 4682737. BGO set color 2 to 2667998.
Timer equals 01"-00 (1 second) -> BGO set color 1 to 4221145. BGO set color 2 to 2401240.
Timer equals 02"-00 -> BGO set color 1 to 3759553. BGO set color 2 to 2134482.
Timer equals 03"-00 -> BGO set color 1 to 3297961. BGO set color 2 to 1867724.
Timer equals 04"-00 -> BGO set color 1 to 2836369. BGO set color 2 to 1600966.
Timer equals 05"-00 -> BGO set color 1 to 2374777. BGO set color 2 to 1334208.
Timer equals 06"-00 -> BGO set color 1 to 1913185. BGO set color 2 to 1067450.
Timer equals 07"-00 -> BGO set color 1 to 1451593. BGO set color 2 to 800692.
Timer equals 08"-00 -> BGO set color 1 to 990001. BGO set color 2 to 533934.
Timer equals 09"-00 -> BGO set color 1 to 396569. BGO set color 2 to 267173.

Any idea why this setup keeps throwing me the wrong colors?

Edited by The_Antisony

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
17th February, 2013 at 17/02/2013 13:48:00 -

Whatever method you're using to convert from hex string to MMF2 colour value, it's wrong.

Lets say you start with this: "#db5151" (a pinkish red colour)
Step 1 is to replace the "#" with "0x", so MMF2 knows it's a hex string.

+ Whenever...
-> ColorStr = "0x" + Right$( ColorStr , Len( ColorStr )-1)

The next step is to convert that hex string to an MMF2 colour value. The important thing to note is that you need to reverse the order of the component colours, from BGR to RGB. This may be where you're going wrong.

+ Whenever...
-> ColorVal = GetRGB(GetBlue(Val( ColorStr )), GetGreen(Val( ColorStr )), GetRed(Val( ColorStr )))

Edited by Sketchy

 
n/a

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
17th February, 2013 at 17/02/2013 21:21:05 -

Success! Yeah, I had no idea RGB had to be turned into BGR before conversion to decimal. Makes sense though, since the result was a whole lot more red than blue. Thanks, Sketchy.

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?
   

Post Reply



 



Advertisement

Worth A Click