Changeset 186 for trunk/samples/rect.rb

Show
Ignore:
Timestamp:
09/21/2007 02:44:26 (11 months ago)
Author:
why
Message:

* shoes/world.c: introduced the new shoes_world_t struct so I can start to implement multiple windows soon.
* shoes/app.c: the shoes_app struct is now wrapped by the App class.
* shoes/ruby.c: heavy reorganization of how blocks are called. prevalent use of instance_eval has been abandoned in favor of evaluation at the app-level and tracking of canvas nesting. i just think instance_eval was too confusing for beginners, I'm much happier with this. In this way, instance variables can be used to store elements rather than plain variables.
* samples/: use of instance variables to store controls and changes to reflect the new scoping. this revision breaks a lot of old code and doesn't yet compile on osx and win32.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/samples/rect.rb

    r123 r186  
    1 rectangles = proc do 
    2   20.times do 
    3     nostroke 
    4     fill rgb((0.6..1.0).rand, (0.1..1.0).rand, (0.2..1.0).rand, (0.4..1.0).rand) 
    5     r = rand(300) + 60 
    6     rect :left => (10..100).rand, :top => (10..200).rand, :width => r, :height => r 
     1Shoes.app :width => 400, :height => 500 do 
     2  rectangles = proc do 
     3    20.times do 
     4      nostroke 
     5      fill rgb((0.6..1.0).rand, (0.1..1.0).rand, (0.2..1.0).rand, (0.4..1.0).rand) 
     6      r = rand(300) + 60 
     7      rect :left => (10..100).rand, :top => (10..200).rand, :width => r, :height => r 
     8    end 
     9    button "OK", :left => 300, :top => 400 do 
     10      clear &rectangles 
     11    end 
    712  end 
    8   button "OK", :left => 300, :top => 400 do 
    9     clear &rectangles 
    10   end 
     13 
     14  rectangles[] 
    1115end 
    12  
    13 Shoes.app :width => 400, :height => 500, &rectangles