[macruby-changes] [1890] MacRuby/branches/experimental/sample-macruby/HotCocoa

source_changes at macosforge.org source_changes at macosforge.org
Fri Jun 19 15:43:08 PDT 2009


Revision: 1890
          http://trac.macosforge.org/projects/ruby/changeset/1890
Author:   lsansonetti at apple.com
Date:     2009-06-19 15:43:08 -0700 (Fri, 19 Jun 2009)
Log Message:
-----------
merged HotCocoa samples from trunk

Modified Paths:
--------------
    MacRuby/branches/experimental/sample-macruby/HotCocoa/README
    MacRuby/branches/experimental/sample-macruby/HotCocoa/demo/lib/application.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/demo/lib/views/movie_view.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/demo/lib/views/web_view.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/iterate.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/particle.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/randomize.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/application.rb

Added Paths:
-----------
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/Rakefile
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/config/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/config/build.yml
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/application.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/menu.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/resources/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/resources/HotCocoa.icns
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/README
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-blendmodes.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-colors.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-effects.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-moving.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/rope-hair.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/rope-ribbon.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/spirograph.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/Rakefile
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/config/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/config/build.yml
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/application.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/controllers/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/menu.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/mvc.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/views/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/resources/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/resources/HotCocoa.icns
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/resources/HotCocoa.icns
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/resources/MainMenu.nib/keyedobjects.nib
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/resources/circle.tif
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/resources/pentagram.tif
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/Rakefile
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/config/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/config/build.yml
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/application.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_view_behaviors.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_window_behaviors.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/menu.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/HotCocoa.icns
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/circle.tif
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/pentagram.tif

Removed Paths:
-------------
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/Rakefile
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/config/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/config/build.yml
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/application.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/menu.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/resources/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/resources/HotCocoa.icns
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/color.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/drawing.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/hotcocoa.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/pdf.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/rope.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/text.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/Rakefile
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/config/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/config/build.yml
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/application.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/controllers/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/menu.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/mvc.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/views/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/resources/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/resources/HotCocoa.icns
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/Rakefile
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/config/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/config/build.yml
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/application.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_view_behaviors.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_window_behaviors.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/menu.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/HotCocoa.icns
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/circle.tif
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/pentagram.tif

Property Changed:
----------------
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/iterate.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/particle.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/randomize.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/Rakefile
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/config/build.yml
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/application.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/custom_view.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/custom_window.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/menu.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/nib_controller.rb
    MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/resources/MainMenu.nib/designable.nib

Modified: MacRuby/branches/experimental/sample-macruby/HotCocoa/README
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/README	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/README	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,3 +1,5 @@
+== HotCocoa Examples ==
+
 This directory contains a few demos of using the HotCocoa library.
 
 To learn more about HotCocoa see:
@@ -24,22 +26,29 @@
 After generating the structure, cd into that directory and run 
 macrake to build.
 
-Demos:
+== Examples ==
 
-calculator    #=> simple calculator example
-demo          #=> demo of many hotcocoa wrappers
-layout_view   #=> demo of using the layout view system
+calculator: a simple calculator example.
 
-Building the demos:
+demo: demo of many hotcocoa wrappers.
 
-Calculator:
-$ cd calculator
-$ macrake
+layout_view: demo of using the layout view system.
 
-Demo:
-$ cd demo
+round_transparent_window: port of an Apple sample showing how to use hotcocoa 
+with a nib files.
+
+round_transparent_window_no_nibs: same as round_transparent_window but without
+using any nibs.
+
+download_and_progress_indicator: demo of downloading data, progress indicator
+and scroll view containing a text view.
+
+Building the examples:
+
+$ cd <example-directory>
 $ macrake
 
-Layout View:
-$ cd layout_view
-$ macrake
+== HotCocoa::Graphics Examples ==
+
+$ cd graphics
+$ open -a textedit README

Modified: MacRuby/branches/experimental/sample-macruby/HotCocoa/demo/lib/application.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/demo/lib/application.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/demo/lib/application.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,5 +1,8 @@
 require 'hotcocoa'
 
+framework 'WebKit'
+framework 'QTKit'
+
 include HotCocoa
 
 # Replace the following code with your own hotcocoa code

Modified: MacRuby/branches/experimental/sample-macruby/HotCocoa/demo/lib/views/movie_view.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/demo/lib/views/movie_view.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/demo/lib/views/movie_view.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,7 +1,5 @@
-framework 'qtkit'
+class MovieViewDemo
 
-class MovieView
-
   def self.description 
     "Movies" 
   end

Modified: MacRuby/branches/experimental/sample-macruby/HotCocoa/demo/lib/views/web_view.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/demo/lib/views/web_view.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/demo/lib/views/web_view.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,7 +1,5 @@
-framework 'webkit'
+class WebViewDemo
 
