require 'bizzieLibrary' require 'GLUtils.rb' $animate = true $clear = true $colorVal = 0.5 $colorDelta = 0.02 setClearColor($white) setColor($black) def updateAngle(newAngle) $angle = newAngle $cos = Math.cos(newAngle) $sin = Math.sin(newAngle) end $dispersion = 0.4 $dispersionDelta = 0.05 $length = 0.4 $lengthDelta = 0.05 updateAngle(randomAngleRadians) $angleDelta = $pi / 8.0 $skip = 1000 $skipDelta = 100 $counter = 0 $down = false $display = Proc.new { if $clear clearScreen $clear = false end $counter += 1 if $counter > $skip $counter = 0 if $down pt = jitter($basisPt, rand * $dispersion) len = $length * rand ptB = pt + [$cos * len, $sin * len] drawLine(pt, ptB) end end GL.Flush } $mouseClick = Proc.new {|button, state, x, y| if state == 0 $basisPt = transformPoint(x,y) $down = true else $down = false end } $mouseMove = Proc.new {|x , y| if $down $basisPt = transformPoint(x,y) end } $keyboard = Proc.new {|key, x, y| case (key) when 'x'[0], 'X'[0] $colorVal = rand setColor($usedPath.doPathPoint($colorVal)) when 'c'[0], 'C'[0] $clear = true when 's'[0], 'S'[0] cycleColors when 'w'[0], 'W'[0] randomColors when '='[0], '+'[0] when '-'[0], '_'[0] when 't'[0], 'T'[0] updateAngle($angle + $angleDelta) when 'r'[0], 'R'[0] updateAngle($angle - $angleDelta) when 'f'[0], 'F'[0] $length = subMin($length, $lengthDelta, $lengthDelta) when 'g'[0], 'G'[0] $length += $lengthDelta when 'v'[0], 'V'[0] $dispersion = subMin($dispersion, $dispersionDelta, $dispersionDelta) when 'b'[0], 'B'[0] $dispersion += $dispersionDelta when 'a'[0], 'A'[0] updateAngle(randomAngleRadians()) when 'y'[0], 'Y'[0] $colorVal = subMin($colorVal, $colorDelta, 0.0) setColor($usedPath.doPathPoint($colorVal)) when 'u'[0], 'U'[0] $colorVal = addMax($colorVal, $colorDelta, 1.0) setColor($usedPath.doPathPoint($colorVal)) when 'h'[0], 'H'[0] $skip += $skipDelta when 'j'[0], 'J'[0] $skip = subMin($skip, $skipDelta, 0) when 27 #/* Escape Key */ exit(0); end } GLUT.KeyboardFunc($keyboard) GLUT.MouseFunc($mouseClick) GLUT.MotionFunc($mouseMove) GLUT.DisplayFunc($display) if $animate GLUT.IdleFunc($display) end GLUT.MainLoop