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

Monday, 23 May 2011

Alhambra Tiling II demonstrates the use of select() function

More suggestions from MountainViewJohn have helped to simplify this design I was originally using the new switch syntax; here is a more elegant solution using trans and select (also new in the version 3 of the cfdg program). Orientation of triangle is more similar to the tiling in the Alhambra palace.
Updated 26 June 2011 to include latest syntax as per (v12) linux.

CF::Alpha = 0       // Testing version 3.0 syntax
CF::ColorDepth = 16

SQRT3 = sqrt(3)
TTOP = sin(30)/SQRT3
HEXS = SQRT3/4

// Similar to original Alhambra tiling color
GOLD = [h 33 sat 0.967 b 0.592]
BLACK = [h 0 sat 0.909 b 0.129]
GREEN = [h 148 sat 0.696 b 0.271]
BLUE = [h 225 sat 0.777 b 0.475]
RED = [h 17 sat 0.983 b 0.231]

startshape alhambraII

CF::Size = [s 6 x -2.5 y -3.5]  // trim to hide the ragged edge

CF::Background = [b -0.22]

shape alhambraII{        
  loop i = 0, 10 [x 1]{
    loop j = 0, 10 [y (HEXS * 2) x -0.5]{
      triangle[trans select(mod(i, 5), GOLD, BLACK, GREEN, BLUE, RED)]
      hexastar[x 0.5 y 0.29 s 0.33 trans select(mod(j, 5), GOLD, BLACK, GREEN, BLUE, RED)]
      hexagon[s 0.4 b 0.77]
    }    
  }
}

// Orientation more like original Alhambra tiling
path triangle {              // CF 3.0 Syntax in path loop and definition
    MOVETO(-0.5, -TTOP)
    loop 3 [r 120]{
    CURVETO(0, -TTOP, -0.25, -0.1) 
    CURVETO(0.5, -TTOP, CF::Continuous)
    }
    CLOSEPOLY() 
    FILL[]     
}

path hexagon{ 
  MOVETO(0.25, HEXS)          // 3.0 Syntax in path loop and definition
  loop 5 [r -60]{
  LINETO(0.5, 0)
  }
  CLOSEPOLY()  
  FILL[]    
} 

shape hexastar{
  TRIANGLE[r 90]
  TRIANGLE[r 270]
}

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