[macruby-changes] [2341] MacRuby/trunk/lib/hotcocoa
source_changes at macosforge.org
source_changes at macosforge.org
Sun Aug 16 22:01:21 PDT 2009
Revision: 2341
http://trac.macosforge.org/projects/ruby/changeset/2341
Author: mattaimonetti at gmail.com
Date: 2009-08-16 22:01:19 -0700 (Sun, 16 Aug 2009)
Log Message:
-----------
[HotCocoa Graphics] added an accessor for the canvas context (so a developer can use CG methods on it directly) and default filename so we can generate CGimages without passing a filename.
Modified Paths:
--------------
MacRuby/trunk/lib/hotcocoa/graphics/canvas.rb
MacRuby/trunk/lib/hotcocoa/graphics.rb
Modified: MacRuby/trunk/lib/hotcocoa/graphics/canvas.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa/graphics/canvas.rb 2009-08-17 04:13:27 UTC (rev 2340)
+++ MacRuby/trunk/lib/hotcocoa/graphics/canvas.rb 2009-08-17 05:01:19 UTC (rev 2341)
@@ -11,9 +11,13 @@
#
# Author:: James Reynolds (mailto:drtoast at drtoast.com)
# Copyright:: Copyright (c) 2008 James Reynolds
-# License:: Distributes under the same terms as Ruby
+# License:: Distributes under the same terms as Ruby
+# In Quartz 2D, the canvas is often referred as the "page".
+# Overview of the underlying page concept available at:
+# http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_overview/dq_overview.html#//apple_ref/doc/uid/TP30001066-CH202-TPXREF101
+
module HotCocoa::Graphics
# drawing destination for writing a PDF, PNG, GIF, JPG, or TIF file
@@ -42,8 +46,12 @@
DefaultOptions = {:quality => 0.8, :width => 400, :height => 400}
- attr_accessor :width, :height
+ attr_accessor :width, :height
+ # We make the context available so developers can directly use underlying CG methods
+ # on objects created by this wrapper
+ attr_reader :ctx
+
class << self
def for_rendering(options={}, &block)
options[:type] = :render
@@ -83,7 +91,7 @@
@width = options[:width]
@height = options[:height]
- @output = options[:filename]
+ @output = options[:filename] || 'test'
@stacksize = 0
@colorspace = CGColorSpaceCreateDeviceRGB() # => CGColorSpaceRef
@autoclosepath = false
@@ -131,7 +139,7 @@
quality(options[:quality]) # set the compression default
push # save the pristine default default graphics state (retrieved by calling "reset")
push # create a new graphics state for the user to mess up
- if block
+ if block_given?
case block.arity
when 0
send(:instance_eval, &block)
Modified: MacRuby/trunk/lib/hotcocoa/graphics.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa/graphics.rb 2009-08-17 04:13:27 UTC (rev 2340)
+++ MacRuby/trunk/lib/hotcocoa/graphics.rb 2009-08-17 05:01:19 UTC (rev 2341)
@@ -11,8 +11,13 @@
#
# Author:: James Reynolds (mailto:drtoast at drtoast.com)
# Copyright:: Copyright (c) 2008 James Reynolds
-# License:: Distributes under the same terms as Ruby
+# License:: Distributes under the same terms as Ruby
+# More information about Quartz 2D is available on the Apple's website:
+# http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_overview/dq_overview.html#//apple_ref/doc/uid/TP30001066-CH202-TPXREF101
+
+
+
module HotCocoa;end # needed in case this is required without hotcocoa
framework 'Cocoa'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090816/b21119c8/attachment.html>
More information about the macruby-changes
mailing list