-class WebView
-
   def self.description 
     "Web Views" 
   end

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/Rakefile
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/download_and_progress_indicator/Rakefile	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/Rakefile	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,4 +0,0 @@
-require 'hotcocoa/application_builder'
-require 'hotcocoa/standard_rake_tasks'
-
-task :default => [:run]
\ No newline at end of file

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/Rakefile (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/download_and_progress_indicator/Rakefile)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/Rakefile	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/Rakefile	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,4 @@
+require 'hotcocoa/application_builder'
+require 'hotcocoa/standard_rake_tasks'
+
+task :default => [:run]
\ No newline at end of file

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/config/build.yml
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/download_and_progress_indicator/config/build.yml	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/config/build.yml	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,8 +0,0 @@
-name: Download And progress bar
-load: lib/application.rb
-version: "1.0"
-icon: resources/HotCocoa.icns
-resources:
-  - resources/**/*.*
-sources: 
-  - lib/**/*.rb

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/config/build.yml (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/download_and_progress_indicator/config/build.yml)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/config/build.yml	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/config/build.yml	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,8 @@
+name: Download And progress bar
+load: lib/application.rb
+version: "1.0"
+icon: resources/HotCocoa.icns
+resources:
+  - resources/**/*.*
+sources: 
+  - lib/**/*.rb

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/application.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/download_and_progress_indicator/lib/application.rb	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/application.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,109 +0,0 @@
-require 'hotcocoa'
-include HotCocoa
-
-TEXT_FILE = "http://www.gutenberg.org/files/4300/4300.txt"
-
-class Application
-
-  def start
-    @app = application(:name   => "Download And Progress Bar") do |app|
-      app.delegate = self
-      @window = window(:frame     => [100, 100, 500, 500], :title => "Download And Progress Bar") do |win|
-        win <<  label(:text => "Cocoa made easy! Example by Matt Aimonetti", :layout => {:start => false})
-        @status = label(:text => "downloading remote data", :layout => {:start => false}, :frame => [0, 0, 300, 20])
-        win <<  @status
-        win << @progress_bar = progress_indicator
-        
-        # Setup a scroll view containing a text view which will display the downloaded data
-        @scroll_view = scroll_view(:frame => [0,0,495,300], :layout => {:expand => [:height, :width]})
-        @text_view = text_view(:frame => [0,0,490,300])
-        @scroll_view.documentView = @text_view
-        
-        win << @scroll_view 
-        
-        @reload_button = button(:title => "Reload the data", :on_action => reload_data)
-        @reload_button.hidden = true
-        
-        win << @reload_button
-        
-        initiate_request(TEXT_FILE, self)  
-        win.will_close { exit }
-      end
-    end
-  end
-  
-  # Returns a proc that is being called by the reload button
-  def reload_data
-    Proc.new { 
-      # Change the progress bar_style
-      @progress_bar.style = :spinning
-      initiate_request(TEXT_FILE, self)
-      @reload_button.hidden = true 
-      @text_view.string = " Reloading..."
-      @status.text  = 're downloading the text file'
-    }
-  end
-  
-  # Request helper setting up a connection and a delegate
-  # used to monitor the transfer
-  def initiate_request(url_string, delegator)
-    url         = NSURL.URLWithString(url_string)
-    request     = NSURLRequest.requestWithURL(url)
-    @connection = NSURLConnection.connectionWithRequest(request, delegate:delegator)
-  end
-  
-  # Delegate method
-  #
-  # The transfer is done and everything went well
-  def connectionDidFinishLoading(connection)
-    @status.text  = "Data totally retrieved"
-    @progress_bar.hide
-    @progress_bar.reset
-    page          = NSString.alloc.initWithData(@receivedData, encoding:NSUTF8StringEncoding)
-    @receivedData = nil
-    begin 
-      @text_view.string = page
-    rescue
-      @status.text = "couldn't display the loaded text"
-    end
-    NSLog("data fully received")
-    @reload_button.hidden = false
-  end
-  
-  # Delegate method
-  #
-  # Deal with the request response 
-  # Note: in Ruby, the method name is the method signature
-  # Objective C uses what's called a selector
-  # The objc selector for the method below would be:
-  #   `connection:didReceiveResponse:`
-  def connection(connection, didReceiveResponse:response)
-    @status.text = (response.statusCode == 200) ? "Retrieving data" : "There was an issue while trying to access the data"
-    expected_size = response.expectedContentLength.to_f
-    # If we know the size of the document we are downloading
-    # we can determine the progress made so far
-    if expected_size > 0
-      @progress_bar.indeterminate = false
-      @progress_bar.maxValue = expected_size.to_f
-    end
-    @progress_bar.show
-    @progress_bar.start
-    NSLog("extected response length: #{response.expectedContentLength.to_s}")
-  end
-  
-  # Delegate method
-  #
-  # This delegate method get called every time a chunk of data
-  # is being received
-  def connection(connection, didReceiveData:receivedData)
-    @status.text  = "Data being retrieved"
-    # Initiate an ivar to store the received data
-    @receivedData ||= NSMutableData.new
-    @receivedData.appendData(receivedData)
-    @progress_bar.incrementBy(receivedData.length.to_f)
-    NSLog("data chunck received so far: #{@progress_bar.value.to_i}")
-  end
-  
-end
-
-Application.new.start
\ No newline at end of file

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/application.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/download_and_progress_indicator/lib/application.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/application.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/application.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,109 @@
+require 'hotcocoa'
+include HotCocoa
+
+TEXT_FILE = "http://www.gutenberg.org/files/4300/4300.txt"
+
+class Application
+
+  def start
+    @app = application(:name   => "Download And Progress Bar") do |app|
+      app.delegate = self
+      @window = window(:frame     => [100, 100, 500, 500], :title => "Download And Progress Bar") do |win|
+        win <<  label(:text => "Cocoa made easy! Example by Matt Aimonetti", :layout => {:start => false})
+        @status = label(:text => "downloading remote data", :layout => {:start => false}, :frame => [0, 0, 300, 20])
+        win <<  @status
+        win << @progress_bar = progress_indicator
+        
+        # Setup a scroll view containing a text view which will display the downloaded data
+        @scroll_view = scroll_view(:frame => [0,0,495,300], :layout => {:expand => [:height, :width]})
+        @text_view = text_view(:frame => [0,0,490,300])
+        @scroll_view.documentView = @text_view
+        
+        win << @scroll_view 
+        
+        @reload_button = button(:title => "Reload the data", :on_action => reload_data)
+        @reload_button.hidden = true
+        
+        win << @reload_button
+        
+        initiate_request(TEXT_FILE, self)  
+        win.will_close { exit }
+      end
+    end
+  end
+  
+  # Returns a proc that is being called by the reload button
+  def reload_data
+    Proc.new { 
+      # Change the progress bar_style
+      @progress_bar.style = :spinning
+      initiate_request(TEXT_FILE, self)
+      @reload_button.hidden = true 
+      @text_view.string = " Reloading..."
+      @status.text  = 're downloading the text file'
+    }
+  end
+  
+  # Request helper setting up a connection and a delegate
+  # used to monitor the transfer
+  def initiate_request(url_string, delegator)
+    url         = NSURL.URLWithString(url_string)
+    request     = NSURLRequest.requestWithURL(url)
+    @connection = NSURLConnection.connectionWithRequest(request, delegate:delegator)
+  end
+  
+  # Delegate method
+  #
+  # The transfer is done and everything went well
+  def connectionDidFinishLoading(connection)
+    @status.text  = "Data totally retrieved"
+    @progress_bar.hide
+    @progress_bar.reset
+    page          = NSString.alloc.initWithData(@receivedData, encoding:NSUTF8StringEncoding)
+    @receivedData = nil
+    begin 
+      @text_view.string = page
+    rescue
+      @status.text = "couldn't display the loaded text"
+    end
+    NSLog("data fully received")
+    @reload_button.hidden = false
+  end
+  
+  # Delegate method
+  #
+  # Deal with the request response 
+  # Note: in Ruby, the method name is the method signature
+  # Objective C uses what's called a selector
+  # The objc selector for the method below would be:
+  #   `connection:didReceiveResponse:`
+  def connection(connection, didReceiveResponse:response)
+    @status.text = (response.statusCode == 200) ? "Retrieving data" : "There was an issue while trying to access the data"
+    expected_size = response.expectedContentLength.to_f
+    # If we know the size of the document we are downloading
+    # we can determine the progress made so far
+    if expected_size > 0
+      @progress_bar.indeterminate = false
+      @progress_bar.maxValue = expected_size.to_f
+    end
+    @progress_bar.show
+    @progress_bar.start
+    NSLog("extected response length: #{response.expectedContentLength.to_s}")
+  end
+  
+  # Delegate method
+  #
+  # This delegate method get called every time a chunk of data
+  # is being received
+  def connection(connection, didReceiveData:receivedData)
+    @status.text  = "Data being retrieved"
+    # Initiate an ivar to store the received data
+    @receivedData ||= NSMutableData.new
+    @receivedData.appendData(receivedData)
+    @progress_bar.incrementBy(receivedData.length.to_f)
+    NSLog("data chunck received so far: #{@progress_bar.value.to_i}")
+  end
+  
+end
+
+Application.new.start
\ No newline at end of file

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/menu.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/download_and_progress_indicator/lib/menu.rb	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/menu.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,32 +0,0 @@
-module HotCocoa
-  def application_menu
-    menu do |main|
-      main.submenu :apple do |apple|
-        apple.item :about, :title => "About #{NSApp.name}"
-        apple.separator
-        apple.item :preferences, :key => ","
-        apple.separator
-        apple.submenu :services
-        apple.separator
-        apple.item :hide, :title => "Hide #{NSApp.name}", :key => "h"
-        apple.item :hide_others, :title => "Hide Others", :key => "h", :modifiers => [:command, :alt]
-        apple.item :show_all, :title => "Show All"
-        apple.separator
-        apple.item :quit, :title => "Quit #{NSApp.name}", :key => "q"
-      end
-      main.submenu :file do |file|
-        file.item :new, :key => "n"
-        file.item :open, :key => "o"
-      end
-      main.submenu :window do |win|
-        win.item :minimize, :key => "m"
-        win.item :zoom
-        win.separator
-        win.item :bring_all_to_front, :title => "Bring All to Front", :key => "o"
-      end
-      main.submenu :help do |help|
-        help.item :help, :title => "#{NSApp.name} Help"
-      end
-    end
-  end
-end

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/menu.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/download_and_progress_indicator/lib/menu.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/menu.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/lib/menu.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,32 @@
+module HotCocoa
+  def application_menu
+    menu do |main|
+      main.submenu :apple do |apple|
+        apple.item :about, :title => "About #{NSApp.name}"
+        apple.separator
+        apple.item :preferences, :key => ","
+        apple.separator
+        apple.submenu :services
+        apple.separator
+        apple.item :hide, :title => "Hide #{NSApp.name}", :key => "h"
+        apple.item :hide_others, :title => "Hide Others", :key => "h", :modifiers => [:command, :alt]
+        apple.item :show_all, :title => "Show All"
+        apple.separator
+        apple.item :quit, :title => "Quit #{NSApp.name}", :key => "q"
+      end
+      main.submenu :file do |file|
+        file.item :new, :key => "n"
+        file.item :open, :key => "o"
+      end
+      main.submenu :window do |win|
+        win.item :minimize, :key => "m"
+        win.item :zoom
+        win.separator
+        win.item :bring_all_to_front, :title => "Bring All to Front", :key => "o"
+      end
+      main.submenu :help do |help|
+        help.item :help, :title => "#{NSApp.name} Help"
+      end
+    end
+  end
+end

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/resources/HotCocoa.icns
===================================================================
(Binary files differ)

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/download_and_progress_indicator/resources/HotCocoa.icns (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/download_and_progress_indicator/resources/HotCocoa.icns)
===================================================================
(Binary files differ)

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/README (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/graphics/README)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/README	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/README	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,17 @@
+=== HotCocoa::Graphics Examples ===
+
+You will find in this directory several examples that illustrate the 
+graphics layer of HotCocoa.
+
+You can run them from the command line using macruby. 
+
+  $ macruby particle.rb
+
+You should then see an image opening in your default image viewer.
+
+These examples are drawing into PNG images, but it is possible to draw on
+any CoreGraphics context, for example within an NSView's drawRect: method.
+
+== TODO ==
+
+Write a demo HotCocoa app that embeds all the samples and draw in an NSView.

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/color.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/color.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/color.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,124 +0,0 @@
-#!/usr/bin/env macruby
-
-require 'hotcocoa/graphics'
-require 'test/unit'
-include HotCocoa::Graphics
-
-
-PRECISION = 0.0000001
-
-class TestHSB < Test::Unit::TestCase
-  
-  def test_hsba
-    
-    # new named color
-    c = Color.blue
-    assert_in_delta(c.hue, 0.6666666, PRECISION)
-    assert_in_delta(c.saturation,1.0, PRECISION)
-    assert_in_delta(c.brightness,1.0, PRECISION)
-    assert_in_delta(c.a,1.0, PRECISION)
-    
-    # new HSBA color
-    c = Color.hsb(0.5,0.4,0.3,0.2)
-    assert_in_delta(c.hue, 0.5, PRECISION)
-    assert_in_delta(c.saturation, 0.4, PRECISION)
-    assert_in_delta(c.brightness, 0.3, PRECISION)
-    assert_in_delta(c.a, 0.2, PRECISION)
-    
-    # new RGBA color
-    c = Color.new(0.5,0.4,0.3,1.0)
-    assert_in_delta(c.hue, 0.08333333, PRECISION)
-    assert_in_delta(c.saturation, 0.3999999, PRECISION)
-    assert_in_delta(c.brightness, 0.5, PRECISION)
-    assert_in_delta(c.a, 1.0, PRECISION)
-    
-    # darken
-    c = Color.blue
-    c.darken(0.1)
-    assert_in_delta(c.hue, 0.6666666, PRECISION)
-    assert_in_delta(c.saturation,1.0, PRECISION)
-    assert_in_delta(c.brightness, 0.8999999, PRECISION)
-    assert_in_delta(c.a,1.0, PRECISION)
-    
-    # lighten
-    c = Color.new(0.5,0.4,0.3,1.0)
-    c.lighten(0.1)
-    assert_in_delta(c.hue, 0.08333333, PRECISION)
-    assert_in_delta(c.saturation, 0.4, PRECISION)
-    assert_in_delta(c.brightness, 0.6, PRECISION)
-    assert_in_delta(c.a, 1.0, PRECISION)
-  
-    # saturate
-    c = Color.new(0.5,0.4,0.3,1.0)
-    c.saturate(0.1)
-    assert_in_delta(c.hue, 0.08333333, PRECISION)
-    assert_in_delta(c.saturation, 0.5, PRECISION)
-    assert_in_delta(c.brightness, 0.5, PRECISION)
-    assert_in_delta(c.a, 1.0, PRECISION)
-    
-    # desaturate
-    c = Color.new(0.5,0.4,0.3,1.0)
-    c.desaturate(0.1)
-    assert_in_delta(c.hue, 0.08333333, PRECISION)
-    assert_in_delta(c.saturation, 0.2999999, PRECISION)
-    assert_in_delta(c.brightness, 0.5, PRECISION)
-    assert_in_delta(c.a, 1.0, PRECISION)
-    
-    # set HSB
-    c.set_hsb(0.5,0.4,0.3,0.2)
-    assert_in_delta(c.hue, 0.5, PRECISION)
-    assert_in_delta(c.saturation, 0.4, PRECISION)
-    assert_in_delta(c.brightness, 0.3, PRECISION)
-    assert_in_delta(c.a, 0.2, PRECISION)
-    
-    # get HSB
-    h,s,b,a = c.get_hsb
-    assert_in_delta(h, 0.5, PRECISION)
-    assert_in_delta(s, 0.4, PRECISION)
-    assert_in_delta(b, 0.3, PRECISION)
-    assert_in_delta(a, 0.2, PRECISION)
-    
-    # adjust HSB
-    c.adjust_hsb(0.1,0.1,0.1,0.1)
-    assert_in_delta(c.hue, 0.6, PRECISION)
-    assert_in_delta(c.saturation, 0.5, PRECISION)
-    assert_in_delta(c.brightness, 0.4, PRECISION)
-    assert_in_delta(c.a, 0.3, PRECISION)
-    
-  end
-  
-  def test_rgba
-    
-    # new named color
-    c = Color.blue
-    assert_in_delta(c.r, 0.0, PRECISION)
-    assert_in_delta(c.g, 0.0, PRECISION)
-    assert_in_delta(c.b, 1.0, PRECISION)
-    assert_in_delta(c.a, 1.0, PRECISION)
-    
-    # new RGBA color
-    c = Color.new(0.5,0.4,0.3,0.2)
-    assert_in_delta(c.r, 0.5, PRECISION)
-    assert_in_delta(c.g, 0.4, PRECISION)
-    assert_in_delta(c.b, 0.3, PRECISION)
-    assert_in_delta(c.a, 0.2, PRECISION)
-
-    # new RGBA color
-    c = Color.rgb(0.5,0.4,0.3,0.2)
-    assert_in_delta(c.r, 0.5, PRECISION)
-    assert_in_delta(c.g, 0.4, PRECISION)
-    assert_in_delta(c.b, 0.3, PRECISION)
-    assert_in_delta(c.a, 0.2, PRECISION)
-
-    # adjust RGBA
-    c.adjust_rgb(0.1,0.1,0.1,0.1)
-    assert_in_delta(c.r, 0.6, PRECISION)
-    assert_in_delta(c.g, 0.5, PRECISION)
-    assert_in_delta(c.b, 0.4, PRECISION)
-    assert_in_delta(c.a, 0.3, PRECISION)
-
-    
-  end
-  
-  
-end
\ No newline at end of file

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/drawing.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/drawing.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/drawing.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,135 +0,0 @@
-#!/usr/bin/env macruby
-
-require 'hotcocoa/graphics'
-require 'test/unit'
-include HotCocoa::Graphics
-
-class TestDrawing < Test::Unit::TestCase
-  
-  def test_save_png
-    c = Canvas.for_image(:size => [400,400], :filename =>'images/test-png.png') do
-      background(Color.white)
-      fill(Color.black)
-      text("Hello PNG!",150,200)
-    end
-    assert(true, c.save)
-    #c.open
-  end
-  
-  def test_save_pdf
-    c = Canvas.for_image(:size => [400,400], :filename =>'images/test-pdf.pdf')
-    c.background(Color.white)
-    c.fill(Color.black)
-    c.text("Hello PDF!",150,200)
-    assert(true, c.save)
-   # c.open
-  end
-  
-  def test_drawing
-    # specify canvas dimensions and output file (pdf, png, tif, gif)
-    File.delete('images/test-drawing.png') if File.exists?('images/test-drawing.png')
-    c = Canvas.for_image(:size => [400,400], :filename =>'images/test-drawing.png') do
-      # set the background fill color
-      background(Color.white)
-      # draw a reference grid
-      cartesian
-
-      # SET CANVAS OPTIONS
-      #translate(200,200)     # set initial drawing point
-      #antialias(false)       # turn off antialiasing for some crazy reason
-      #alpha(0.5)             # set transparency for drawing operations
-      #fill(Color.blue.dark)  # set the fill color
-      #nofill                 # disable fill
-
-      # SET CANVAS LINE STYLE
-      nofill
-      stroke(Color.black)
-      strokewidth(5)
-      linecap(:round)         # render line endings as :round, :butt, or :square 
-      linejoin(:round)        # render line joins as :round, :bevel (flat), or :miter (pointy)
-
-      # DRAW LINES ON CANVAS
-      arc(200,200,50,-45,180)           # an arc of a circle with center x,y with radius, start angle, end angle
-      line(0,0,200,200)                 # a line with start X, start Y, end X, end Y
-      lines([[400,400],[300,400],[200,300],[400,300],[400,400]])  # array of points
-      qcurve(200,200,0,0,400,0)         # a quadratic bezier curve with control point cpx,cpy and endpoints x1,y1,x2,y2
-      curve(200,200,200,400,0,0,0,400)  # a bezier curve with control points cp1x,cp1y,cp2x,cp2y and endpoints x1,y1,x2,y2
-
-      # CONSTRUCT COMPLEX PATHS DIRECTLY ON CANVAS
-      fill(Color.red)                   # set the fill color for the new path
-      autoclosepath(true)               # automatically close the path when calling `endpath`
-      new_path 50, 300 do
-        curveto(150,250,150,200,50,200)
-        lineto(0,250)
-        #moveto(25,250)
-        qcurveto(25,300,50,250)
-        arcto(50,225,100,225,20)
-      end
-
-      # CONSTRUCT A REUSABLE PATH OBJECT
-      p = Path.new
-      p.scale(0.75)
-      p.translate(350,0)
-      p.moveto(50,300)
-      p.curveto(150,250,150,200,50,200)
-      p.lineto(0,250)
-      p.qcurveto(25,300,50,250)
-      #p.moveto(25,250)
-      p.arcto(50,225,100,225,20)
-      p.endpath
-      p.contains(100,250)   # doesn't work?
-      strokewidth(1)
-      fill(Color.orange.darken)
-      draw(p)     # draw it to the canvas
-
-      # CONSTRUCT A PATH WITH SHAPES
-      p2 = Path.new
-      p2.rect(0,0,50,50)
-      p2.oval(-50,-50,50,50)
-      fill(Color.blue)
-      draw(p2,50,100)           # draw the path at x,y (or current point)
-      draw(p2,150,100)          # draw the path at x,y (or current point)
-
-      # GET PATH INFO
-      puts "path bounding box at [#{p.x},#{p.y}] with dimensions #{p.width}x#{p.height}, current point is #{p.currentpoint}"
-
-      # DRAW TEXT
-      # save the previous drawing state (font, colors, position, etc)
-      new_state do
-        font('Times-Bold')
-        fontsize(20)
-        translate(150,350)
-        text("bzzzzt",0,10)
-        # restore the previous drawing state
-      end
-
-      # DRAW GRADIENTS, CLIPPING PATHS
-      new_state do                        # save the previous state
-        translate(300,300)          # move to a new drawing location
-
-        # create gradient
-        g = Gradient.new([Color.yellow,Color.violet.darken.a(0.5),Color.orange])  # create a gradient
-
-        # linear:
-        m = Path.new                  # create a new path to use for clipping
-        m.oval(-50,-50,100,100)       # draw a circle in the path
-        beginclip(m) do                # tell the canvas to use the clipping path
-          gradient(g,0,-50,0,50)      # draw a linear gradient between the two points
-        end                           # tell the canvas to stop using the clipping path
-
-        # radial:
-        translate(0,-200)           # move down a bit
-        beginclip(m) do              # begin clipping again
-          radial(g,0,0,50)          # draw radial gradient starting at x,y using radius
-        end                         # end clipping
-      end                           # restore the previous state
-    end
-    
-
-    # SAVE THE CANVAS TO OUTPUT FILE
-    assert(true,c.save)
-    #assert_equal('', `diff images/test-drawing.png images/fixture-drawing.png`)
-    #c.open
-  end
-  
-end
\ No newline at end of file

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/hotcocoa.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/hotcocoa.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/hotcocoa.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,10 +0,0 @@
-#!/usr/bin/env macruby
-
-require 'hotcocoa'
-include HotCocoa
-
- at table = table_view(
-  :columns => [ 
-    column(:id => :klass, :text => "Class"),
-    column(:id => :ancestors, :text => "Ancestors") 
-  ]  )
\ No newline at end of file

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-blendmodes.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/graphics/image-blendmodes.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-blendmodes.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-blendmodes.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,39 @@
+require 'hotcocoa/graphics'
+include HotCocoa
+include Graphics
+
+OUTFILE = 'image-blendmodes.png'
+
+canvas = Canvas.for_image(:size => [400,730], :filename => OUTFILE)
+canvas.background(Color.white)
+canvas.font('Skia')
+canvas.fontsize(14)
+
+# set image width,height
+w,h = [95,95]
+
+# set initial drawing position
+x,y = [0,canvas.height - h - 10]
+
+# load and resize two images
+imgA = Image.new('images/v2.jpg').resize(w,h)
+imgB = Image.new('images/italy.jpg').resize(w,h)
+
+# add image B to image A using each blending mode, and draw to canvas
+[:normal,:multiply,:screen,:overlay,:darken,:lighten,
+  :colordodge,:colorburn,:softlight,:hardlight,:difference,:exclusion,
+  :hue,:saturation,:color,:luminosity,:maximum,:minimum,:add,:atop,
+  :in,:out,:over].each do |blendmode|
+  imgA.reset.resize(w,h)
+  imgA.blend(imgB, blendmode)
+  canvas.draw(imgA,x,y)
+  canvas.text(blendmode,x,y-15)
+  x += w + 5
+  if (x > canvas.width - w + 5)
+    x = 0
+    y -= h + 25
+  end
+end
+canvas.save
+
+`open #{OUTFILE}`

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-colors.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/graphics/image-colors.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-colors.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-colors.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,106 @@
+require 'hotcocoa/graphics'
+include HotCocoa
+include Graphics
+
+OUTFILE = 'image-colors.png'
+
+# set up the canvas
+canvas = Canvas.for_image(:size => [400,400], :filename => OUTFILE)
+canvas.background(Color.white)
+canvas.font('Skia')
+canvas.fontsize(14)
+canvas.fill(Color.black)
+
+# LOAD IMAGE
+img = Image.new('images/v2.jpg')
+
+w,h = [100,100]
+x,y = [0,290]
+xoffset = 105
+yoffset = 130
+
+# ORIGINAL image, resized to fit within w,h:
+img.fit(w,h)
+canvas.draw(img,x,y)
+canvas.text("original",x,y-15)
+x += xoffset
+
+# HUE: rotate color wheel by degrees
+img.reset.fit(w,h)
+img.hue(45)
+canvas.draw(img,x,y)
+canvas.text("hue",x,y-15)
+x += xoffset
+
+# EXPOSURE: increase/decrease exposure by f-stops
+img.reset.fit(w,h)
+img.exposure(1.0)
+canvas.draw(img,x,y)
+canvas.text("exposure",x,y-15)
+x += xoffset
+
+# SATURATION: adjust saturation by multiplier
+img.reset.fit(w,h)
+img.saturation(2.0)
+canvas.draw(img,x,y)
+canvas.text("saturation",x,y-15)
+x += xoffset
+
+# (go to next row)
+x = 0
+y -= yoffset
+
+# CONTRAST: adjust contrast by multiplier
+img.reset.fit(w,h)
+img.contrast(2.0)
+canvas.draw(img,x,y)
+canvas.text("contrast",x,y-15)
+x += xoffset
+
+# BRIGHTNESS: adjust brightness
+img.reset.fit(w,h)
+img.brightness(0.5)
+canvas.draw(img,x,y)
+canvas.text("brightness",x,y-15)
+x += xoffset
+
+# MONOCHROME: convert to a monochrome image
+img.reset.fit(w,h)
+img.monochrome(Color.orange)
+canvas.draw(img,x,y)
+canvas.text("monochrome",x,y-15)
+x += xoffset
+
+# WHITEPOINT: remap the white point
+img.reset.fit(w,h)
+img.whitepoint(Color.whiteish)
+canvas.draw(img,x,y)
+canvas.text("white point",x,y-15)
+x += xoffset
+
+# (go to next row)
+x = 0
+y -= yoffset
+
+# CHAINING: apply multiple effects at once
+img.reset.fit(w,h)
+img.hue(60).saturation(2.0).contrast(2.5)
+canvas.draw(img,x,y)
+canvas.text("multi effects",x,y-15)
+x += xoffset
+
+# COLORS: sample random colors from the image and render as a gradient
+img.reset.fit(w,h)              # reset the image and scale to fit within w,h
+colors = img.colors(10).sort!   # select 10 random colors and sort by brightness
+# gradient
+gradient = Gradient.new(colors) # create a new gradient using the selected colors
+rect = Path.new.rect(x,y,img.width,img.height) # create a rectangle the size of the image
+canvas.beginclip(rect)          # begin clipping so the gradient will only fill the rectangle
+canvas.gradient(gradient,x,y,x+img.width,y+img.height) # draw the gradient between opposite corners of the rectangle
+canvas.endclip                  # end clipping so we can draw on the rest of the canvas
+canvas.text("get colors",x,y-15)    # add text label
+x += xoffset
+
+canvas.save
+
+`open #{OUTFILE}`

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-effects.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/graphics/image-effects.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-effects.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-effects.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,119 @@
+require 'hotcocoa/graphics'
+include HotCocoa
+include Graphics
+
+OUTFILE = 'image-effects.png'
+
+# set up the canvas
+canvas = Canvas.for_image(:size => [400,400], :filename => OUTFILE)
+canvas.background(Color.white)
+canvas.font('Skia')
+canvas.fontsize(14)
+canvas.fill(Color.black)
+
+# load image file
+img = Image.new('images/v2.jpg')
+
+# set image width/height, starting position, and increment position
+w,h = [100,100]
+x,y = [0,290]
+xoffset = 105
+yoffset = 130
+
+# ORIGINAL image, resized to fit within w,h:
+img.fit(w,h)
+canvas.draw(img,x,y)
+canvas.text("original",x,y-15)
+x += xoffset
+
+# CRYSTALLIZE: apply a "crystallize" effect with the given radius
+img.reset.fit(w,h)
+img.crystallize(5.0)
+canvas.draw(img,x,y)
+canvas.text("crystallize",x,y-15)
+x += xoffset
+
+# BLOOM: apply a "bloom" effect with the given radius and intensity
+img.reset.fit(w,h)
+img.bloom(10, 1.0)
+canvas.draw(img,x,y)
+canvas.text("bloom",x,y-15)
+x += xoffset
+
+# EDGES: detect edges
+img.reset.fit(w,h)
+img.edges(10)
+canvas.draw(img,x,y)
+canvas.text("edges",x,y-15)
+x += xoffset
+
+# (go to next row)
+x = 0
+y -= yoffset
+
+# POSTERIZE: reduce image to the specified number of colors
+img.reset.fit(w,h)
+img.posterize(8)
+canvas.draw(img,x,y)
+canvas.text("posterize",x,y-15)
+x += xoffset
+
+# TWIRL: rotate around x,y with radius and angle
+img.reset.fit(w,h)
+img.twirl(35,50,40,90)
+canvas.draw(img,x,y)
+canvas.text("twirl",x,y-15)
+x += xoffset
+
+# EDGEWORK: simulate a woodcut print
+img.reset.fit(w,h)
+canvas.rect(x,y,img.width,img.height) # needs a black background
+img.edgework(0.5)
+canvas.draw(img,x,y)
+canvas.text("edgework",x,y-15)
+x += xoffset
+
+# DISPLACEMENT: use a second image as a displacement map
+img.reset.fit(w,h)
+img2 = Image.new('images/italy.jpg').resize(img.width,img.height)
+img.displacement(img2, 30.0)
+canvas.draw(img,x,y)
+canvas.text("displacement",x,y-15)
+x += xoffset
+
+# (go to next row)
+x = 0
+y -= yoffset
+
+# DOTSCREEN: simulate a dot screen: center point, angle(0-360), width(1-50), and sharpness(0-1)
+img.reset.fit(w,h)
+img.dotscreen(0,0,45,5,0.7)
+canvas.draw(img,x,y)
+canvas.text("dotscreen",x,y-15)
+x += xoffset
+
+# SHARPEN: sharpen using the given radius and intensity
+img.reset.fit(w,h)
+img.sharpen(2.0,2.0)
+canvas.draw(img,x,y)
+canvas.text("sharpen",x,y-15)
+x += xoffset
+
+# BLUR: apply a gaussian blur with the given radius
+img.reset.fit(w,h)
+img.blur(3.0)
+canvas.draw(img,x,y)
+canvas.text("blur",x,y-15)
+x += xoffset
+
+# MOTION BLUR: apply a motion blur with the given radius and angle
+img.reset.fit(w,h)
+img.motionblur(10.0,90)
+canvas.draw(img,x,y)
+canvas.text("motion blur",x,y-15)
+x += xoffset
+
+# save the canvas
+canvas.save
+
+`open #{OUTFILE}`

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-moving.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/graphics/image-moving.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-moving.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image-moving.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,63 @@
+require 'hotcocoa/graphics'
+include HotCocoa
+include Graphics
+
+PRECISION = 0.0000001
+
+OUTFILE = 'image-moving.png'
+
+# setup the canvas
+canvas = Canvas.for_image(:size => [400,400], :filename => OUTFILE)
+canvas.background(Color.white)
+canvas.font('Skia')
+canvas.fontsize(14)
+canvas.fill(Color.black)
+canvas.stroke(Color.red)
+
+# load an image
+img = Image.new('images/v2.jpg')
+
+# SCALE (multiply both dimensions by a scaling factor)
+img.scale(0.2)
+canvas.draw(img,0,240)  # draw the image at the specified coordinates
+canvas.text("scale to 20%",0,220)
+
+# FIT (scale to fit within the given dimensions, maintaining original aspect ratio)
+img.reset               # first reset the image to its original size
+img.fit(100,100)
+canvas.fill(Color.white)
+canvas.rect(120,240,100,100)
+canvas.fill(Color.black)
+canvas.draw(img,133,240)
+canvas.text("fit into 100x100",120,220)
+
+# RESIZE (scale to fit exactly within the given dimensions)
+img.reset
+img.resize(100,100)
+canvas.draw(img,240,240)
+canvas.text("resize to 100x100",240,220)
+
+# CROP (to the largest square containing image data)
+img.reset
+img.scale(0.2).crop
+canvas.draw(img,0,100)
+canvas.text("crop max square",0,80)
+
+# CROP (within a rectangle starting at x,y with width,height)
+img.reset
+img.scale(0.3).crop(0,0,100,100)
+canvas.draw(img,120,100)
+canvas.text("crop to 100x100",120,80)
+
+# ROTATE
+img.origin(:center)
+img.rotate(45)           
+canvas.draw(img,300,140)
+canvas.text("rotate 45 degrees",250,50)
+
+#img.origin(:center)   # center the image
+#img.translate(0,-150)    # move the image
+
+canvas.save
+
+`open #{OUTFILE}`

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/image.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,332 +0,0 @@
-#!/usr/bin/env macruby
-
-require 'hotcocoa/graphics'
-require 'test/unit'
-include HotCocoa::Graphics
-
-
-#PRECISION = 0.000000000000001
-PRECISION = 0.0000001
-
-class TestImage < Test::Unit::TestCase
-  
-  def test_image_moving
-    
-    # setup the canvas
-    File.delete('images/test-image-moving.png') if File.exists?('images/test-image-moving.png')
-    canvas = Canvas.for_image(:size => [400,400], :filename => 'images/test-image-moving.png')
-    canvas.background(Color.white)
-    canvas.font('Skia')
-    canvas.fontsize(14)
-    canvas.fill(Color.black)
-    canvas.stroke(Color.red)
-
-    # load an image
-    img = Image.new('images/v2.jpg')
-
-    # SCALE (multiply both dimensions by a scaling factor)
-    img.scale(0.2)
-    canvas.draw(img,0,240)  # draw the image at the specified coordinates
-    canvas.text("scale to 20%",0,220)
-
-    # FIT (scale to fit within the given dimensions, maintaining original aspect ratio)
-    img.reset               # first reset the image to its original size
-    img.fit(100,100)
-    canvas.fill(Color.white)
-    canvas.rect(120,240,100,100)
-    canvas.fill(Color.black)
-    canvas.draw(img,133,240)
-    canvas.text("fit into 100x100",120,220)
-
-    # RESIZE (scale to fit exactly within the given dimensions)
-    img.reset
-    img.resize(100,100)
-    canvas.draw(img,240,240)
-    canvas.text("resize to 100x100",240,220)
-
-    # CROP (to the largest square containing image data)
-    img.reset
-    img.scale(0.2).crop
-    canvas.draw(img,0,100)
-    canvas.text("crop max square",0,80)
-
-    # CROP (within a rectangle starting at x,y with width,height)
-    img.reset
-    img.scale(0.3).crop(0,0,100,100)
-    canvas.draw(img,120,100)
-    canvas.text("crop to 100x100",120,80)
-
-    # ROTATE
-    img.origin(:center)
-    img.rotate(45)           
-    canvas.draw(img,300,140)
-    canvas.text("rotate 45 degrees",250,50)
-
-    #img.origin(:center)   # center the image
-    #img.translate(0,-150)    # move the image
-
-    assert(true, canvas.save)
-    assert_equal('', `diff images/test-image-moving.png images/fixture-image-moving.png`)
-    #canvas.open
-  end
-  
-  def test_image_effects
-    # set up the canvas
-    File.delete('images/test-image-effects.png') if File.exists?('images/test-image-effects.png')
-    canvas = Canvas.for_image(:size => [400,400], :filename => 'images/test-image-effects.png')
-    canvas.background(Color.white)
-    canvas.font('Skia')
-    canvas.fontsize(14)
-    canvas.fill(Color.black)
-
-    # load image file
-    img = Image.new('images/v2.jpg')
-
-    # set image width/height, starting position, and increment position
-    w,h = [100,100]
-    x,y = [0,290]
-    xoffset = 105
-    yoffset = 130
-
-    # ORIGINAL image, resized to fit within w,h:
-    img.fit(w,h)
-    canvas.draw(img,x,y)
-    canvas.text("original",x,y-15)
-    x += xoffset
-
-    # CRYSTALLIZE: apply a "crystallize" effect with the given radius
-    img.reset.fit(w,h)
-    img.crystallize(5.0)
-    canvas.draw(img,x,y)
-    canvas.text("crystallize",x,y-15)
-    x += xoffset
-
-    # BLOOM: apply a "bloom" effect with the given radius and intensity
-    img.reset.fit(w,h)
-    img.bloom(10, 1.0)
-    canvas.draw(img,x,y)
-    canvas.text("bloom",x,y-15)
-    x += xoffset
-
-    # EDGES: detect edges
-    img.reset.fit(w,h)
-    img.edges(10)
-    canvas.draw(img,x,y)
-    canvas.text("edges",x,y-15)
-    x += xoffset
-
-    # (go to next row)
-    x = 0
-    y -= yoffset
-
-    # POSTERIZE: reduce image to the specified number of colors
-    img.reset.fit(w,h)
-    img.posterize(8)
-    canvas.draw(img,x,y)
-    canvas.text("posterize",x,y-15)
-    x += xoffset
-
-    # TWIRL: rotate around x,y with radius and angle
-    img.reset.fit(w,h)
-    img.twirl(35,50,40,90)
-    canvas.draw(img,x,y)
-    canvas.text("twirl",x,y-15)
-    x += xoffset
-
-    # EDGEWORK: simulate a woodcut print
-    img.reset.fit(w,h)
-    canvas.rect(x,y,img.width,img.height) # needs a black background
-    img.edgework(0.5)
-    canvas.draw(img,x,y)
-    canvas.text("edgework",x,y-15)
-    x += xoffset
-
-    # DISPLACEMENT: use a second image as a displacement map
-    img.reset.fit(w,h)
-    img2 = Image.new('images/italy.jpg').resize(img.width,img.height)
-    img.displacement(img2, 30.0)
-    canvas.draw(img,x,y)
-    canvas.text("displacement",x,y-15)
-    x += xoffset
-
-    # (go to next row)
-    x = 0
-    y -= yoffset
-
-    # DOTSCREEN: simulate a dot screen: center point, angle(0-360), width(1-50), and sharpness(0-1)
-    img.reset.fit(w,h)
-    img.dotscreen(0,0,45,5,0.7)
-    canvas.draw(img,x,y)
-    canvas.text("dotscreen",x,y-15)
-    x += xoffset
-
-    # SHARPEN: sharpen using the given radius and intensity
-    img.reset.fit(w,h)
-    img.sharpen(2.0,2.0)
-    canvas.draw(img,x,y)
-    canvas.text("sharpen",x,y-15)
-    x += xoffset
-
-    # BLUR: apply a gaussian blur with the given radius
-    img.reset.fit(w,h)
-    img.blur(3.0)
-    canvas.draw(img,x,y)
-    canvas.text("blur",x,y-15)
-    x += xoffset
-
-    # MOTION BLUR: apply a motion blur with the given radius and angle
-    img.reset.fit(w,h)
-    img.motionblur(10.0,90)
-    canvas.draw(img,x,y)
-    canvas.text("motion blur",x,y-15)
-    x += xoffset
-
-    # save the canvas
-    assert(true, canvas.save)
-    assert_equal('', `diff images/test-image-effects.png images/fixture-image-effects.png`)
-    #canvas.open
-  end
-  
-  def test_image_colors
-    
-    # set up the canvas
-    File.delete('images/test-image-colors.png') if File.exists?('images/test-image-colors.png')
-    canvas = Canvas.for_image(:size => [400,400], :filename => 'images/test-image-colors.png')
-    canvas.background(Color.white)
-    canvas.font('Skia')
-    canvas.fontsize(14)
-    canvas.fill(Color.black)
-
-    # LOAD IMAGE
-    img = Image.new('images/v2.jpg')
-
-    w,h = [100,100]
-    x,y = [0,290]
-    xoffset = 105
-    yoffset = 130
-
-    # ORIGINAL image, resized to fit within w,h:
-    img.fit(w,h)
-    canvas.draw(img,x,y)
-    canvas.text("original",x,y-15)
-    x += xoffset
-
-    # HUE: rotate color wheel by degrees
-    img.reset.fit(w,h)
-    img.hue(45)
-    canvas.draw(img,x,y)
-    canvas.text("hue",x,y-15)
-    x += xoffset
-    
-    # EXPOSURE: increase/decrease exposure by f-stops
-    img.reset.fit(w,h)
-    img.exposure(1.0)
-    canvas.draw(img,x,y)
-    canvas.text("exposure",x,y-15)
-    x += xoffset
-    
-    # SATURATION: adjust saturation by multiplier
-    img.reset.fit(w,h)
-    img.saturation(2.0)
-    canvas.draw(img,x,y)
-    canvas.text("saturation",x,y-15)
-    x += xoffset
-    
-    # (go to next row)
-    x = 0
-    y -= yoffset
-    
-    # CONTRAST: adjust contrast by multiplier
-    img.reset.fit(w,h)
-    img.contrast(2.0)
-    canvas.draw(img,x,y)
-    canvas.text("contrast",x,y-15)
-    x += xoffset
-    
-    # BRIGHTNESS: adjust brightness
-    img.reset.fit(w,h)
-    img.brightness(0.5)
-    canvas.draw(img,x,y)
-    canvas.text("brightness",x,y-15)
-    x += xoffset
-    
-    # MONOCHROME: convert to a monochrome image
-    img.reset.fit(w,h)
-    img.monochrome(Color.orange)
-    canvas.draw(img,x,y)
-    canvas.text("monochrome",x,y-15)
-    x += xoffset
-    
-    # WHITEPOINT: remap the white point
-    img.reset.fit(w,h)
-    img.whitepoint(Color.whiteish)
-    canvas.draw(img,x,y)
-    canvas.text("white point",x,y-15)
-    x += xoffset
-    
-    # (go to next row)
-    x = 0
-    y -= yoffset
-    
-    # CHAINING: apply multiple effects at once
-    img.reset.fit(w,h)
-    img.hue(60).saturation(2.0).contrast(2.5)
-    canvas.draw(img,x,y)
-    canvas.text("multi effects",x,y-15)
-    x += xoffset
-    
-    # COLORS: sample random colors from the image and render as a gradient
-    img.reset.fit(w,h)              # reset the image and scale to fit within w,h
-    colors = img.colors(10).sort!   # select 10 random colors and sort by brightness
-    # gradient
-    gradient = Gradient.new(colors) # create a new gradient using the selected colors
-    rect = Path.new.rect(x,y,img.width,img.height) # create a rectangle the size of the image
-    canvas.beginclip(rect)          # begin clipping so the gradient will only fill the rectangle
-    canvas.gradient(gradient,x,y,x+img.width,y+img.height) # draw the gradient between opposite corners of the rectangle
-    canvas.endclip                  # end clipping so we can draw on the rest of the canvas
-    canvas.text("get colors",x,y-15)    # add text label
-    x += xoffset
-
-    assert(true, canvas.save)
-    # hmm, can't use an image fixture if we're doing randomized things
-    # assert_equal('', `diff images/test-image-colors.png images/fixture-image-colors.png`)
-  end
-  
-  def test_image_blendmodes
-    
-    canvas = Canvas.for_image(:size => [400,730], :filename => 'images/test-image-blendmodes.png')
-    canvas.background(Color.white)
-    canvas.font('Skia')
-    canvas.fontsize(14)
-
-    # set image width,height
-    w,h = [95,95]
-
-    # set initial drawing position
-    x,y = [0,canvas.height - h - 10]
-
-    # load and resize two images
-    imgA = Image.new('images/v2.jpg').resize(w,h)
-    imgB = Image.new('images/italy.jpg').resize(w,h)
-
-    # add image B to image A using each blending mode, and draw to canvas
-    [:normal,:multiply,:screen,:overlay,:darken,:lighten,
-      :colordodge,:colorburn,:softlight,:hardlight,:difference,:exclusion,
-      :hue,:saturation,:color,:luminosity,:maximum,:minimum,:add,:atop,
-      :in,:out,:over].each do |blendmode|
-      imgA.reset.resize(w,h)
-      imgA.blend(imgB, blendmode)
-      canvas.draw(imgA,x,y)
-      canvas.text(blendmode,x,y-15)
-      x += w + 5
-      if (x > canvas.width - w + 5)
-        x = 0
-        y -= h + 25
-      end
-    end
-    canvas.save
-    
-  end
-  
-  
-end
\ No newline at end of file

