Change colour of sprite

I normally draw simple sprite shape in bright red

image

and then just use set color effect
image
to get whatever colour I'm after

But it's completely stumping me on how to change it to black or grey without having to manipulate the pixel values directly

image

I'm going down the colour rabbit hole once again :slight_smile:

I'm currently at this point

Looking at Snap! function transform_HSV code - it looks like whenever a set colour or set saturation or set brightness block is processed, each sprite pixel is converted from RGB to HSV colour space -Note brightness and value (V) refer to the same thing

Then there is a LOT of code with lots of ifs in it manipulating these HSV values and finally the HSV data is converted back to RGB and pixel updated

My understanding of HSV is that a full bright red RGB 255,0,0 is converted to HSV 0, 100,100

My next understanding is that reducing V to 50 should change the the RGB to 127,0,0

And if V is reduced to 0, we should get 0,0,0

But if I use set brightness to 0 in Snap!, nothing happens to the colour of the sprite

Is this a bug/feature in Snap! or am I not understanding colours - this wouldn't be the first time :slight_smile:

I just played around with the Colors and Crayon library
image

and these work like I think they should - changing V to 0 changes the RGB value to 0,0,0

Black and white are a neutral colours. Need is change the brightest to set black or white colour- more nothing I can say :wink:

I think the problem is that you're confusing pen color with sprite color. They are the same if the sprite is wearing its turtle costume, but since you made a different costume for it, the two are independent. After some experimentation I found that what you need is
untitled script pic (3)
which I confess isn't what I expected.

I wasn't confusing pen color with sprite color - I just used the pen blocks to check how they behaved :slight_smile:

Your discovery that using -ve values for saturation and brightness, does let me desaturate a sprite and convert it to a black-> white greyscale.

So that is solution for my original problem :slight_smile:

It has sorted my project out which is a simulation of this Neopixels digital twin project

image

Red indicates North on the compass so you can see the current heading of the Mayflower MAS400 craft I talked about at SnapCon21

ProjectName=Mayflower_DigitialTwinOfTwin

Very cool!

Topic probably was resolved, yes?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.