Discuss Scratch

PH-zero
Scratcher
100+ posts

HTML-colors

Hey , i already mentioned that problem here

In this post i'm going to suggest something that is easier to realize:

HTML-Colors!

It would look like this:

ColorFF7500touched?

Red: FF (Maximum)
Green: 75
Blue: 00 (Minimum)

Examples:

White: FFFFFF
Black 000000
Pure Red: FF0000
Gray: 888888
Cyan: 00FFFF

And there is no need to eliminate the old color-blocks-system, this idea could simple be added.
cobraguy
Scratcher
1000+ posts

HTML-colors

You mean this?

touchingcolor?

Or do you mean that instead of having a block that uses the color picker, you could use a hexadecimal?

Last edited by cobraguy (Nov. 11, 2013 17:26:55)

jTron
Scratcher
100+ posts

HTML-colors

Hmm… You mean like this?



(Naturally, the text area will accept many things, such as BB0000, RGB(187, 0, 0), RGBP(73.3, 0, 0), cmyk(0, 100, 100, 27), [hsl, hsv, lab, lch, xyz, luv, xyY, Hunter-lab, etc.])

And maybe it accepts strings in the color slot? Or we go panther and add a new data type? Or we allow variables to hold colors? *licks lips*

Last edited by jTron (Nov. 11, 2013 23:11:37)

PH-zero
Scratcher
100+ posts

HTML-colors

Or do you mean that instead of having a block that uses the color picker, you could use a hexadecimal?
You got it

Or we allow variables to hold colors?
This is exactly what i need!!! colors stored in a string! Perfect!
xlk
Scratcher
100+ posts

HTML-colors

PH-zero wrote:

Or do you mean that instead of having a block that uses the color picker, you could use a hexadecimal?
You got it

Or we allow variables to hold colors?
This is exactly what i need!!! colors stored in a string! Perfect!
You can do that with variables. If you can't put a variable on the colour square, check out this little project of mine http://scratch.mit.edu/projects/12392264/
PH-zero
Scratcher
100+ posts

HTML-colors

PH-zero wrote:

Or do you mean that instead of having a block that uses the color picker, you could use a hexadecimal?

You got it

Or we allow variables to hold colors?

This is exactly what i need!!! colors stored in a string! Perfect!

You can do that with variables. If you can't put a variable on the colour square, check out this little project of mine http://scratch.mit.edu/projects/12392264/

I know you can SET colors with variables but you can not (and thats my problem) GET the colors
with numbers/variables.

I need to check a color-collision, it looks like this:

colorelement1ofColorListtouched?

It seems like it just doesnt work like this… =/
But it would work if you could use HTML-coded colors.
jTron
Scratcher
100+ posts

HTML-colors

PH-zero wrote:

PH-zero wrote:

Or do you mean that instead of having a block that uses the color picker, you could use a hexadecimal?

You got it

Or we allow variables to hold colors?

This is exactly what i need!!! colors stored in a string! Perfect!

You can do that with variables. If you can't put a variable on the colour square, check out this little project of mine http://scratch.mit.edu/projects/12392264/

I know you can SET colors with variables but you can not (and thats my problem) GET the colors
with numbers/variables.

I need to check a color-collision, it looks like this:

colorelement1ofColorListtouched?

It seems like it just doesnt work like this… =/
But it would work if you could use HTML-coded colors.
So what you're really wanting is for a specific data type for colors?
Like [set pen color to [color2]]
And then with modifier blocks like [change [color2 v] hue by ( )]
Etc.?

Last edited by jTron (Nov. 12, 2013 23:25:10)

turkey3_test
Scratcher
1000+ posts

HTML-colors

Don't support, because the current method is fine and it's too confusing for new users.
PH-zero
Scratcher
100+ posts

HTML-colors

