# First-class colors (Part 1)

self explanatory.

It's not self-explanatory; what would be changed?

I mean, like then you could do things like ((color (color1)) + (color (color2))). to mix colors evenly, and (some % of (color (...)) + (some % of (color (...)) to mix with a percentage. the biggest change is that blocks can now report colors. also, there would be a color with RGBA (list) block, and a ([R/G/B/A/RGBA v] of color (color input), and a (color (color picker input)) block. you should also be able to put reporters in color picker slots, as now blocks can report colors.

so you want a primitive way of dealing with colors.

yeah.

Can I put in a plug here for the Colors and Crayons library? I think the only thing you really need that it doesn't either include or enable is the color-picker input. I'll fix that next library update.

I'm not sure how I feel about overloading the arithmetic operators to build an algebra of colors. I'm thinking a color is really a three-item vector (or four-item, with different rules for alpha), and we already have a meaning for addition of vectors, which is probably wrong for colors. (What if an RGB value is more than 255? Does it just get capped at 255, or is the result scaled down so that the highest value is 255? I'd have to spend yet more time with Wikipedia to learn this stuff.) Does multiplication of colors mean anything?

First class colors was probably the first thing our users asked for, back in the BYOB days, because Panther sort of had them. It didn't overload arithmetic, but it did include the two specific operations you mention, adding colors and adding colors in specified proportion. I don't understand how it computed the result of an addition:

... oh wait, yes I do. It took 50% of each. I guess that does guarantee non-overflow. I don't think it's physically correct, though. If you mix pure blue and pure green you should get cyan:

but instead they give you teal, which is a mixture of cyan with black:

I keep thinking I finally understand colors, but I don't.

it doesn't have anything else mentioned in this topic, and I need those.

What exactly do you need? `It could be really simple to code it into functions for you.

it needs to be a primitive way, because in snap every thing SHOULD be first-class.

Um, ok. But do you really need it first class how would it help? I want to know a lot about this subject right now. It seems interesting.

This seems like some confusing syntax. Can you try to make it more easy to understand?

I'll do it in 1/2 hour

Some thrown-together screenshots of what the weirdly presented syntax is in blocks:

(I have absolutely no idea what this means or does)

some % of color: the some text should be an input, and should work with NUMBERS too, and the + will be the same from operators. also why is it on pen, pen is not the same as colors.

this doesn't seem like a lot of blocks, are you sure it should be its own category?
also, the amount of categories is odd, which means the category select bar looks bad

it could be a library.

so, then the blocks would have to be in the pen category?
libraries can't create categories, to make that happen you would have to modify the editor, and the cloud, and the cloud backend. (probably not all of those, but you get the idea.)

@bh , would a library be considered primitive, just asking.

31 posts were split to a new topic: Remixing someone else's blocks

the OTHER category