Discuss Scratch

we_bi_wa_bu
Scratcher
3 posts

How do you get specific colors with the set pen color to block

I am so confused on how to get specific colors with this pen block, someone explain this to me pls

set pen color to (number)
awesome-llama
Scratcher
1000+ posts

How do you get specific colors with the set pen color to block

Scratch uses 8 bits per channel color, in RGB format. Transparency is also possible as ARGB but I won't explain it yet.

The color represented as a number is the channels combined:

set pen color to ((((R) * (65536)) + ((G) * (256))) + (B))
  • R, G, and B are integers between 0 and 255
  • 65536 is calculated from 256^2

A hidden feature of Scratch is that it can handle hexadecimal numbers. The following also work for setting the color:

set pen color to (join [0x] [ff3000])
set pen color to (join [#] [ff3000])

The join blocks are just so that text can be entered into the input.
we_bi_wa_bu
Scratcher
3 posts

How do you get specific colors with the set pen color to block

awesome-llama wrote:

Scratch uses 8 bits per channel color, in RGB format. Transparency is also possible as ARGB but I won't explain it yet.

The color represented as a number is the channels combined:

set pen color to ((((R) * (65536)) + ((G) * (256))) + (B))
  • R, G, and B are integers between 0 and 255
  • 65536 is calculated from 256^2

A hidden feature of Scratch is that it can handle hexadecimal numbers. The following also work for setting the color:

set pen color to (join [0x] [ff3000])
set pen color to (join [#] [ff3000])

The join blocks are just so that text can be entered into the input.

TYSM this helped a lot

Powered by DjangoBB