View previous topic :: View next topic |
Author |
Message |
michaelp
Joined: 27 Jul 2008 Posts: 114
|
Posted: Fri Apr 17, 2009 3:58 pm Post subject: allegro colours file |
|
|
Taken from here.
Uploaded to sendspace is a .zip archive that includes a file with a bunch of colours listed at the link that I posted. I added int to the front of all of them, and did a "Find and Replace" with Color.new and makecol. Now, import this file to your program, and you will be able to choose any of the colours in that list.
The luacolours.html is a list of all the colours. It says the name, and a preview of colour.
Module name is allegro.colours.
Just stick it in your allegro import directory, so dmd/windows/import/allegro for me.
Download:
http://www.sendspace.com/file/zylqqp
Enjoy! |
|
Back to top |
|
|
torhu
Joined: 30 Mar 2006 Posts: 56
|
Posted: Wed Apr 22, 2009 12:45 pm Post subject: |
|
|
That's handy, but I don't think it'll work like that.
Code: | int snow=makecol(255,250,250); |
You can't use makecol() for static initialization. And you have to wait until after calling set_gfx_mode().
You could store the colors as RGB struct constants, and delay calling makecol until you actually need the color, there are many ways.
Code: |
const RGB snow = { 255,250,250 };
const RGB GhostWhite = { 248,248,255 };
int get_color(RGB c) { return makecol(c.r, c.g, c.b); }
// used like:
int col = get_color(snow);
|
|
|
Back to top |
|
|
michaelp
Joined: 27 Jul 2008 Posts: 114
|
Posted: Wed Apr 22, 2009 1:21 pm Post subject: |
|
|
Yeah, when I tried using it, I got lots of errors about using makecol.
I'll see what I can do to actually make it work. |
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Fri Feb 12, 2010 2:08 am Post subject: |
|
|
I've got these two ways at the moment, don't know if ones the best.
Come to think of it making a program to generate the values for each colour would be good, it would be the cleanest. Maybe I'll do that some time.
Code: |
enum Colour { red=16711680,
blue=255,
green=65280,
amber=16757760,
bluba=46335,
mag=16711935,
cyan=65535,
yellow=16776960,
gray=8421504,
white=int.max, //16777215,
black=0 };
void func() {
putpixel(screen,10,10,Colour.blue);
}
|
Code: |
class ColourPallet {
static int red,green,blue,amber,white,black,yellow,magenta,cyan;
this() {
red=makecol(255,0,0);
green=makecol(0,255,0);
blue=makecol(0,0,255);
amber=makecol(255,180,0);
white=makecol(255,255,255);
black=makecol(0,0,0); // or just 0 but I'm being consistant(sp)
yellow=makecol(255,255,0);
magenta=makecol(255,0,255);
cyan=makecol(0,255,255);
}
}
ColourPallet Colour;
void main() {
allegro_init();
// and other allegro stuff
Colour=new ColourPallet;
}
void func() {
putpixel(screen,10,10,Colour.blue);
}
|
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|