Modified: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/iterate.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/iterate.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/iterate.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,45 +1,38 @@
-#!/usr/bin/env macruby
-
 require 'hotcocoa/graphics'
-require 'test/unit'
-include HotCocoa::Graphics
+include HotCocoa
+include Graphics
 
+OUTFILE = 'iterate.png'
 
-class TestIterate < Test::Unit::TestCase
-  
-  def test_iterate
+# create a new 400×400 pixel canvas to draw on
+canvas = Canvas.for_image(:size => [400,400], :filename => OUTFILE) do
+  background(Color.white)
 
-    # create a new 400×400 pixel canvas to draw on
-    canvas = Canvas.for_image(:size => [400,400], :filename => 'images/test-iterating.png') do
-      background(Color.white)
+  # create a petal shape with base at (0,0), size 40×150, and bulge at 30px
+  shape = Path.new
+  shape.petal(0,0,40,150,30)
+  # add a circle
+  shape.oval(-10,20,20,20)
+  # color it red
+  shape.fill(Color.red)
 
-      # create a petal shape with base at (0,0), size 40×150, and bulge at 30px
-      shape = Path.new
-      shape.petal(0,0,40,150,30)
-      # add a circle
-      shape.oval(-10,20,20,20)
-      # color it red
-      shape.fill(Color.red)
+  # increment shape parameters by the specified amount each iteration,
+  # or by a random value selected from the specified range
+  shape.increment(:rotation, 5.0)
+  #shape.increment(:scale, 0.95)
+  shape.increment(:scalex, 0.99)
+  shape.increment(:scaley, 0.96)
+  shape.increment(:x, 10.0)
+  shape.increment(:y, 12.0)
+  shape.increment(:hue,-0.02..0.02)
+  shape.increment(:saturation, -0.1..0.1)
+  shape.increment(:brightness, -0.1..0.1)
+  shape.increment(:alpha, -0.1..0.1)
 
