29.11.2012 Views

MetaFun - Pragma ADE

MetaFun - Pragma ADE

MetaFun - Pragma ADE

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

290<br />

This rather nice circle is defined as:<br />

colorcircle(4cm,(.4,.6,.8),(.8,.4,.6),(.6,.8,.4));<br />

The final implementation, which is part of METAFUN, is slightly more efficient.<br />

vardef colorcircle (expr size, red, green, blue) =<br />

save r, g, b, c, m, y, w ; save radius ;<br />

path r, g, b, c, m, y, w ; numeric radius ;<br />

radius := 5cm ; pickup pencircle scaled (radius/25) ;<br />

transform t ; t := identity rotatedaround(origin,120) ;<br />

r := fullcircle rotated 90 scaled radius<br />

shifted (0,radius/4) rotatedaround(origin,135) ;<br />

b := r transformed t ; g := b transformed t ;<br />

c := buildcycle(subpath(1,7) of g, subpath(1,7) of b) ;<br />

y := c transformed t ; m := y transformed t ;<br />

w := buildcycle(subpath(3,5) of r,<br />

subpath(3,5) of g, subpath(3,5) of b) ;<br />

pushcurrentpicture ;<br />

fill r withcolor red ;<br />

fill g withcolor green ;<br />

fill b withcolor blue ;<br />

fill c withcolor white-red ;<br />

fill m withcolor white-green ;<br />

fill y withcolor white-blue ;<br />

fill w withcolor white ;<br />

for i = r,g,b,c,m,y : draw i withcolor .5white ; endfor ;<br />

currentpicture := currentpicture xsized size ;<br />

A few applications Color circles

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!