Don't support, because the current method is fine and it's too confusing for new users.
Thats not true, at least in my opinion.
The current method is missing the Saturation-factor.
You should be able to set:
Pen Hue.
Pen Brightness.
Pen Saturation.
That wouldn't be confusing at all.
I think the current method is rather confusing:
You can set the color field to a color by color-picking but you can also use a number but you cannot use
one number for all colors as there are over 16.7 Million colors!
DadOfMrLog
Scratcher
1000+ posts

HTML-colors

PH-zero wrote:

The current method is missing the Saturation-factor.
Yes, it would be handy to have “set/change pen saturation…” - I've made a project which provides this functionality, but it requires replacing Scratch's built-in “set/change pen color…” and “set/change pen shade…” blocks with the custom ones I built to go with the new “set/change pen saturation…” (but they are ‘drop-in’ replacements, so it's not hard).

PH-zero wrote:

You can set the color field to a color by color-picking but you can also use a number but you cannot use
one number for all colors as there are over 16.7 Million colors!
I'm not really clear what you want? You can put a variable into the “set pen color…” block (the one that has the colour picker, not the one that sets the pen hue with a number from zero to 200). The number you use is RGB, so it's red*65536+green*256+blue:
setRGBColtored*65536+green*256+bluesetpencolortoRGBCol note this is the block that usually shows the colour picker...
So you have a totally general colour in the variable “RGBCol” that you can use elsewhere - yes, even in touching blocks:
iftouchingcolorRGBCol?thendostuff...
So that means you *can* use a normal variable to hold any colour value.

If you want to find which colour is at a particular pixel, that's a different matter - it's possible to make a project that goes through all possible colours and reports when it finds the one it's touching (fortunately, it doesn't have to go through all 16.7 million, because Scratch's colour-matching is very ‘loose’… but that unfortunately also means you can't tell precisely which colour it is…)
I've made such a project right here! -It's rather too slow to be practical, though.

Hope that's helpful in some way!

Last edited by DadOfMrLog (Nov. 13, 2013 13:36:19)

scratchisthebest
Scratcher
1000+ posts

HTML-colors

256 is 1<<8 and 65536 is 1<<16 (<< meaning leftshift)
so maybe 1<<24 will provide alpha as well, presuming colors are stored in the common aaaaaaaarrrrrrrrggggggggbbbbbbbb format. Maybe it will just explode though. We'll need to try.
PH-zero
Scratcher
100+ posts

HTML-colors

Thanks DadOfMrLog! So you really have to put in a number between 0 and 16.7 Million…
Now someone tell me that this method is fine… xD

This would make much more sense:

Setpen-huetoSetpen-brightnesstoSetpen-saturationtoColor touched?Huetouched?Brightnesstouched?Saturtationtouched?

Sorry if i'm wrong but i think that would be less confusing than the current method.
In fact the current method confused me when i used it for the first time.
DadOfMrLog
Scratcher
1000+ posts

HTML-colors

scratchisthebest wrote:

256 is 1<<8 and 65536 is 1<<16 (<< meaning leftshift)
so maybe 1<<24 will provide alpha as well, presuming colors are stored in the common aaaaaaaarrrrrrrrggggggggbbbbbbbb format. Maybe it will just explode though. We'll need to try.
Unfortunately not - that was one of the first things I tried with it
(It appears to just ignore the alpha part.)

Last edited by DadOfMrLog (Nov. 13, 2013 16:43:04)

DadOfMrLog
Scratcher
1000+ posts

HTML-colors

PH-zero wrote:

Color touched?
If you want to do it with hex values, here's a converter I whipped up:
definesetcomptohexdigitsetcomptohexdigit note: no proper checking for invalid hex digitsifcomp=athensetcompto10elseifcomp=bthensetcompto11elseifcomp=cthensetcompto12elseifcomp=dthensetcompto13elseifcomp=ethensetcompto14elseifcomp=fthensetcompto15definesetaColourtorgbhexsetaColourto0setposto0repeatlengthofrgbhexchangeposby1setcomptoletterposofrgbhexsetaColourtoaColour*16+compsetaColourtoFF7500iftouchingaColour?thendostuff...setpencolortoaColour
(Hope I got that all right - not checked it!)

