samples/sierpinski.rb in cf3-0.0.3 vs samples/sierpinski.rb in cf3-0.0.4

- old
+ new

@@ -1,44 +1,49 @@ require 'cf3' load_library 'control_panel' -attr_accessor :resolution, :panel +attr_accessor :resolution, :panel, :hide -def setup_the_triangle - +def setup_the_triangle @triangle = ContextFree.define do shape :tri do - triangle size: 0.5, rotation: PI + triangle size: 0.5, rotation: 180 split do tri size: 0.5, y: -0.578, x: 0, - hue: 0.8, saturation: 0.2, brightness: 0.8 + hue: 288, saturation: 0.2, brightness: 0.8 rewind - tri size: 0.5, y: 0.289, x: -0.5, hue: 0.2, - saturation: 0.2, brightness: 0.8 + tri size: 0.5, y: 0.289, x: -0.5, hue: 72, + saturation: 0.2, brightness: 0.8 rewind - tri size: 0.5, y: 0.289, x: 0.5, hue: 0.2, - saturation: 0.2, brightness: 0.8 + tri size: 0.5, y: 0.289, x: 0.5, hue: 72, + saturation: 0.2, brightness: 0.8 end - end - + end end end def setup size 600, 600 setup_the_triangle no_stroke - color_mode HSB, 1.0 - smooth + @hide = false @resolution = 5 control_panel do |p| + p.look_feel "Metal" # optionall set look and feel p.slider :resolution, (2..50), 5 @panel = p end end def draw - panel.set_visible(self.visible) # display panel after sketch frame + unless hide + panel.set_visible(true) # display panel after sketch frame + @hide = true + end background 0.1 - @triangle.render :tri, size: height/1.1, color: [0, 0.5, 1], stop_size: @resolution, start_y: height/1.65 + @triangle.render :tri, size: height/1.1, color: [0, 0.5, 1.0, 1.0], stop_size: @resolution, start_y: height/1.65 +end + +def mouse_clicked + @hide = false end