-      # increment shape parameters by the specified amount each iteration,
-      # or by a random value selected from the specified range
-      shape.increment(:rotation, 5.0)
-      #shape.increment(:scale, 0.95)
-      shape.increment(:scalex, 0.99)
-      shape.increment(:scaley, 0.96)
-      shape.increment(:x, 10.0)
-      shape.increment(:y, 12.0)
-      shape.increment(:hue,-0.02..0.02)
-      shape.increment(:saturation, -0.1..0.1)
-      shape.increment(:brightness, -0.1..0.1)
-      shape.increment(:alpha, -0.1..0.1)
+  # draw 200 petals on the canvas starting at location 50,200
+  translate(50,220)
+  draw(shape,0,0,200)
+  save
+end
 
-      # draw 200 petals on the canvas starting at location 50,200
-      translate(50,220)
-      draw(shape,0,0,200)
-      save
-    end
-    
-  end
-  
-end
\ No newline at end of file
+`open #{OUTFILE}`


Property changes on: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/iterate.rb
___________________________________________________________________
Deleted: svn:executable
   - *

Modified: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/particle.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/particle.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/particle.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,76 +1,69 @@
-#!/usr/bin/env macruby
-
 require 'hotcocoa/graphics'
-require 'test/unit'
-include HotCocoa::Graphics
-
+include HotCocoa
+include Graphics
 include Math
 
-class TestParticle < Test::Unit::TestCase
-  
-  def test_particle
+OUTFILE = 'particule.png'
 
-    # initialize canvas
-    canvas = Canvas.for_image(:size => [1920,1200], :filename => 'images/test-particles.png')
-    canvas.background(Color.black)
+canvas = Canvas.for_image(:size => [1920,1200], :filename => OUTFILE)
+canvas.background(Color.black)
 
