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

Tuesday, 24 May 2011

Using if in Context Free 3.0 (Linux v12)

Using if to control x displacement in context free, and more subtle mod statement to to produce less obvious repeat patterns:-

   1 startshape pattern
   2 
   3 SQRT3 = sqrt(3)
   4 TTOP = sin(30)/SQRT3
   5 HEXS = SQRT3/4
   6 BLUE = [b .73 h 201 sat .53]
   7 MAGENTA = [b .53 h 42 sat .76]
   8 RED = [b .53 h 356 sat .7]
   9 GREEN = [b .68 h 132 sat .64]
  10  
  11 CF::Size = [s 8.0 x -4 y -4] 
  12 
  13 CF::Background = [b -0.2]
  14 
  15 path triangle {              
  16     MOVETO(-0.5, -TTOP)
  17     loop 3 [r 120]{
  18     CURVETO(0, -TTOP, -0.25, -0.1) 
  19     CURVETO(0.5, -TTOP, CF::Continuous)
  20     }
  21     CLOSEPOLY() 
  22     FILL[]     
  23 }
  24 
  25 shape pattern{
  26    loop i = 0, 10 [x 0.97]{
  27      loop j = 0, 10 [y 0.85]{
  28        if (mod(j, 2) == 0){           
  29        triangle [trans select(mod((i + j), 4), BLUE, MAGENTA, RED, GREEN)]
  30        }
  31        else{
  32          triangle [x 0.48 trans select(mod((i + j), 4), BLUE, MAGENTA, RED, GREEN)]
  33        }
  34      }
  35    }
  36 }
  37 

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