[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-gtk2-appdx-clrtheory

Zurück zum Archiv-Index

ruby-****@sourc***** ruby-****@sourc*****
2013年 4月 23日 (火) 05:45:52 JST


-------------------------
REMOTE_ADDR = 70.49.50.179
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-appdx-clrtheory
-------------------------
@@ -390,7 +390,7 @@
 
 
 
-((*display-color-shades.rb*))
+    ((*display-color-shades.rb*))
 
 
 
@@ -400,98 +400,98 @@
 
 
     
-     #!/usr/bin/env ruby
-     # Testing ColorBrightnessMgmt module from file 'color-brightness-mgmt.rb'
-     
-     $: << '~/work/HikiLib'
-     require 'hiki2-gtk-w-cairo.rb'
-     include HikiGtk
-     
-     class DrwAreaToImg < CairoWindow
-       include CairoHelper
-     
-       def initialize(title=nil, n=4)
-         super(title)
-         @number_of_shades_on_one_side=n
-         @unit = 1.0
-         @step = @unit/n
-         @color_box_w = @unit * 0.65
-         @color_box_h = @unit / 3
-         @hgap = (@unit - @color_box_w) / 7
-         @vgap = 3*@hgap
-         # @cr ... instance variable is initialized only after {{ draw }} method is called.
-       end
-     
-       def draw(cr, drawing_area)
-         # NOTE the peculiarity here, cairo context instance variable can be
-         # initialized, only after 'draw' method is called with the context
-         # parameter (cr).
-         @cr = cr
-         cr.scale(100, 100)	# (100, 100)	# Examples are in 1x1 coordinate space
-         cr.line_width = 0.01
-         # Display the color grid.
-         base_color_names.each_with_index do |color, line| 
-           display_line_of_shades_for_color(color, line)
+         #!/usr/bin/env ruby
+         # Testing ColorBrightnessMgmt module from file 'color-brightness-mgmt.rb'
+         
+         $: << '~/work/HikiLib'
+         require 'hiki2-gtk-w-cairo.rb'
+         include HikiGtk
+         
+         class DrwAreaToImg < CairoWindow
+           include CairoHelper
+         
+           def initialize(title=nil, n=4)
+             super(title)
+             @number_of_shades_on_one_side=n
+             @unit = 1.0
+             @step = @unit/n
+             @color_box_w = @unit * 0.65
+             @color_box_h = @unit / 3
+             @hgap = (@unit - @color_box_w) / 7
+             @vgap = 3*@hgap
+             # @cr ... instance variable is initialized only after {{ draw }} method is called.
+           end
+         
+           def draw(cr, drawing_area)
+             # NOTE the peculiarity here, cairo context instance variable can be
+             # initialized, only after 'draw' method is called with the context
+             # parameter (cr).
+             @cr = cr
+             cr.scale(100, 100)	# (100, 100)	# Examples are in 1x1 coordinate space
+             cr.line_width = 0.01
+             # Display the color grid.
+             base_color_names.each_with_index do |color, line| 
+               display_line_of_shades_for_color(color, line)
+             end
+           end
+         
+           def display_line_of_shades_for_color(color, line)
+             n = @number_of_shades_on_one_side
+             cr = @cr	# @cr ... is initialized only after {{ draw }} method is called.
+             w = @color_box_w
+             h = @color_box_h
+             nx = x = y = @hgap
+             ny = line * (@vgap + h) + @hgap
+         
+             0.step(2*@unit, @step).each do |v|
+               brightness = v - @unit
+               cr.save			# Save original cairo context environment.
+               cr.translate(nx, ny)	# Change all coordinates in cr for the following step pass. 
+         
+               cr.set_source_rgba(mk_cairo_acolor(color, brightness))
+               draw_closed_paths(cr, [x, y], [w, y], [w, h], [x, h], :c)
+               cr.fill
+               cr.set_source_rgba(mk_cairo_acolor(:black)) # Change font colour for defining colour code.
+               draw_closed_paths(cr, [x, y], [w, y], [w, h], [x, h], :c)
+               cr.stroke
+               if v == 0		# Write color name only into the brightest colour-xox.
+                 cr.set_font_size(0.1)
+                 cr.set_source_rgba(mk_cairo_acolor(:black))
+                 cr.move_to(x+ @ hgap, y+4*@hgap) 
+                 cr.show_text(color.to_s)
+               end
+               # Display colour code underneath each colour box.
+               color_code = mk_rgb_color(color, brightness).upcase
+               cr.set_font_size(0.15)
+               cr.set_source_rgba(mk_cairo_acolor(brightness==0 ? :red : :black))
+               cr.move_to(@hgap, @vgap + h) 
+               cr.show_text(color_code)
+               cr.restore	# Restore the original cairo context envirionment, preventing
+               			# accumulative effect, when setting coordinates for next 
+               			# color-box {{ see: cr.save & cr.translate(nx, ny) }} above.
+               nx +=  w + 2*@hgap
+             end	# end-step-loop
+           end
+         
+           # Convenience method to dynamicaly size the main Gtk window. Returns window
+           # 'width' and 'height' parameters after window object is created and after users
+           # request for number of colours is taken into account during instatiation process.
+           def get_dimensions
+            [
+               ((@number_of_shades_on_one_side * 2.0 + 1) * (@color_box_w + @vgap) - @vgap) * 100, 
+               ((@color_box_h + @hgap + @vgap) * base_color_names.size - @hgap) * 100
+            ]
+           end
          end
-       end
-     
-       def display_line_of_shades_for_color(color, line)
-         n = @number_of_shades_on_one_side
-         cr = @cr	# @cr ... is initialized only after {{ draw }} method is called.
-         w = @color_box_w
-         h = @color_box_h
-         nx = x = y = @hgap
-         ny = line * (@vgap + h) + @hgap
-     
-         0.step(2*@unit, @step).each do |v|
-           brightness = v - @unit
-           cr.save			# Save original cairo context environment.
-           cr.translate(nx, ny)	# Change all coordinates in cr for the following step pass. 
-     
-           cr.set_source_rgba(mk_cairo_acolor(color, brightness))
-           draw_closed_paths(cr, [x, y], [w, y], [w, h], [x, h], :c)
-           cr.fill
-           cr.set_source_rgba(mk_cairo_acolor(:black)) # Change font colour for defining colour code.
-           draw_closed_paths(cr, [x, y], [w, y], [w, h], [x, h], :c)
-           cr.stroke
-           if v == 0		# Write color name only into the brightest colour-xox.
-             cr.set_font_size(0.1)
-             cr.set_source_rgba(mk_cairo_acolor(:black))
-             cr.move_to(x+ @ hgap, y+4*@hgap) 
-             cr.show_text(color.to_s)
-           end
-           # Display colour code underneath each colour box.
-           color_code = mk_rgb_color(color, brightness).upcase
-           cr.set_font_size(0.15)
-           cr.set_source_rgba(mk_cairo_acolor(brightness==0 ? :red : :black))
-           cr.move_to(@hgap, @vgap + h) 
-           cr.show_text(color_code)
-           cr.restore	# Restore the original cairo context envirionment, preventing
-           			# accumulative effect, when setting coordinates for next 
-           			# color-box {{ see: cr.save & cr.translate(nx, ny) }} above.
-           nx +=  w + 2*@hgap
-         end	# end-step-loop
-       end
-     
-       # Convenience method to dynamicaly size the main Gtk window. Returns window
-       # 'width' and 'height' parameters after window object is created and after users
-       # request for number of colours is taken into account during instatiation process.
-       def get_dimensions
-        [
-           ((@number_of_shades_on_one_side * 2.0 + 1) * (@color_box_w + @vgap) - @vgap) * 100, 
-           ((@color_box_h + @hgap + @vgap) * base_color_names.size - @hgap) * 100
-        ]
-       end
-     end
-     
-     # Allow setting the number of colour shades from the command line.
-     num_of_shades = ARGV.size == 1 ? ARGV[0].to_f : 4
-     
-     title = "Display a colour grid"
-     w=DrwAreaToImg.new(title, num_of_shades)
-     w.set_size_request(*w.get_dimensions)
-     w.show_all
-     Gtk.main
+         
+         # Allow setting the number of colour shades from the command line.
+         num_of_shades = ARGV.size == 1 ? ARGV[0].to_f : 4
+         
+         title = "Display a colour grid"
+         w=DrwAreaToImg.new(title, num_of_shades)
+         w.set_size_request(*w.get_dimensions)
+         w.show_all
+         Gtk.main
 
 
 




ruby-gnome2-cvs メーリングリストの案内
Zurück zum Archiv-Index