[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-gtk2-dancr-rbcatut

Back to archive index

ruby-****@sourc***** ruby-****@sourc*****
2013年 3月 23日 (土) 15:01:51 JST


-------------------------
REMOTE_ADDR = 70.49.48.128
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-dancr-rbcatut
-------------------------
@@ -114,18 +114,17 @@
     Indeed, to create the template we are going to use the code shown in the above 'minimal-rb-cr.rb'program. Eventually, the new template will act as wrapper code, with a stub method called((*draw(cr, drawing_area).*)) Basically, the template is an executable program in which you create a new class inheriting directly from the CairoWindow, and overriding its((*draw*))method. This 'draw' method is where you will place your cairo code. Lets look at the empty ready to use template: 
 
      #!/usr/bin/env ruby
-
      $: << '~/work/HikiLib'
      require 'hiki2-gtk-w-cairo.rb'
      include HikiGtk
-
      class MyCairoCodeClass < CairoWindow		# Your own CairoWindow class
      	def draw(cr, drawing_area)			# Override the draw method
      	  width, height = drawing_area.window.size	# You will likely need w, h
-     	        o o o					# Your code comes here
+     	  # Your code comes here:			#
+     	  # ---------------------			#
+     	        o o o					# Your code comes here.
      	end						#					
      end						#
-
      window=MyCairoCodeClass.new	# Replace 'CairoWindow' with your new class name.
      					# Optionally, supply the your name to the constructor. 
      window.show_all
@@ -136,32 +135,29 @@
     :A Real Life Example With Runing Cairo Code   
 
         (12.3.0.1.2.2)    {{image_right("1203-smiley-face-s1.png")}}
-        In Michael Urman's Cairo tutorial called ((<Cairo Tutorial for PyGTK Programmers|URL:http://www.tortall.net/mu/wiki/PyGTKCairoTutorial>)), where Nichael also creates a similar Gtk/Cairo framework as is ours, you can find a neat piece of Python cairo code generating a((*smiley face.*)) I translated his smiley face Python code to Ruby, and run it in our Ruby Gtk/Cairo wrapper.
+        In Michael Urman's Cairo tutorial called ((<Cairo Tutorial for PyGTK Programmers|URL:http://www.tortall.net/mu/wiki/PyGTKCairoTutorial>)), where Michael creates a similar Gtk/Cairo framework as is ours, you can find a neat piece of Python cairo code generating a((*smiley face.*)) I translated his smiley face Python code to Ruby, and run it in our Ruby Gtk/Cairo wrapper.
 
         ((*smiley-face.rb*))
 
          #!/usr/bin/env ruby
-         
          $: << '~/work/HikiLib'
          require 'hiki2-gtk-w-cairo.rb'
          include HikiGtk
          
          class SmileyFace < CairoWindow
-         
            def draw(cr, drawing_area)
          
              width, height = drawing_area.window.size
-         
+
+     	     # Your code comes here:
+             # ---------------------
              # Fill the background with a colour of your choice
              cr.set_source_rgb(0.5, 0.5, 0.9)
              cr.rectangle(0, 0, width, height)
              cr.fill()
-         
              # draw a rectangle
              cr.set_source_rgb(1.0, 1.0, 1.0)
              cr.rectangle(10, 10, width - 20, height - 20)
              cr.fill()
-         
              # and a circle
              cr.set_source_rgb(1.0, 0.0, 0.0)
              radius = [width, height].min
@@ -169,7 +166,3 @@
              cr.stroke()
              cr.arc(width / 2.0, height / 2.0, radius / 3.0 - 10, Math::PI / 3, 2 * Math::PI / 3)
              cr.stroke()
-         
              # draw lines
              cr.set_source_rgb(0.0, 0.0, 0.8)
              cr.move_to(width / 3.0, height / 3.0)
@@ -177,6 +173,3 @@
              cr.move_to(2 * width / 3.0, height / 3.0)
              cr.rel_line_to(0, height / 6.0)
              cr.stroke()
+             # ---------------------
            end
          end
          




ruby-gnome2-cvs メーリングリストの案内
Back to archive index