-    # load images and grab colors
-    img = Image.new('images/italy.jpg').saturation(1.9)
-    redcolors = img.colors(100)
-    img = Image.new('images/v2.jpg').saturation(1.9)
-    bluecolors = img.colors(100)
+# load images and grab colors
+img = Image.new('images/italy.jpg').saturation(1.9)
+redcolors = img.colors(100)
+img = Image.new('images/v2.jpg').saturation(1.9)
+bluecolors = img.colors(100)
 
-    # create flower head shape
-    head = Path.new.oval(0,0,10,10,:center)
-    petals = 3
-    petals.times do
-      head.rotate(360/petals)
-      head.oval(0,10,5,5,:center)
-      head.oval(0,17,2,2,:center)
-    end
-    # randomize head attributes
-    head.randomize(:fill,redcolors)
-    head.randomize(:stroke,bluecolors)
-    head.randomize(:scale,0.2..2.0)
-    head.randomize(:rotation,0..360)
+# create flower head shape
+head = Path.new.oval(0,0,10,10,:center)
+petals = 3
+petals.times do
+  head.rotate(360/petals)
+  head.oval(0,10,5,5,:center)
+  head.oval(0,17,2,2,:center)
+end
+# randomize head attributes
+head.randomize(:fill,redcolors)
+head.randomize(:stroke,bluecolors)
+head.randomize(:scale,0.2..2.0)
+head.randomize(:rotation,0..360)
 
-    # create particles
-    numparticles = 200
-    numframes = 200
-    particles = []
-    numparticles.times do |i|
-      # start particle at random point at bottom of canvas
-      x = random(canvas.width/2 - 50,canvas.width/2 + 50)
-      p = Particle.new(x,0)
-      p.velocity_x = random(-0.5,0.5)   # set initial x velocity
-      p.velocity_y = random(1.0,3.0)    # set initial y velocity
-      p.acceleration = 0.1            # set drag or acceleration
-      particles[i] = p          # add particle to array
-    end
+# create particles
+numparticles = 200
+numframes = 200
+particles = []
+numparticles.times do |i|
+  # start particle at random point at bottom of canvas
+  x = random(canvas.width/2 - 50,canvas.width/2 + 50)
+  p = Particle.new(x,0)
+  p.velocity_x = random(-0.5,0.5)   # set initial x velocity
+  p.velocity_y = random(1.0,3.0)    # set initial y velocity
+  p.acceleration = 0.1            # set drag or acceleration
+  particles[i] = p          # add particle to array
+end
 
-    # animate particles
-    numframes.times do |frame|
-      numparticles.times do |i|
-        particles[i].move
-      end
-    end
+# animate particles
+numframes.times do |frame|
+  numparticles.times do |i|
+    particles[i].move
+  end
+end
 
-    # draw particle trails and heads
-    numparticles.times do |i|
-      canvas.push
-      # choose a stem color
-      color = choose(bluecolors).a(0.7).analog(20,0.7)
-      canvas.stroke(color)
-      canvas.strokewidth(random(0.5,2.0))
-      # draw the particle
-      particles[i].draw(canvas)
-      # go to the last particle position and draw the flower head
-      canvas.translate(particles[i].points[-1][0],particles[i].points[-1][1])
-      canvas.draw(head)
-      canvas.pop
-    end
+# draw particle trails and heads
+numparticles.times do |i|
+  canvas.push
+  # choose a stem color
+  color = choose(bluecolors).a(0.7).analog(20,0.7)
+  canvas.stroke(color)
+  canvas.strokewidth(random(0.5,2.0))
+  # draw the particle
+  particles[i].draw(canvas)
+  # go to the last particle position and draw the flower head
+  canvas.translate(particles[i].points[-1][0],particles[i].points[-1][1])
+  canvas.draw(head)
+  canvas.pop
+end
 
-    canvas.save   
-  end
-  
-end
\ No newline at end of file
+canvas.save
+
+`open #{OUTFILE}`


Property changes on: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/particle.rb
___________________________________________________________________
Deleted: svn:executable
   - *

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/pdf.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/pdf.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/pdf.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,48 +0,0 @@
-#!/usr/bin/env macruby
-
-require 'hotcocoa/graphics'
-require 'test/unit'
-include HotCocoa::Graphics
-
-
-class TestPdf < Test::Unit::TestCase
-  
-  # def test_pdf
-  #   pdf_to_png('/Volumes/catalog/inprocess/GV/lookinsides/GV.1505.pdf','/Volumes/catalog/inprocess/GV/converted')
-   # end
-  #Mon Jul 28 19:53:55 toastmacbook-3.local macruby[16693] <Error>: CGBitmapContextCreateImage: failed to allocate 144365952 bytes.
-  #Mon Jul 28 19:53:55 toastmacbook-3.local macruby[16693] <Error>: CGImageCreate: invalid image provider: NULL.
-  
-  def test_parse_dir
-    scale = 3.0
-    sourcedir = '/Volumes/catalog/inprocess/GV/lookinsides'
-    destdir = '/Volumes/catalog/inprocess/GV/converted'
-    for file in Dir.entries(sourcedir)
-      next unless File.extname(file).downcase == '.pdf'
-      pdf_to_png(File.join(sourcedir,file),destdir,scale)
-    end
-  end
-  
-end
-
-def pdf_to_png(file,destdir,scale=3.0)
-  puts file
-  newfilename = File.basename(file, File.extname(file))
-  newfilename, pagenum = newfilename.split('_')
-  pagenum ||= 0
-  pagenum = sprintf("%02d", pagenum)
-  pdf = Pdf.new(file)
-  pages = pdf.pages
-  w = pdf.width * scale
-  h = pdf.height * scale
-  for p in 1..pages do
-    pdisplay = sprintf("%02d", p)
-    canvas = Canvas.for_image(:size => [400,400], :filename => "#{destdir}/#{newfilename}_#{pagenum}-#{pdisplay}.png")
-    canvas.background(Color.white)
-    canvas.draw(pdf,0,0,w,h,p)
-    canvas.save
-    canvas = nil
-    GC.start
-  end
-
-end
\ No newline at end of file

Modified: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/randomize.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/randomize.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/randomize.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,46 +1,40 @@
 #!/usr/bin/env macruby
-
 require 'hotcocoa/graphics'
-require 'test/unit'
-include HotCocoa::Graphics
+include HotCocoa
+include Graphics
 
+OUTFILE = 'randomize.png'
 
-class TestRandomize < Test::Unit::TestCase
-  
-  def test_randomize
+# create a new 400×400 pixel canvas to draw on
+canvas = Canvas.for_image(:size => [400,400], :filename => OUTFILE)
+canvas.background(Color.white)
 
-    # create a new 400×400 pixel canvas to draw on
-    canvas = Canvas.for_image(:size => [400,400], :filename => 'images/test-randomize.png')
-    canvas.background(Color.white)
+# create a flower shape
+shape = Path.new
+petals = 5
+for i in 1..petals do
+  shape.petal(0, 0, 40, 100)       # petal at x,y with width,height
+  shape.rotate(360 / petals)       # rotate by 1/5th
+end
 
-    # create a flower shape
-    shape = Path.new
-    petals = 5
-    for i in 1..petals do
-      shape.petal(0,0,40,100)       # petal at x,y with width,height
-      shape.rotate(360 / petals)    # rotate by 1/5th
-    end
+# randomize shape parameters
+shape.randomize(:fill, Color.blue.complementary)
+shape.randomize(:stroke, Color.blue.complementary)
+shape.randomize(:strokewidth, 1.0..10.0)
+shape.randomize(:rotation, 0..360)
+shape.randomize(:scale, 0.5..1.0)
+shape.randomize(:scalex, 0.5..1.0)
+shape.randomize(:scaley, 0.5..1.0)
+shape.randomize(:alpha, 0.5..1.0)
+# shape.randomize(:hue, 0.5..0.8)
+shape.randomize(:saturation, 0.0..1.0)
+shape.randomize(:brightness, 0.0..1.0)
+shape.randomize(:x, -100.0..100.0)
+shape.randomize(:y, -100.0..100.0)
 
-    # randomize shape parameters
-    shape.randomize(:fill, Color.blue.complementary)
-    shape.randomize(:stroke, Color.blue.complementary)
-    shape.randomize(:strokewidth, 1.0..10.0)
-    shape.randomize(:rotation, 0..360)
-    shape.randomize(:scale, 0.5..1.0)
-    shape.randomize(:scalex, 0.5..1.0)
-    shape.randomize(:scaley, 0.5..1.0)
-    shape.randomize(:alpha, 0.5..1.0)
-    # shape.randomize(:hue, 0.5..0.8)
-    shape.randomize(:saturation, 0.0..1.0)
-    shape.randomize(:brightness, 0.0..1.0)
-    shape.randomize(:x, -100.0..100.0)
-    shape.randomize(:y, -100.0..100.0)
+# draw 50 flowers starting at the center of the canvas
+canvas.translate(200, 200)
+canvas.draw(shape, 0, 0, 100)
+canvas.save
 
-    # draw 50 flowers starting at the center of the canvas
-    canvas.translate(200,200)
-    canvas.draw(shape,0,0,100)
-    canvas.save
-    
-  end
-  
-end
\ No newline at end of file
+`open #{OUTFILE}`


