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).
The code is at: http://www.math.ntnu.no/~stacey/HowDidIDoThat/iPad/Codea.html
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
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:
and so on.
See other thread - “complain” can be as simple as
print(“Holy Cow! you passed the wrong number of parameters to Colour()!”)
I just hate a silent fail, because I don’t know what I did wrong.
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.x11.Name and there is a function
Colour.byName that selects the colour object that best fits the name. Syntax is
type is one of
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
And, yes, you should go watch Red Dwarf. It is truly excruciatingly funny.
This looks awesome! My iPad couldn’t copy the class though, so I couldn’t try it out
Did I see a little Norwegian in your post there Andrew?
Greetings from Norway
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.
My iPad couldn’t copy the class though
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.
Incidentally, there’s a bit of discussion on copying in another thread. I outline my method in this post: http://www.twolivesleft.com/Codea/Talk/discussion/comment/966#Comment_966
I wanted to see the fonts with their names.
Uses Hersey fonts class with the Colour class
It’s a bit slow and there’s possibly a better way to go
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
print(“Effect of noSmooth() on fill() command”)
– This function gets called once every frame
for i=1, 10 do
mycolor = color(r,g,b,255)
if toggle_noSmooth==1 then