One way to create an equivalent of PATH (from C++ cfdg) is to use the processing shape facilities, here I have created a custom line-strip hexagon shape (ie no fill). But of course you could just as easily create a filled shape.
#########################
# hextube.rb
#########################
load_library 'context_free'
def setup_the_hextube
@hexa = ContextFree.define do
############ Begin defining custom terminal, as a hexagon (path C++ cfdg)
class << self
define_method(:hexagon) do |some_options|
size, options = *self.get_shape_values(some_options)
rot = (options[:rotation])? options[:rotation]: 0
no_fill
stroke(*options[:color])
stroke_weight(size/30)
begin_shape
6.times do |i|
vertex(size * Math.cos(Math::PI * i/3 + rot), size * Math.sin(Math::PI * i/3 + rot))
end
end_shape(CLOSE)
end
end
########### End definition of custom terminal 'hexagon'
rule :hextube do
hexa :brightness => 1.0
end
rule :hexa do
hexagon :size => 1, :brightness => 1.0
hexa :size => 0.9, :rotation => 5
end
end
end
def setup
size 800, 800
background 0
smooth
setup_the_hextube
draw_it
end
def draw_it
@hexa.render :hextube, :start_x => width/2, :start_y => height/2,
:size => height/2.1, :color => [0, 1, 1, 0.5]
end
Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0
Sunday, 23 May 2010
Ruby Processing Context Free DSL (how to do a cfdg PATH)
Labels:
context free,
DSL,
path,
ruby processing
Subscribe to:
Post Comments (Atom)
Followers
Blog Archive
-
▼
2010
(73)
-
▼
May
(9)
- Towards Penrose Tiling Using ruby-processing conte...
- Ruby Processing Context Free DSL (how to do a cfdg...
- Colored Penrose Tiling using LSystems
- Op Art using Voronoi Cell, Ruby Processing
- Voronoi Cells from the Coordinates of A Penrose Ti...
- Random Voronoi Sketch
- A Simple flower using ruby processing context free...
- Custom hbar shape for ruby processing Context Free...
- Penrose Tiling Ruby-Processing LSystems
-
▼
May
(9)
About Me
- monkstone
- I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2
No comments:
Post a Comment