I’ve written a class file that extends the colour management of Codea. It’s a wrapper around the current colour stuff, it’s main purpose is to define some basic manipulations of colours, including blending, tinting, shading, and toning. It also defines a whole raft of “standard colours”, based on the SVG and X11 lists (you need to call a function to actually define them).
Yay for named colors! Sorely needed - the color picker is dandy, but typing a name is easier, especially when that’s what you’re used to. I will be using this.
it would be nice to expose this as a function, not just as a wrapper - so I could say “background(Colour(“DarkGrey1”))” - another nice add might be some “fuzzy matching” of the color names, so “darkgrey” might still work. Finally - it needs to complain if you pass it bad parameters (like 2 of them) rather than fail silently, please. I have been trying to take to heart the suggestion that we’re computer science guys writing for other computer science guys, and perhaps our bar is set too high for many potential Codea users…
A superlative suggestion, sir, with just two minor flaws. One: we don’t have any defensive shields. And two: we don’t have any defensive shields. Now I realise that, technically speaking, that’s only one flaw; but I thought it was such a big one, it was worth mentioning twice.
What I meant to say was: those are both excellent suggestions, but I don’t know how to do either. How do we “complain” in Codea?
Actually, the first is eminently possible. I misunderstood what you meant when I first read it.
Very nice! Something like this is sorely needed. Would you mind if we copied some of your work into the internal “color” type? Specifically having global colour names, so they could be added to the autocomplete system.
While I prefer spelling “colour” the way you have it, most code seems to standardise on American spelling.
Would you mind if we copied some of your work into the internal “color” type?
Vær så godt! I decided to put it in the public domain precisely so that anyone could do what they like with it without needing to ask permission (if you need it released under a different licence, just ask - I’m no expert in these matters).
While I prefer spelling “colour” the way you have it
Yippee!
most code seems to standardise on American spelling.
\grumble, grumble, grumble\ Oh, all right then.
If you know about TeX/LaTeX, you might appreciate the fact that the start of my documents is:
PS. Did not recognize the quote; google says Red Dwarf, which I’ve seen like part of an episode of. It’s been on my “you should go watch this” list for a decade now, but couldn’t be bothered. But clearly I must, because I did snort, out loud.
Okay, it now complains if given the wrong number of arguments (though it doesn’t check to see if the arguments that it gets are the right type). The arrays of named colours are “exposed” as Colour.svg.Name and Colour.x11.Name and there is a function Colour.byName that selects the colour object that best fits the name. Syntax is Colour.byName(type,name) where type is one of svg or x11. The colour is chosen as the one that matches the given name as the start, and the test is lower case. So in the x11 set then azure will match Azure1.
And, yes, you should go watch Red Dwarf. It is truly excruciatingly funny.
I haven’t had a chance to download and try but it does look great and well thought out.
As an american who watched Red Dwarf in colour and not color and as self-appointed representative for all americans, I vote for keeping colour. But I understand that you have to be pratical. If you’ll excuse me I have to go a few miles down the road to fill my tires with the right pounds of pressure while hoping we will someday catch up to the 20th century here.
I use a system whereby I have direct access to the directory (libimobiledevice on Linux) so I haven’t tested cut-and-pasting. If there’s something that I can do from my side that would make it easier, just say.
Did I see a little Norwegian in your post there Andrew?
Yes. I tend to scatter a bit in my witterings from time to time. I’m a Brit, but living in Norway and so trying to learn the language.
I vote for keeping colour.
Great! Of course, the best would be to provide both, but I don’t know if that’s possible.
One reason for me to choose Colour was that color was already taken.
inspired by the colour-mapping of Andrew I played around with that a bit, and found an interesting effect. Below you will find a short example that explains that. In case you want to have a smooth transition between the colors, you need to set noSmooth() next to the fill command to fill a rect or an ellipse.
Hope that helps
– Use this function to perform your initial setup
function setup()
print(“Effect of noSmooth() on fill() command”)
end
– This function gets called once every frame
function draw()
iparameter("toggle_noSmooth",0,1,0)
black=color(0,0,0,255)
background(black)
w=50; h=w
for i=1, 10 do
r=i*20
g=255-i*20
b=128
mycolor = color(r,g,b,255)
fill(mycolor)
if toggle_noSmooth==1 then
noSmooth()
end
rect(20+(i-1)*w,200,w,h)
end