Discuss Scratch

GP1
Scratcher
100+ posts

Scratch color parameter saving format?

Hello. I opened up the JSON of a project with the
<touching color [#000000]?>
block. The block's object looked like this:
["touchingColor:", -13687519]
The value that Scratch saves to the JSON is -13687519 for the color. Looking around, it looks like this is a 8-bit color format? Perhaps RRRGGGBB? If so, why is there a negative, unless it is unsigned (or signed, what ever it is, I can't remember).

blob8108
Scratcher
1000+ posts

Scratch color parameter saving format?

Hexadecimal 0xAARRGGBB, apparently.

Have a look at this project,: I believe it's the same idea.

tosh · slowly becoming a grown-up adult and very confused about it
scimonster
Scratcher
1000+ posts

Scratch color parameter saving format?

blob8108 wrote:

Hexadecimal 0xAARRGGBB, apparently.

Have a look at this project,: I believe it's the same idea.
I agree with the statement, but where does it say that on the wiki article? ~~~~

Retired Community Moderator
BTW, i run Google Chrome 41.0.2272.101 on a Linux system - Ubuntu 14.04. NEW: iPad 4th gen. w/retina.

418 I'm a teapot (original - to be read by bored computer geeks)
THE GAME (you just lost)
; THE SEMICOLON LIVES ON IN OUR SIGS
blob8108
Scratcher
1000+ posts

Scratch color parameter saving format?

scimonster wrote:

where does it say that on the wiki article?
In a couple of places, describing color-related fields. For example, the `textColor` field on Scratch_2.0_File_Format#Costume_objects.
~~~~

tosh · slowly becoming a grown-up adult and very confused about it
MathWizz
Scratcher
100+ posts

Scratch color parameter saving format?

To add to blob, it is also signed.

running Chromium 42.0.2311.90 with Flash Player 15.0.0.189 on Arch Linux 3.19.5-1-ck
MathWizzJsScratch && sb.js & Amber (coming soon! maybe)
davidkt
Scratcher
1000+ posts

Scratch color parameter saving format?

What's the A?

Remember when I looked like this? I still do.


Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
GP1
Scratcher
100+ posts

Scratch color parameter saving format?

davidkt wrote:

What's the A?
Alpha. It is the transparency of the image.

GP1
Scratcher
100+ posts

Scratch color parameter saving format?

Ok, cool. I made some JavaScript on a JSFiddle to see if I could do it from the value to ARGB. Here is the code I got. I don't know whether I am supposed to keep the value in the project signed or not.

var colorNumber = -13687519;

var a = colorNumber >> 24 & 0xFF;
var r = colorNumber >> 16 & 0xFF;
var g = colorNumber >> 8 & 0xFF;
var b = colorNumber & 0xFF;

window.alert("a: " + a + "\nr: " + r + "\ng: " + g + "\nb: " + b);

Last edited by GP1 (April 16, 2014 22:57:30)


blob8108
Scratcher
1000+ posts

Scratch color parameter saving format?

MathWizz wrote:

To add to blob, it is also signed.

tosh · slowly becoming a grown-up adult and very confused about it

Powered by DjangoBB