more color for alex

until today, fig made up to 16 colors available to the user. in fact, fig hasnt changed– and yet:

mcfknqc

 

ive yet to come up with the precise way i want to do more than 16 colors– as a feature of the language. this is largely due to the fact that graphics can do 16 million colors, while a term window or framebuffer can be limited to 16 or 256. at 16, it is consistent.

but almost no one wants that limit of 16, and so i finally wrote a quick routine to access figs internal palette so that a mixed-native rgb function could be used. now fig programs can be a lot prettier. alex really is the reason it happened today, instead of some other time (next year?) because that 16 color palette wasnt cutting it for trying to do graphics stuff all the time. yeah, i can do a lot with 16 colors. but i really wanted more. and this is how its done:

#### license: creative commons cc0 1.0 (public domain)
#### http://creativecommons.org/publicdomain/zero/1.0/

function rgbcolor r g b
python
    now = 0 ; figcgapal[0] = (r, g, b)
    fig
    fig

# for alex: the first ever fig program with > 16 colors

now display
for y 1 256 1
for x 1 256 1

for my 0 1 1
for mx 0 1 1

r1 x minus 1
g1 y minus 1
b1 mx times 64
b2 my times 128 plus b1
xs mx times 256 plus x
ys my times 256 plus y
now rgbcolor r1 g1 b2 pset xs ys 0

next
next

next
now display
next
now lineinput

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s