Discuss Scratch

CamManCraft
Scratcher
32 posts

HSL and RGB levels

Hello, I have been working on a project lately about customizing a character. You can set a color for different clothing items such as pants and shirts, but instead of making each costume have a different color, I wanted to do something where I can set 1 costume be any color that I want. There is no way to do that currently with sprites so I have a suggestion for that: HSL and/or RGB levels.

Using Brightness and Color levels for costumes are helpful, but they don't give all colors such as shades of black and white. This will also be more user friendly and easier to customize colors for costumes with the same shape.

Here are some examples of what these new levels could look like:

change [Hue v] effect by (25) 
change [Saturation v] effect by (25)
change [Lightness v] effect by (25)

change [Red v] effect by (25)
change [Green v] effect by (25)
change [Blue v] effect by (25)

Hopefully this will get added so that you won't either have less colors with the color and lightness levels, or have multiple costumes with different colors. Thanks!

Hello I am CamManCraft! I make Art, Animations, and Games!
__________>>>> CamManCraft's Scratch Page <<<<__________
jakel181
Scratcher
1000+ posts

HSL and RGB levels

Thats a Great Idea! Support. If you are familiar with the the pen tool there is kind of a work around, but not much. I'll let TheLogFather explain in this post https://scratch.mit.edu/discuss/topic/114308/?page=1

TheLogFather wrote:

To clarify how pen alpha works…


How it used to be:

The “set pen color” block (with the square colour-picker) allows you to put in a numerical expression. Up until v435.2 of the Scratch player, that value corresponded to an RGB colour-triplet (RGB means red-green-blue, see https://en.wikipedia.org/wiki/RGB_color_model ).

It worked like this:
set pen color to ( ( ( ( (R) * (256) ) + (G) ) * (256) ) + (B) ) // the block with colour-picker, NOT the one you type into
(R) // the red component (whole number, zero to 255)
(G) // the green component (whole number, zero to 255)
(B) // the blue component (whole number, zero to 255)


What is alpha?

In computer graphics, drawing is often done with not just RGB, but ARGB. That extra ‘A’ at the start stands for the ‘alpha’ value, and it determines how a colour ‘blends’ with what's already behind it. ( See https://en.wikipedia.org/wiki/Alpha_compositing )

If alpha=1 then it completely overwrites what's underneath. If alpha=0 then it means completely transparent (i.e. it does nothing to what's underneath).

Since A has to be in the range zero to 255 (like R, G & B), the A is scaled such that ‘full’ A of 255 corresponds to alpha=1 (and A=0 is also alpha=0).


How it is now:

As of v435.2 release of the Scratch player, the Scratch pen now also supports that extra ‘A’ component:
set pen color to ( ( ( ( ( ( (A)*(256) ) + (R) ) * (256) ) + (G) ) * (256) ) + (B) ) // the one with the colour-picker
(A) // the alpha component (whole number, *ONE* to 255) - more alpha means less transparent, but zero is same as 255

Note that A=zero would usually imply fully transparent - i.e. invisible. Since it effectively wouldn't do anything to draw with such a colour, Scratch assumes that you really meant fully opaque (i.e. A=255).

Also, since A=0 makes the expression above the same as it was before v435.2, it means we *must* have A=0 being the same as A=255 to ensure projects using just the RGB triplet still draw as they used to…


Hope that helps to explain it!

Last edited by jakel181 (April 19, 2018 13:41:45)


Disco Calculator | Is it Prime?
Translate The SDS | The Scratch Wiki

define How to scratch
think [Creative]
This message was transmitted using 100% recycled electrons
;
KrisBigK
Scratcher
38 posts

HSL and RGB levels

Support. If the blocks were added, then it will be possible to make a white costume into another color except grey.
CamManCraft
Scratcher
32 posts

HSL and RGB levels

jakel181 wrote:

Thats a Great Idea! Support. If you are familiar with the the pen tool there is kind of a work around, but not much. I'll let TheLogFather explain in this post https://scratch.mit.edu/discuss/topic/114308/?page=1

Yeah that seems pretty cool, but using the pen tool would be hard to make different shapes for what I want in the game that I am making. Making different clothing items is a little complicated for the pen tool and would require a lot of coding for it to make the shape. So doing the RGB or HSL levels like I suggested would be easier to use and would be for sprites and costumes instead of making shapes from pen.

Hello I am CamManCraft! I make Art, Animations, and Games!
__________>>>> CamManCraft's Scratch Page <<<<__________
jakel181
Scratcher
1000+ posts

HSL and RGB levels

CamManCraft wrote:

jakel181 wrote:

Thats a Great Idea! Support. If you are familiar with the the pen tool there is kind of a work around, but not much. I'll let TheLogFather explain in this post https://scratch.mit.edu/discuss/topic/114308/?page=1

Yeah that seems pretty cool, but using the pen tool would be hard to make different shapes for what I want in the game that I am making. Making different clothing items is a little complicated for the pen tool and would require a lot of coding for it to make the shape. So doing the RGB or HSL levels like I suggested would be easier to use and would be for sprites and costumes instead of making shapes from pen.
Making shapes with the pen is easy let me wip up a quick demo project of some pants (because why not?)

Disco Calculator | Is it Prime?
Translate The SDS | The Scratch Wiki

define How to scratch
think [Creative]
This message was transmitted using 100% recycled electrons
;
CamManCraft
Scratcher
32 posts

HSL and RGB levels

jakel181 wrote:

Making shapes with the pen is easy let me wip up a quick demo project of some pants (because why not?)

Ok thanks! I will make sure to check out that project to learn how to make basic shapes with pen with it and hopefully it will work out in the game that I am currently making.

Hello I am CamManCraft! I make Art, Animations, and Games!
__________>>>> CamManCraft's Scratch Page <<<<__________
jakel181
Scratcher
1000+ posts

HSL and RGB levels

https://scratch.mit.edu/projects/217361101/#player

Disco Calculator | Is it Prime?
Translate The SDS | The Scratch Wiki

define How to scratch
think [Creative]
This message was transmitted using 100% recycled electrons
;

Powered by DjangoBB

Standard | Mobile