Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and processing.py

Friday, 24 July 2009

Starfield with CFDG (revised)

I'm a bit confused there this new directive (similar to tile since release version of 2.2) that you can apply that sets the virtual size of your image (or so I thought), that can produced a cropped image. So I gave it a go with my revised starfield (a few spiky stars), I set the size to 600 X 600 assuming with default settings I would get a cropped image of 500 x 500, ie more stars in the middle but I got the reverse. So being quite pragmatic I set the size to to 200 x 200 and ran the rule, and I got the cropped image I was looking for!!! PS: the x and y values of the size directive are supposed to set the center of the image, but don't make any assumptions about that, I needed to set them both to 0; may'be because of my rules....
   1:startshape starfield
2:size {s 205 154 x 0 y 0} // to crop your image, does not work the way I expected it to
3:background{hue 240 b -0.9 sat 1} // dark blue background
4:rule starfield{ // 5 times create white stars
5:5*{}either{x 2} // empty directive seems OK
6:}
7:
8:// create two instances of star rotate both and flip one
9:rule both{
10:star{rotate 30}
11:star{rotate -30 flip 90}
12:}
13:
14:// multiple either, create a star
15:rule either{
16:star{}
17:}
18:
19:// or create a star and flip it
20:rule either{
21:star{flip 90}
22:}
23:
24:// base star is a translated circle
25:rule star {
26:CIRCLE{b 1} // set star brightness at terminal seems to be safer
27:translate{size 0.91 y 59.2}
28:}
29:
30:// spiky star is a translated circle base star with spikes
31:rule star 0.3 {
32:CIRCLE{b 1} // set star brightness at terminal seems to be safer
33:translate{size 0.99 y 59.2}
34:spike{r 45}
35:spike{s 0.7}
36:}
37:
38:// multiple translate rules adds more randomness
39:rule translate {star {rotate 126}}
40:rule translate {
41:star{rotate 127}
42:}
43:
44:rule translate {both{}}
45:rule translate {star {rotate -110 flip 90}}
46:
47:path spike {
48: 4 * {r 90} {
49: MOVETO {x 0 y 0}
50: LINETO {y 1.5}
51: }
52: STROKE {s 2 b 1 p roundcap }
53:}





Now there's a further twist to this I wanted to produce a screen saver sized version. So entered the desired height and width options via the command line, and what appeared to be happening was the program ignored the external entered size (for the purpose of cropping).
So on the basis of my experience I would say if you want a cropped image, then set the size in your rules file to less than 500. Conversely if for some peculiar reason you want to effectively shrink your image on the canvas set the dimensions in the rules file to greater than 500 (you would have to be a bit mad to do it though). Note I have now updated my jedit mode, but it still can't differentiate between size directive and size attribute (most people use 's' for attribute anyway) and I have uploaded it to JEdit.org where you can to download a copy of my mode file.
Follow the link to other downloads then modes the file you want is cfdg.xml. Once downloaded follow instructions in jEdit help to install it. Whilst I was at it also uploaded a revised processing.xml mode (all I did was to update the syntax toxi did all the hard work of setting it up, but he gave me the OK to upload the revised version at jEdit).

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2