PH-zero wrote:

Huetouched?Brightnesstouched?Saturtationtouched?
The above is something completely different, though - checking specific HSB components.

One major problem with that is the way that HSB works - try it out in my HSB project and you might see the issue…
Set the brightness to zero, and you'll get black, no matter what hue & saturation are set to. Conversely, brightness set to 100 gives white, no matter what values are for hue/saturation.
Setting saturation to zero gives a similar effect - changing brightness only changes the colour from black to white (through greys), but changing the hue does nothing.

That means there are singularities in the RGB <-> HSB conversion - given certain RGB values (e.g. 000000 or FFFFFF), there are multiple possible HSB values (for white or black, the H and S could be anything - only B matters).

This means you have a potential problem when asking if you're touching a particular saturation, or hue. If the pixel is black or white, you have no idea what the answers should be. If the pixel is grey, you know the saturation (zero) and brightness, but you have no idea what the answer is if asking about its hue…


I guess it would be possible to have blocks that check if touching a specific value of one of the R,G,B components. TBH, though, I'm not sure how practical that is to use. (Actually, it wouldn't be that hard to script it, too, taking my RGB detector project as a starting point. It'd cause significant lag, though, if used too frequently, since there are so many possible remaining colour values to check through, even when one component is fixed…)

Last edited by DadOfMrLog (Nov. 13, 2013 17:32:23)

PH-zero
Scratcher
100+ posts

HTML-colors

Thanks again DadOfMrLog, I'll try you'r first solution!

And yes you're right… if the hex value is for example FFFFFF and you want to convert HSB into RGB you loose a bit of information…
And the other way, RGB -> HSB, you have to make somthing up (the hue)
turkey3_test
Scratcher
1000+ posts

HTML-colors

PH-zero wrote:

Don't support, because the current method is fine and it's too confusing for new users.
Thats not true, at least in my opinion.
The current method is missing the Saturation-factor.
You should be able to set:
Pen Hue.
Pen Brightness.
Pen Saturation.
That wouldn't be confusing at all.
I think the current method is rather confusing:
You can set the color field to a color by color-picking but you can also use a number but you cannot use
one number for all colors as there are over 16.7 Million colors!
I definitely support having saturation, but not entering the HTML color value.
AonymousGuy
Scratcher
1000+ posts

HTML-colors

Wouldn't there need to be a new input type for hexadecimal? (so that people could enter ABCDEF but not something like COLOR1 into the input)

I have always wanted to use numbers for colors detected.

What if we could store colors in variables? In a language called C#, there is a type called Color which, when an instance is made, can store a color.

Also, I really don't like hexadecimal. What if there was a variation of the block that converted from decimal to hexadecimal, so that you could just scroll through all the colors to see what color a sprite was touching instead of making a hex-decimal converter and converting the number each time?

Sorry for all the negativity, because I really would like numeric / hexadecimal color detection.
HarryNews
Scratcher
3 posts

HTML-colors

PH-zero wrote:

I know you can SET colors with variables but you can not (and thats my problem) GET the colors
with numbers/variables.

Oh my god please tell me how to set colors with variables! I tried putting a variable of value 1671168 in a set pen to block but it didn't work
TheLogFather
Scratcher
1000+ posts

HTML-colors

Be sure to use the pen colour block that has the colour-picker square (not the one that takes a ‘hue’ from zero to 200 [199?]).

i.e. use this one:
setpencolorto
Just go ahead and drop the variable where the square is

To understand how to get the right colours, see the block examples in my post above: http://scratch.mit.edu/discuss/post/184294/

Last edited by TheLogFather (March 14, 2014 21:35:21)

HarryTwos
Scratcher
6 posts

HTML-colors

cobraguy wrote:

You mean this?

touchingcolor?

Or do you mean that instead of having a block that uses the color picker, you could use a hexadecimal?
What about being able to make a variable of what colour it is touching?

Powered by DjangoBB