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

Wednesday, 1 July 2009

Defeating the object

As part of my experimentation with context free, I wanted to see if I could produce a more realistic Mondrian, without converting an image file. I think I've proved it can be done, it is a bit tedious (though could be improved by using a python script to generate the rules, therefore might be a starting point for experiments with cfdg for 'little people'). What I've done is specify row by row (à la image to cfdg script), replaces a ca. 5000 line script with something a bit more elegant, nevertheless very constrained, hence defeating context free concept.

Here's the code:

   1:startshape mondrian
2:
3:rule mondrian{
4:top{y 10}
5:first{}
6:middle_row{y -1}
7:second{y -2}
8:top{y -12}
9:}
10:
11:rule first_colors{
12:border{}
13:part_row{x 1}
14:border{x 11}
15:part_row{x 12 hue 360 sat 1}
16:border{x 22}
17:}
18:
19:rule second_colors{
20:border{}
21:part_row{x 1 hue 60 sat 1}
22:border{x 11}
23:part_row{x 12 hue 360 sat 1}
24:border{x 22}
25:}
26:// increment y
27:rule first{
28:10 * {y 1}first_colors{}
29:}
30:// decrement y
31:rule second{
32:10 * {y -1}second_colors{}
33:}
34:
35:rule middle_row{
36:12 *{x 1}border{}
37:part_row{x 12 hue 360 sat 1}
38:border{x 22}
39:}
40:
41:rule top{
42:23 *{x 1}border{}
43:}
44:
45:rule part_row{
46:10 * {x 1}SQUARE{ s 1 b 1 }
47:}
48:
49:rule border{
50:SQUARE{ s 1 b -1 }
51:}


and the result



However this exercise did make me a bit more familiar with the context free syntax, and also occasioned this perverse idea; why not change the SQUARE to be implemented as a grid of CIRCLES, now that is something context free excels at.
Here is my code:

   1:startshape mondrian
2:
3:rule mondrian{
4:top{y 10}
5:first{}
6:middle_row{y -1}
7:second{y -2}
8:top{y -12}
9:}
10:
11:rule first_colors{
12:border{}
13:part_row{x 1}
14:border{x 11}
15:part_row{x 12 hue 360 sat 1}
16:border{x 22}
17:}
18:
19:rule second_colors{
20:border{}
21:part_row{x 1 hue 60 sat 1}
22:border{x 11}
23:part_row{x 12 hue 360 sat 1}
24:border{x 22}
25:}
26:// increment y
27:rule first{
28:10 * {y 1}first_colors{}
29:}
30:// decrement y
31:rule second{
32:10 * {y -1}second_colors{}
33:}
34:
35:rule middle_row{
36:12 *{x 1}border{}
37:part_row{x 12 hue 360 sat 1}
38:border{x 22}
39:}
40:
41:rule top{
42:23 *{x 1}border{}
43:}
44:
45:rule part_row{
46:10 * {x 1}square{ s 1 b 1 }
47:}
48:
49:rule border{
50:square{ s 1 b -1 }
51:}
52:
53:rule square{
54:2 * {y 0.5}{
55:2 * {x 0.5}
56:CIRCLE{s 0.5}
57:}
58:}


3 comments:

  1. You know, that's almost like print.

    ReplyDelete
  2. Yes I made it deliberately simple with only 2 by 2 dot squares. Roy Lichtenstein, could be a next target?

    ReplyDelete
  3. Of course! And another favourite of mine. It is looking so good.

    ReplyDelete

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