Property changes on: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/randomize.rb
___________________________________________________________________
Deleted: svn:executable
   - *

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/rope-hair.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/graphics/rope-hair.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/rope-hair.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/rope-hair.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,36 @@
+require 'hotcocoa/graphics'
+include HotCocoa
+include Graphics
+
+OUTFILE = 'rope-hair.png'
+
+# initialize the canvas
+canvas = Canvas.for_image(:size => [400,400], :filename => OUTFILE)
+
+# choose a random color and set the background to a darker variant
+clr = Color.random.a(0.5)
+canvas.background(clr.copy.darken(0.6))
+
+# create a new rope with 200 fibers
+rope = Rope.new(canvas, :width => 100, :fibers => 200, :strokewidth => 0.4, :roundness => 3.0)
+
+# randomly rotate the canvas from its center
+canvas.translate(canvas.width/2, canvas.height/2)
+canvas.rotate(random(0, 360))
+canvas.translate(-canvas.width/2, -canvas.height/2)
+
+# draw 20 ropes
+ropes = 20
+ropes.times do
+  canvas.stroke(clr.copy.analog(20, 0.8))   # rotate hue up to 20 deg left/right, vary brightness/saturation by up to 70%
+  rope.x0 = -100                            # start rope off bottom left of canvas
+  rope.y0 = -100
+  rope.x1 = canvas.width + 100              # end rope off top right of canvas
+  rope.y1 = canvas.height + 100
+  rope.hair                                 # draw rope in organic “hair” style
+end
+
+# save the canvas
+canvas.save
+
+`open #{OUTFILE}`

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/rope-ribbon.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/graphics/rope-ribbon.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/rope-ribbon.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/rope-ribbon.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,36 @@
+require 'hotcocoa/graphics'
+include HotCocoa
+include Graphics
+
+OUTFILE = 'rope-ribbon.png'
+
+# initialize the canvas
+canvas = Canvas.for_image(:size => [400,400], :filename => OUTFILE)
+
+# choose a random color and set the background to a darker variant
+clr = Color.random.a(0.5)
+canvas.background(clr.copy.darken(0.6))
+
+# create a new rope with 200 fibers
+rope = Rope.new(canvas, :width => 500, :fibers => 200, :strokewidth => 1.0, :roundness => 1.5)
+
+# randomly rotate the canvas from its center
+canvas.translate(canvas.width/2, canvas.height/2)
+canvas.rotate(random(0, 360))
+canvas.translate(-canvas.width/2, -canvas.height/2)
+
+# draw 20 ropes
+ropes = 20
+ropes.times do |i|
+   canvas.stroke(clr.copy.analog(10, 0.7))   # rotate hue up to 10 deg left/right, vary brightness/saturation by up to 70%
+   rope.x0 = -100                            # start rope off bottom left of canvas
+   rope.y0 = -100
+   rope.x1 = canvas.width + 200              # end rope off top right of canvas
+   rope.y1 = canvas.height + 200
+   rope.ribbon                               # draw rope in smooth “ribbon” style
+end
+
+# save the canvas
+canvas.save
+
+`open #{OUTFILE}`

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/rope.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/rope.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/rope.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,81 +0,0 @@
-#!/usr/bin/env macruby
-
-require 'hotcocoa/graphics'
-require 'test/unit'
-include HotCocoa::Graphics
-
-
-class TestRope < Test::Unit::TestCase
-  
-  def test_rope_hair
-
-    # initialize the canvas
-    canvas = Canvas.for_image(:size => [400,400], :filename => 'images/test-rope-hair.png')
-
-    # choose a random color and set the background to a darker variant
-    clr = Color.random.a(0.5)
-    canvas.background(clr.copy.darken(0.6))
-
-    # create a new rope with 200 fibers
-    rope = Rope.new(canvas, :width => 100, :fibers => 200, :strokewidth => 0.4, :roundness => 3.0)
-
-    # randomly rotate the canvas from its center
-    canvas.translate(canvas.width/2,canvas.height/2)
-    canvas.rotate(random(0,360))
-    canvas.translate(-canvas.width/2,-canvas.height/2)
-
-    # draw 20 ropes
-    ropes = 20
-    ropes.times do
-      canvas.stroke(clr.copy.analog(20, 0.8))   # rotate hue up to 20 deg left/right, vary brightness/saturation by up to 70%
-      rope.x0 = -100                            # start rope off bottom left of canvas
-      rope.y0 = -100
-      rope.x1 = canvas.width + 100              # end rope off top right of canvas
-      rope.y1 = canvas.height + 100
-      rope.hair                                 # draw rope in organic “hair” style
-    end
-
-    # save the canvas
-    canvas.save
-    
-  end
-  
-  
-  def test_rope_ribbon
-    
-    # initialize the canvas
-    canvas = Canvas.for_image(:size => [400,400], :filename => 'images/test-rope-ribbon.png')
-
-    # choose a random color and set the background to a darker variant
-    clr = Color.random.a(0.5)
-    canvas.background(clr.copy.darken(0.6))
-
-    # create a new rope with 200 fibers
-    rope = Rope.new(canvas, :width => 500, :fibers => 200, :strokewidth => 1.0, :roundness => 1.5)
-
-    # randomly rotate the canvas from its center
-    canvas.translate(canvas.width/2,canvas.height/2)
-    canvas.rotate(random(0,360))
-    canvas.translate(-canvas.width/2,-canvas.height/2)
-
-    # draw 20 ropes
-    ropes = 20
-    for i in 0..ropes do
-        canvas.stroke(clr.copy.analog(10, 0.7))   # rotate hue up to 10 deg left/right, vary brightness/saturation by up to 70%
-        rope.x0 = -100                            # start rope off bottom left of canvas
-        rope.y0 = -100
-        rope.x1 = canvas.width + 200              # end rope off top right of canvas
-        rope.y1 = canvas.height + 200
-        rope.ribbon                               # draw rope in smooth “ribbon” style
-    end
-
-    # save the canvas
-    canvas.save
-    
-  end
-  
-  
-  
-  
-  
-end
\ No newline at end of file

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/spirograph.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/graphics/spirograph.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/spirograph.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/spirograph.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,31 @@
+#!/usr/bin/env macruby
+require 'hotcocoa/graphics'
+include HotCocoa
+include Graphics
+
+OUTFILE = 'spirograph.png'
+
+# set up the canvas and font
+canvas = Canvas.for_image(:size => [400,400], :filename => OUTFILE) do
+  background(Color.beige)
+  fill(Color.black)
+  font('Book Antiqua')
+  fontsize(12)
+  translate(200,200)
+
+  # rotate, draw text, repeat
+  180.times do |frame|
+    new_state do
+      rotate((frame*2) + 120)
+      translate(70,0)
+      text('going...', 80, 0)
+      rotate(frame * 6)
+      text('Around and', 20, 0)
+    end
+  end
+end
+
+# save the canvas
+canvas.save
+
+`open #{OUTFILE}`

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/text.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/text.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/graphics/text.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,37 +0,0 @@
-#!/usr/bin/env macruby
-
-require 'hotcocoa/graphics'
-require 'test/unit'
-include HotCocoa::Graphics
-
-
-class TestText < Test::Unit::TestCase
-  
-  def test_text_spirograph
-    
-    # set up the canvas and font
-    canvas = Canvas.for_image(:size => [400,400], :filename => 'images/test-text-spirograph.png') do
-      background(Color.beige)
-      fill(Color.black)
-      font('Book Antiqua')
-      fontsize(12)
-      translate(200,200)
-
-      # rotate, draw text, repeat
-      180.times do |frame|
-        new_state do
-          rotate((frame*2) + 120)
-          translate(70,0)
-          text('going...', 80, 0)
-          rotate(frame * 6)
-          text('Around and', 20, 0)
-        end
-      end
-    end
-
-    # save the canvas
-    canvas.save
-    
-  end
-  
-end
\ No newline at end of file

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/Rakefile
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/mvc/Rakefile	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/Rakefile	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,4 +0,0 @@
-require 'hotcocoa/application_builder'
-require 'hotcocoa/standard_rake_tasks'
-
-task :default => [:run]
\ No newline at end of file

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/Rakefile (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/mvc/Rakefile)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/Rakefile	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/Rakefile	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,4 @@
+require 'hotcocoa/application_builder'
+require 'hotcocoa/standard_rake_tasks'
+
+task :default => [:run]
\ No newline at end of file

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/config/build.yml
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/mvc/config/build.yml	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/config/build.yml	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,8 +0,0 @@
-name: Mvc
-load: lib/application.rb
-version: "1.0"
-icon: resources/HotCocoa.icns
-resources:
-  - resources/**/*.*
-sources: 
-  - lib/**/*.rb

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/config/build.yml (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/mvc/config/build.yml)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/config/build.yml	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/config/build.yml	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,8 @@
+name: Mvc
+load: lib/application.rb
+version: "1.0"
+icon: resources/HotCocoa.icns
+resources:
+  - resources/**/*.*
+sources: 
+  - lib/**/*.rb

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/application.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/mvc/lib/application.rb	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/application.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,60 +0,0 @@
-require 'hotcocoa'
-require 'lib/mvc'
-
-class Application < HotCocoaApplication
-  
-end
-
-class ApplicationController < HotCocoaApplicationController
-  def switch_views(sender)
-    application_window.view.remove(application_view)
-    application_window.view << my_other_view
-  end
-end
-
-class ApplicationView < HotCocoaView
-  def render 
-    self << HotCocoa.button(:title => "View 1!", :on_action => controller.method(:switch_views))
-  end
-end
-
-class MyController < HotCocoaController
-  def switch_back(sender)
-    application_window.view.remove(my_other_view)
-    application_window.view << application_view
-  end
-
-  def open_window(sender)
-    HotCocoa.window(:center => true) << third_view
-  end
-  
-end
-
-class MyOtherView < HotCocoaView
-
-  controller :my_controller
-
-  def render 
-    self << HotCocoa.button(:title => "View 2!", :on_action => controller.method(:switch_back), :frame => [0, 100, 200, 20])
-    self << HotCocoa.button(:title => "open window!", :on_action => controller.method(:open_window))
-  end
-
-end
-
-class ThirdController < HotCocoaController
-  def close_window(sender)
-    third_view.window.close
-  end
-end
-
-class ThirdView < HotCocoaView
-
-  controller :third_controller
-
-  def render 
-    self << HotCocoa.button(:title => "close window!", :on_action => controller.method(:close_window))
-  end
-
-end
-
-Application.new.start
\ No newline at end of file

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/application.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/mvc/lib/application.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/application.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/application.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,60 @@
+require 'hotcocoa'
+require 'lib/mvc'
+
+class Application < HotCocoaApplication
+  
+end
+
+class ApplicationController < HotCocoaApplicationController
+  def switch_views(sender)
+    application_window.view.remove(application_view)
+    application_window.view << my_other_view
+  end
+end
+
+class ApplicationView < HotCocoaView
+  def render 
+    self << HotCocoa.button(:title => "View 1!", :on_action => controller.method(:switch_views))
+  end
+end
+
+class MyController < HotCocoaController
+  def switch_back(sender)
+    application_window.view.remove(my_other_view)
+    application_window.view << application_view
+  end
+
+  def open_window(sender)
+    HotCocoa.window(:center => true) << third_view
+  end
+  
+end
+
+class MyOtherView < HotCocoaView
+
+  controller :my_controller
+
+  def render 
+    self << HotCocoa.button(:title => "View 2!", :on_action => controller.method(:switch_back), :frame => [0, 100, 200, 20])
+    self << HotCocoa.button(:title => "open window!", :on_action => controller.method(:open_window))
+  end
+
+end
+
+class ThirdController < HotCocoaController
+  def close_window(sender)
+    third_view.window.close
+  end
+end
+
+class ThirdView < HotCocoaView
+
+  controller :third_controller
+
+  def render 
+    self << HotCocoa.button(:title => "close window!", :on_action => controller.method(:close_window))
+  end
+
+end
+
+Application.new.start
\ No newline at end of file

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/menu.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/mvc/lib/menu.rb	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/menu.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,32 +0,0 @@
-module HotCocoa
-  def application_menu
-    menu do |main|
-      main.submenu :apple do |apple|
-        apple.item :about, :title => "About #{NSApp.name}"
-        apple.separator
-        apple.item :preferences, :key => ","
-        apple.separator
-        apple.submenu :services
-        apple.separator
-        apple.item :hide, :title => "Hide #{NSApp.name}", :key => "h"
-        apple.item :hide_others, :title => "Hide Others", :key => "h", :modifiers => [:command, :alt]
-        apple.item :show_all, :title => "Show All"
-        apple.separator
-        apple.item :quit, :title => "Quit #{NSApp.name}", :key => "q"
-      end
-      main.submenu :file do |file|
-        file.item :new, :key => "n"
-        file.item :open, :key => "o"
-      end
-      main.submenu :window do |win|
-        win.item :minimize, :key => "m"
-        win.item :zoom
-        win.separator
-        win.item :bring_all_to_front, :title => "Bring All to Front", :key => "o"
-      end
-      main.submenu :help do |help|
-        help.item :help, :title => "#{NSApp.name} Help"
-      end
-    end
-  end
-end

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/menu.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/mvc/lib/menu.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/menu.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/menu.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,32 @@
+module HotCocoa
+  def application_menu
+    menu do |main|
+      main.submenu :apple do |apple|
+        apple.item :about, :title => "About #{NSApp.name}"
+        apple.separator
+        apple.item :preferences, :key => ","
+        apple.separator
+        apple.submenu :services
+        apple.separator
+        apple.item :hide, :title => "Hide #{NSApp.name}", :key => "h"
+        apple.item :hide_others, :title => "Hide Others", :key => "h", :modifiers => [:command, :alt]
+        apple.item :show_all, :title => "Show All"
+        apple.separator
+        apple.item :quit, :title => "Quit #{NSApp.name}", :key => "q"
+      end
+      main.submenu :file do |file|
+        file.item :new, :key => "n"
+        file.item :open, :key => "o"
+      end
+      main.submenu :window do |win|
+        win.item :minimize, :key => "m"
+        win.item :zoom
+        win.separator
+        win.item :bring_all_to_front, :title => "Bring All to Front", :key => "o"
+      end
+      main.submenu :help do |help|
+        help.item :help, :title => "#{NSApp.name} Help"
+      end
+    end
+  end
+end

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/mvc.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/mvc/lib/mvc.rb	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/mvc.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,182 +0,0 @@
-require 'hotcocoa'
-
-class String
-  
-  def underscore
-    to_s.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase
-  end #unless defined?(:underscore)
-  
-  def camel_case
-    if self !~ /_/ && self =~ /[A-Z]+.*/
-      self
-    else
-      split('_').map{|e| e.capitalize}.join
-    end
-  end #unless defined?(:camel_case)
-end
-
-class HotCocoaApplication
-  attr_accessor :shared_application, :application_controller, :controllers
-  
-  include HotCocoa
-  
-  def self.instance=(instance)
-    @instance = instance
-  end
-  
-  def self.instance
-    @instance
-  end
-  
-  def initialize
-    HotCocoaApplication.instance = self
-    @controllers = {}
-    @shared_application = application
-    @application_controller = controller(:application_controller)
-    shared_application.delegate = application_controller
-  end
-  
-  def start
-    @shared_application.run
-  end
-  
-  def controller(controller_name)
-    controller_class = Object.const_get(controller_name.to_s.camel_case)
-    @controllers[controller_name] || create_controller_instance(controller_name, controller_class)
-  end
-  
-  private
-  
-    def create_controller_instance(controller_name, controller_class)
-      controller_instance = controller_class.new(self)
-      @controllers[controller_name] = controller_instance
-      controller_instance.application_window
-      controller_instance
-    end
-  
-end
-
-class HotCocoaController
-  
-  def self.view_instances
-    @view_instances ||= {}
-  end
-  
-  attr_reader :application
-  
-  def initialize(application)
-    @application = application
-  end
-  
-  def application_window
-    @application.application_controller.application_window
-  end
-
-end
-
-class HotCocoaApplicationController < HotCocoaController
-  
-  def initialize(application)
-    super(application)
-  end
-  
-  def application_window
-    @application_window ||= ApplicationWindow.new(self).application_window
-  end
-  
-  # help menu item
-  def on_help(menu)
-  end
-
-  # This is commented out, so the minimize menu item is disabled
-  def on_minimize(menu)
-  end
-
-  # window/zoom
-  def on_zoom(menu)
-  end
-
-  # window/bring_all_to_front
-  def on_bring_all_to_front(menu)
-  end
-
-end
-
-class HotCocoaWindow
-  
-  attr_reader :application_controller, :application_window
-  
-  def initialize(application_controller)
-    @application_controller = application_controller
-    render
-  end
-  
-  def render
-    @application_window = HotCocoa.window(:title => title)
-    @application_window.view << application_controller.application_view
-  end
-  
-  def title
-    "My Application"
-  end
-  
-end
-
-class HotCocoaView < NSView
-  
-  DefaultLayoutOptions = {:expand => [:width, :height]}
-  
-  module ClassMethods
-    def controller(name=nil)
-      if name
-        @name = name
-      else
-        @name || :application_controller
-      end
-    end
-    def options(options=nil)
-      @options = options if options
-    end
-  end
-  
-  def self.inherited(klass)
-    klass.extend(ClassMethods)
-    klass.send(:include, HotCocoa::Behaviors)
-    class_name = klass.name.underscore
-    HotCocoaController.class_eval %{
-      def #{class_name}
-        view = HotCocoaController.view_instances[:#{class_name}] ||= #{klass.name}.alloc.initWithFrame([0,0,0,0])
-        view.setup_view
-        view
-      end
-    }, __FILE__, __LINE__
-  end
-  
-  attr_reader :controller
-
-  def setup_view
-    @controller = class_controller
-    self.layout = layout_options
-    render
-  end
-  
-  private
-  
-    def class_controller
-      HotCocoaApplication.instance.controller(self.class.controller)
-    end
-  
-    def layout_options
-      options = if self.class.options && self.class.options[:layout]
-        self.class.options[:layout]
-      else
-        DefaultLayoutOptions
-      end
-    end
-
-end
-
-class ApplicationWindow < HotCocoaWindow
-  
-end
-

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/mvc.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/mvc/lib/mvc.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/mvc.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/lib/mvc.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,182 @@
+require 'hotcocoa'
+
+class String
+  
+  def underscore
+    to_s.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase
+  end #unless defined?(:underscore)
+  
+  def camel_case
+    if self !~ /_/ && self =~ /[A-Z]+.*/
+      self
+    else
+      split('_').map{|e| e.capitalize}.join
+    end
+  end #unless defined?(:camel_case)
+end
+
+class HotCocoaApplication
+  attr_accessor :shared_application, :application_controller, :controllers
+  
+  include HotCocoa
+  
+  def self.instance=(instance)
+    @instance = instance
+  end
+  
+  def self.instance
+    @instance
+  end
+  
+  def initialize
+    HotCocoaApplication.instance = self
+    @controllers = {}
+    @shared_application = application
+    @application_controller = controller(:application_controller)
+    shared_application.delegate = application_controller
+  end
+  
+  def start
+    @shared_application.run
+  end
+  
+  def controller(controller_name)
+    controller_class = Object.const_get(controller_name.to_s.camel_case)
+    @controllers[controller_name] || create_controller_instance(controller_name, controller_class)
+  end
+  
+  private
+  
+    def create_controller_instance(controller_name, controller_class)
+      controller_instance = controller_class.new(self)
+      @controllers[controller_name] = controller_instance
+      controller_instance.application_window
+      controller_instance
+    end
+  
+end
+
+class HotCocoaController
+  
+  def self.view_instances
+    @view_instances ||= {}
+  end
+  
+  attr_reader :application
+  
+  def initialize(application)
+    @application = application
+  end
+  
+  def application_window
+    @application.application_controller.application_window
+  end
+
+end
+
+class HotCocoaApplicationController < HotCocoaController
+  
+  def initialize(application)
+    super(application)
+  end
+  
+  def application_window
+    @application_window ||= ApplicationWindow.new(self).application_window
+  end
+  
+  # help menu item
+  def on_help(menu)
+  end
+
+  # This is commented out, so the minimize menu item is disabled
+  def on_minimize(menu)
+  end
+
+  # window/zoom
+  def on_zoom(menu)
+  end
+
+  # window/bring_all_to_front
+  def on_bring_all_to_front(menu)
+  end
+
+end
+
+class HotCocoaWindow
+  
+  attr_reader :application_controller, :application_window
+  
+  def initialize(application_controller)
+    @application_controller = application_controller
+    render
+  end
+  
+  def render
+    @application_window = HotCocoa.window(:title => title)
+    @application_window.view << application_controller.application_view
+  end
+  
+  def title
+    "My Application"
+  end
+  
+end
+
+class HotCocoaView < NSView
+  
+  DefaultLayoutOptions = {:expand => [:width, :height]}
+  
+  module ClassMethods
+    def controller(name=nil)
+      if name
+        @name = name
+      else
+        @name || :application_controller
+      end
+    end
+    def options(options=nil)
+      @options = options if options
+    end
+  end
+  
+  def self.inherited(klass)
+    klass.extend(ClassMethods)
+    klass.send(:include, HotCocoa::Behaviors)
+    class_name = klass.name.underscore
+    HotCocoaController.class_eval %{
+      def #{class_name}
+        view = HotCocoaController.view_instances[:#{class_name}] ||= #{klass.name}.alloc.initWithFrame([0,0,0,0])
+        view.setup_view
+        view
+      end
+    }, __FILE__, __LINE__
+  end
+  
+  attr_reader :controller
+
+  def setup_view
+    @controller = class_controller
+    self.layout = layout_options
+    render
+  end
+  
+  private
+  
+    def class_controller
+      HotCocoaApplication.instance.controller(self.class.controller)
+    end
+  
+    def layout_options
+      options = if self.class.options && self.class.options[:layout]
+        self.class.options[:layout]
+      else
+        DefaultLayoutOptions
+      end
+    end
+
+end
+
+class ApplicationWindow < HotCocoaWindow
+  
+end
+

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/resources/HotCocoa.icns
===================================================================
(Binary files differ)

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/mvc/resources/HotCocoa.icns (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/mvc/resources/HotCocoa.icns)
===================================================================
(Binary files differ)


Property changes on: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/Rakefile
___________________________________________________________________
Added: svn:executable
   + *


Property changes on: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/config/build.yml
___________________________________________________________________
Added: svn:executable
   + *

Modified: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/application.rb
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/application.rb	2009-06-19 22:42:24 UTC (rev 1889)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/application.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -45,4 +45,51 @@
   
 end
 
-Application.new.start
\ No newline at end of file
+Application.new.start=======
+require 'hotcocoa'
+SOURCE_DIR = File.expand_path(File.dirname(__FILE__))
+require SOURCE_DIR + '/nib_controller'
+require SOURCE_DIR + '/custom_view'
+require SOURCE_DIR + '/custom_window'
+
+# Replace the following code with your own hotcocoa code
+
+class Application
+
+  include HotCocoa
+  
+  def start
+    application :name => "HotCocoa: Round Transparent Window" do |app|
+      app.delegate = self
+      # load our nib
+      NibController.new
+    end
+  end
+  
+  # file/open
+  def on_open(menu)
+  end
+  
+  # file/new 
+  def on_new(menu)
+  end
+  
+  # help menu item
+  def on_help(menu)
+  end
+  
+  # This is commented out, so the minimize menu item is disabled
+  #def on_minimize(menu)
+  #end
+  
+  # window/zoom
+  def on_zoom(menu)
+  end
+  
+  # window/bring_all_to_front
+  def on_bring_all_to_front(menu)
+  end
+  
+end
+
+Application.new.start


Property changes on: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/application.rb
___________________________________________________________________
Added: svn:executable
   + *


Property changes on: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/custom_view.rb
___________________________________________________________________
Added: svn:executable
   + *


Property changes on: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/custom_window.rb
___________________________________________________________________
Added: svn:executable
   + *


Property changes on: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/menu.rb
___________________________________________________________________
Added: svn:executable
   + *


Property changes on: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/lib/nib_controller.rb
___________________________________________________________________
Added: svn:executable
   + *

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/resources/HotCocoa.icns (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window/resources/HotCocoa.icns)
===================================================================
(Binary files differ)


Property changes on: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/resources/MainMenu.nib/designable.nib
___________________________________________________________________
Added: svn:executable
   + *

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/resources/MainMenu.nib/keyedobjects.nib (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window/resources/MainMenu.nib/keyedobjects.nib)
===================================================================
(Binary files differ)

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/resources/circle.tif (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window/resources/circle.tif)
===================================================================
(Binary files differ)

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window/resources/pentagram.tif (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window/resources/pentagram.tif)
===================================================================
(Binary files differ)

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/Rakefile
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/Rakefile	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/Rakefile	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,4 +0,0 @@
-require 'hotcocoa/application_builder'
-require 'hotcocoa/standard_rake_tasks'
-
-task :default => [:run]
\ No newline at end of file

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/Rakefile (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/Rakefile)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/Rakefile	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/Rakefile	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,4 @@
+require 'hotcocoa/application_builder'
+require 'hotcocoa/standard_rake_tasks'
+
+task :default => [:run]
\ No newline at end of file

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/config/build.yml
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/config/build.yml	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/config/build.yml	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,8 +0,0 @@
-name: Round Transparent Window
-load: lib/application.rb
-version: "1.0"
-icon: resources/HotCocoa.icns
-resources:
-  - resources/**/*.*
-sources: 
-  - lib/**/*.rb

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/config/build.yml (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/config/build.yml)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/config/build.yml	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/config/build.yml	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,8 @@
+name: Round Transparent Window
+load: lib/application.rb
+version: "1.0"
+icon: resources/HotCocoa.icns
+resources:
+  - resources/**/*.*
+sources: 
+  - lib/**/*.rb

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/application.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/application.rb	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/application.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,75 +0,0 @@
-require 'hotcocoa'
-SOURCE_DIR = File.expand_path(File.dirname(__FILE__))
-require SOURCE_DIR + '/custom_view_behaviors'
-require SOURCE_DIR + '/custom_window_behaviors'
-
-class Application
-  include HotCocoa
-  
-  def start
-    application :name => "HotCocoa: Round Transparent Window" do |app|
-      app.delegate = self
-      @main_window = window :frame => [434, 297, 250, 250],
-                            :title => "The NSBorderlessWindowMask style makes this title bar go away",
-                            :style => [:borderless] do |win|
-        win.setBackgroundColor(color(:name => 'clear'))
-        # This next line pulls the window up to the front on top of other system windows.  This is how the Clock app behaves;
-        # generally you wouldn't do this for windows unless you really wanted them to float above everything.
-        win.level = NSStatusWindowLevel
-        # Let's start with no transparency for all drawing into the window
-        win.alphaValue = 1.0
-        # but let's turn off opaqueness so that we can see through the parts of the window that we're not drawing into
-        win.opaque = false
-        # and while we're at it, make sure the window has a shadow, which will automatically be the shape of our custom content.
-        win.hasShadow = true
-        # We need to extend the window to add support for mouse dragging
-        win.extend(CustomWindowBehaviors)
-        # and we need to extend the window's content view to override the drawRect method
-        win.contentView.extend(CustomViewBehaviors)
-        win << slider_layout("Move slider to change transparency") do |slider|
-            # set the window's alpha value from 0.0-1.0
-            win.alphaValue = slider.floatValue
-            # go ahead and tell the window to redraw things, which has the effect of calling win.contentView's -drawRect: routine
-            win.display
-        end
-      end
-    end
-  end
-  
-  def slider_layout(label, &block)
-    layout_view(:frame => [0, 0, 0, 90], :layout => {:expand => [:height, :width], :start => false}) do |view|
-      view << label(:text => label, :layout => {:align => :center})
-      s = slider :min => 0, :max => 1.0, :on_action => block, :layout => {:expand => :width, :align => :top}
-      s.floatValue = 1.0
-      s.frameSize  = [0, 24]
-      view << s
-    end
-  end
-  
-  # file/open
-  def on_open(menu)
-  end
-  
-  # file/new 
-  def on_new(menu)
-  end
-  
-  # help menu item
-  def on_help(menu)
-  end
-  
-  # This is commented out, so the minimize menu item is disabled
-  #def on_minimize(menu)
-  #end
-  
-  # window/zoom
-  def on_zoom(menu)
-  end
-  
-  # window/bring_all_to_front
-  def on_bring_all_to_front(menu)
-  end
-  
-end
-
-Application.new.start

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/application.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/application.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/application.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/application.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,75 @@
+require 'hotcocoa'
+SOURCE_DIR = File.expand_path(File.dirname(__FILE__))
+require SOURCE_DIR + '/custom_view_behaviors'
+require SOURCE_DIR + '/custom_window_behaviors'
+
+class Application
+  include HotCocoa
+  
+  def start
+    application :name => "HotCocoa: Round Transparent Window" do |app|
+      app.delegate = self
+      @main_window = window :frame => [434, 297, 250, 250],
+                            :title => "The NSBorderlessWindowMask style makes this title bar go away",
+                            :style => [:borderless] do |win|
+        win.setBackgroundColor(color(:name => 'clear'))
+        # This next line pulls the window up to the front on top of other system windows.  This is how the Clock app behaves;
+        # generally you wouldn't do this for windows unless you really wanted them to float above everything.
+        win.level = NSStatusWindowLevel
+        # Let's start with no transparency for all drawing into the window
+        win.alphaValue = 1.0
+        # but let's turn off opaqueness so that we can see through the parts of the window that we're not drawing into
+        win.opaque = false
+        # and while we're at it, make sure the window has a shadow, which will automatically be the shape of our custom content.
+        win.hasShadow = true
+        # We need to extend the window to add support for mouse dragging
+        win.extend(CustomWindowBehaviors)
+        # and we need to extend the window's content view to override the drawRect method
+        win.contentView.extend(CustomViewBehaviors)
+        win << slider_layout("Move slider to change transparency") do |slider|
+            # set the window's alpha value from 0.0-1.0
+            win.alphaValue = slider.floatValue
+            # go ahead and tell the window to redraw things, which has the effect of calling win.contentView's -drawRect: routine
+            win.display
+        end
+      end
+    end
+  end
+  
+  def slider_layout(label, &block)
+    layout_view(:frame => [0, 0, 0, 90], :layout => {:expand => [:height, :width], :start => false}) do |view|
+      view << label(:text => label, :layout => {:align => :center})
+      s = slider :min => 0, :max => 1.0, :on_action => block, :layout => {:expand => :width, :align => :top}
+      s.floatValue = 1.0
+      s.frameSize  = [0, 24]
+      view << s
+    end
+  end
+  
+  # file/open
+  def on_open(menu)
+  end
+  
+  # file/new 
+  def on_new(menu)
+  end
+  
+  # help menu item
+  def on_help(menu)
+  end
+  
+  # This is commented out, so the minimize menu item is disabled
+  #def on_minimize(menu)
+  #end
+  
+  # window/zoom
+  def on_zoom(menu)
+  end
+  
+  # window/bring_all_to_front
+  def on_bring_all_to_front(menu)
+  end
+  
+end
+
+Application.new.start

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_view_behaviors.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_view_behaviors.rb	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_view_behaviors.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,40 +0,0 @@
-# Description: 	This is the header file for the CustomView class, which handles the drawing of the window content.
-#               we use a circle graphic and a pentagram graphic, switching between the two depending upon the 
-#               window's transparency.
-
-module CustomViewBehaviors
-
-  def set_images
-    @circle_image = NSImage.imageNamed("circle")
-    @penta_image  = NSImage.imageNamed("pentagram")
-  end
-  
-  def redraw
-    needsDisplay = true
-  end
-  
-  # When it's time to draw, this method is called.
-  # This view is inside the window, the window's opaqueness has been turned off,
-  # and the window's styleMask has been set to NSBorderlessWindowMask on creation,
-  # so what this view draws *is all the user sees of the window*.  The first two lines below
-  # then fill things with "clear" color, so that any images we draw are the custom shape of the window,
-  # for all practical purposes.  Furthermore, if the window's alphaValue is <1.0, drawing will use
-  # transparency.
-  def drawRect(rect)
-    set_images unless @circle_image
-    # erase whatever graphics were there before with clear
-    NSColor.clearColor.set
-    NSRectFill(frame)   
-    # if our window transparency is >0.7, we decide to draw the circle.  Otherwise, draw the pentagram.
-    # If we called -disolveToPoint:fraction: instead of -compositeToPoint:operation:, then the image
-    # could itself be drawn with less than full opaqueness, but since we're already setting the alpha
-    # on the entire window, we don't bother with that here.
-    image_to_draw = (window.alphaValue > 0.7) ? @circle_image : @penta_image
-    # same as `image_to_draw.compositeToPoint([0,0], operation:NSCompositeSourceOver)`
-    # apart that compositeToPoint usage is now discouraged as the behavior it provides is not recommended 
-    # for general use
-    image_to_draw.drawAtPoint([0,0], fromRect:frame, operation:NSCompositeSourceOver, fraction:1.0)
-    window.invalidateShadow
-  end
-  
-end
\ No newline at end of file

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_view_behaviors.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_view_behaviors.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_view_behaviors.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_view_behaviors.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,40 @@
+# Description: 	This is the header file for the CustomView class, which handles the drawing of the window content.
+#               we use a circle graphic and a pentagram graphic, switching between the two depending upon the 
+#               window's transparency.
+
+module CustomViewBehaviors
+
+  def set_images
+    @circle_image = NSImage.imageNamed("circle")
+    @penta_image  = NSImage.imageNamed("pentagram")
+  end
+  
+  def redraw
+    needsDisplay = true
+  end
+  
+  # When it's time to draw, this method is called.
+  # This view is inside the window, the window's opaqueness has been turned off,
+  # and the window's styleMask has been set to NSBorderlessWindowMask on creation,
+  # so what this view draws *is all the user sees of the window*.  The first two lines below
+  # then fill things with "clear" color, so that any images we draw are the custom shape of the window,
+  # for all practical purposes.  Furthermore, if the window's alphaValue is <1.0, drawing will use
+  # transparency.
+  def drawRect(rect)
+    set_images unless @circle_image
+    # erase whatever graphics were there before with clear
+    NSColor.clearColor.set
+    NSRectFill(frame)   
+    # if our window transparency is >0.7, we decide to draw the circle.  Otherwise, draw the pentagram.
+    # If we called -disolveToPoint:fraction: instead of -compositeToPoint:operation:, then the image
+    # could itself be drawn with less than full opaqueness, but since we're already setting the alpha
+    # on the entire window, we don't bother with that here.
+    image_to_draw = (window.alphaValue > 0.7) ? @circle_image : @penta_image
+    # same as `image_to_draw.compositeToPoint([0,0], operation:NSCompositeSourceOver)`
+    # apart that compositeToPoint usage is now discouraged as the behavior it provides is not recommended 
+    # for general use
+    image_to_draw.drawAtPoint([0,0], fromRect:frame, operation:NSCompositeSourceOver, fraction:1.0)
+    window.invalidateShadow
+  end
+  
+end
\ No newline at end of file

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_window_behaviors.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_window_behaviors.rb	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_window_behaviors.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,67 +0,0 @@
-# Description:  This is where we extend the windows behaviors to have a custom shape and be transparent.  
-#               We also override the #mouseDown and #mouseDragged methods, to allow for dragging the window
-#               by clicking on its content area (since it doesn't have a title bar to drag).
-
-module CustomWindowBehaviors
-  attr_accessor :initialLocation
-
-  # We are extending initWithContentRect which is called by #window
-  def initWithContentRect(contentRect, styleMask:aStyle, backing:bufferingType, defer:flag)
-    # Call NSWindow's version of this function, but pass in the all-important value of NSBorderlessWindowMask
-    #for the styleMask so that the window doesn't have a title bar
-    result = super(contentRect, NSBorderlessWindowMask, NSBackingStoreBuffered, false)
-    # Set the background color to clear so that (along with the setOpaque call below) we can see through the parts
-    # of the window that we're not drawing into
-    result.backgroundColor = color(:name => 'clear')
-    # This next line pulls the window up to the front on top of other system windows.  This is how the Clock app behaves;
-    # generally you wouldn't do this for windows unless you really wanted them to float above everything.
-    result.level = NSStatusWindowLevel
-    # Let's start with no transparency for all drawing into the window
-    result.alphaValue = 1.0
-    # but let's turn off opaqueness so that we can see through the parts of the window that we're not drawing into
-    result.opaque = false
-    # and while we're at it, make sure the window has a shadow, which will automatically be the shape of our custom content.
-    result.hasShadow = true
-    result
-  end
-
-  # Custom windows that use the NSBorderlessWindowMask can't become key by default.  Therefore, controls in such windows
-  # won't ever be enabled by default. Thus, we override this method to change that.
-  def canBecomeKeyWindow
-    true
-  end
-
-  # Once the user starts dragging the mouse, we move the window with it. We do this because the window has no title
-  # bar for the user to drag (so we have to implement dragging ourselves)
-  # (overriding original method)
-  def mouseDragged(theEvent)
-    screen_frame = NSScreen.mainScreen.frame
-    window_frame = self.frame
-    current_location = self.convertBaseToScreen(self.mouseLocationOutsideOfEventStream)
-
-    # grab the current global mouse location; we could just as easily get the mouse location 
-    # in the same way as we do in -mouseDown:
-    new_origin = NSPoint.new((current_location.x - @initialLocation.x), (current_location.y - @initialLocation.y))
-
-    # Don't let the window get dragged up under the menu bar
-    if((new_origin.y + window_frame.size.height) > (screen_frame.origin.y + screen_frame.size.height))
-      new_origin.y = screen_frame.origin.y + (screen_frame.size.height - window_frame.size.height)
-    end
-
-    # go ahead and move the window to the new location
-    self.frameOrigin = new_origin
-  end
-
-  # We start tracking the a drag operation here when the user first clicks the mouse,
-  # to establish the initial location.
-  def mouseDown(theEvent)
-    window_frame = frame
-    
-    # grab the mouse location in global coordinates
-    @initialLocation = convertBaseToScreen(theEvent.locationInWindow)
-    @initialLocation.x -= window_frame.origin.x
-    @initialLocation.y -= window_frame.origin.y
-  end
-  
-  
-end
\ No newline at end of file

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_window_behaviors.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_window_behaviors.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_window_behaviors.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/custom_window_behaviors.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,67 @@
+# Description:  This is where we extend the windows behaviors to have a custom shape and be transparent.  
+#               We also override the #mouseDown and #mouseDragged methods, to allow for dragging the window
+#               by clicking on its content area (since it doesn't have a title bar to drag).
+
+module CustomWindowBehaviors
+  attr_accessor :initialLocation
+
+  # We are extending initWithContentRect which is called by #window
+  def initWithContentRect(contentRect, styleMask:aStyle, backing:bufferingType, defer:flag)
+    # Call NSWindow's version of this function, but pass in the all-important value of NSBorderlessWindowMask
+    #for the styleMask so that the window doesn't have a title bar
+    result = super(contentRect, NSBorderlessWindowMask, NSBackingStoreBuffered, false)
+    # Set the background color to clear so that (along with the setOpaque call below) we can see through the parts
+    # of the window that we're not drawing into
+    result.backgroundColor = color(:name => 'clear')
+    # This next line pulls the window up to the front on top of other system windows.  This is how the Clock app behaves;
+    # generally you wouldn't do this for windows unless you really wanted them to float above everything.
+    result.level = NSStatusWindowLevel
+    # Let's start with no transparency for all drawing into the window
+    result.alphaValue = 1.0
+    # but let's turn off opaqueness so that we can see through the parts of the window that we're not drawing into
+    result.opaque = false
+    # and while we're at it, make sure the window has a shadow, which will automatically be the shape of our custom content.
+    result.hasShadow = true
+    result
+  end
+
+  # Custom windows that use the NSBorderlessWindowMask can't become key by default.  Therefore, controls in such windows
+  # won't ever be enabled by default. Thus, we override this method to change that.
+  def canBecomeKeyWindow
+    true
+  end
+
+  # Once the user starts dragging the mouse, we move the window with it. We do this because the window has no title
+  # bar for the user to drag (so we have to implement dragging ourselves)
+  # (overriding original method)
+  def mouseDragged(theEvent)
+    screen_frame = NSScreen.mainScreen.frame
+    window_frame = self.frame
+    current_location = self.convertBaseToScreen(self.mouseLocationOutsideOfEventStream)
+
+    # grab the current global mouse location; we could just as easily get the mouse location 
+    # in the same way as we do in -mouseDown:
+    new_origin = NSPoint.new((current_location.x - @initialLocation.x), (current_location.y - @initialLocation.y))
+
+    # Don't let the window get dragged up under the menu bar
+    if((new_origin.y + window_frame.size.height) > (screen_frame.origin.y + screen_frame.size.height))
+      new_origin.y = screen_frame.origin.y + (screen_frame.size.height - window_frame.size.height)
+    end
+
+    # go ahead and move the window to the new location
+    self.frameOrigin = new_origin
+  end
+
+  # We start tracking the a drag operation here when the user first clicks the mouse,
+  # to establish the initial location.
+  def mouseDown(theEvent)
+    window_frame = frame
+    
+    # grab the mouse location in global coordinates
+    @initialLocation = convertBaseToScreen(theEvent.locationInWindow)
+    @initialLocation.x -= window_frame.origin.x
+    @initialLocation.y -= window_frame.origin.y
+  end
+  
+  
+end
\ No newline at end of file

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/menu.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/menu.rb	2009-06-19 21:09:10 UTC (rev 1886)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/menu.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -1,32 +0,0 @@
-module HotCocoa
-  def application_menu
-    menu do |main|
-      main.submenu :apple do |apple|
-        apple.item :about, :title => "About #{NSApp.name}"
-        apple.separator
-        apple.item :preferences, :key => ","
-        apple.separator
-        apple.submenu :services
-        apple.separator
-        apple.item :hide, :title => "Hide #{NSApp.name}", :key => "h"
-        apple.item :hide_others, :title => "Hide Others", :key => "h", :modifiers => [:command, :alt]
-        apple.item :show_all, :title => "Show All"
-        apple.separator
-        apple.item :quit, :title => "Quit #{NSApp.name}", :key => "q"
-      end
-      main.submenu :file do |file|
-        file.item :new, :key => "n"
-        file.item :open, :key => "o"
-      end
-      main.submenu :window do |win|
-        win.item :minimize, :key => "m"
-        win.item :zoom
-        win.separator
-        win.item :bring_all_to_front, :title => "Bring All to Front", :key => "o"
-      end
-      main.submenu :help do |help|
-        help.item :help, :title => "#{NSApp.name} Help"
-      end
-    end
-  end
-end

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/menu.rb (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/menu.rb)
===================================================================
--- MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/menu.rb	                        (rev 0)
+++ MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/lib/menu.rb	2009-06-19 22:43:08 UTC (rev 1890)
@@ -0,0 +1,32 @@
+module HotCocoa
+  def application_menu
+    menu do |main|
+      main.submenu :apple do |apple|
+        apple.item :about, :title => "About #{NSApp.name}"
+        apple.separator
+        apple.item :preferences, :key => ","
+        apple.separator
+        apple.submenu :services
+        apple.separator
+        apple.item :hide, :title => "Hide #{NSApp.name}", :key => "h"
+        apple.item :hide_others, :title => "Hide Others", :key => "h", :modifiers => [:command, :alt]
+        apple.item :show_all, :title => "Show All"
+        apple.separator
+        apple.item :quit, :title => "Quit #{NSApp.name}", :key => "q"
+      end
+      main.submenu :file do |file|
+        file.item :new, :key => "n"
+        file.item :open, :key => "o"
+      end
+      main.submenu :window do |win|
+        win.item :minimize, :key => "m"
+        win.item :zoom
+        win.separator
+        win.item :bring_all_to_front, :title => "Bring All to Front", :key => "o"
+      end
+      main.submenu :help do |help|
+        help.item :help, :title => "#{NSApp.name} Help"
+      end
+    end
+  end
+end

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/HotCocoa.icns
===================================================================
(Binary files differ)

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/HotCocoa.icns (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/HotCocoa.icns)
===================================================================
(Binary files differ)

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/circle.tif
===================================================================
(Binary files differ)

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/circle.tif (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/circle.tif)
===================================================================
(Binary files differ)

Deleted: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/pentagram.tif
===================================================================
(Binary files differ)

Copied: MacRuby/branches/experimental/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/pentagram.tif (from rev 1886, MacRuby/trunk/sample-macruby/HotCocoa/round_transparent_window_no_nibs/resources/pentagram.tif)
===================================================================
(Binary files differ)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090619/f2be101f/attachment-0001.html>


More information about the macruby-changes mailing list