ruby-****@sourc*****
ruby-****@sourc*****
2013年 4月 3日 (水) 14:51:58 JST
------------------------- REMOTE_ADDR = 70.49.48.128 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-dancr-rbcatut-intro ------------------------- @@ -35,6 +35,7 @@ * 12.3.0.1.2.1 ((<A Real Life Example With Runing Cairo Code|tut-gtk2-dancr-rbcatut-intro#A Real Life Example With Runing Cairo Code>)) * 12.3.0.2 ((<Running Cairo Code From Non-Gtk Ruby Environment|tut-gtk2-dancr-rbcatut-intro#Running Cairo Code From Non-Gtk Ruby Environment>)) + * 12.3.0.2.1 ((<Pure Ruby Cairo Library - rcairo API|tut-gtk2-dancr-rbcatut-intro#Pure Ruby Cairo Library - rcairo API>)) * 12.3.0.3 ((<Hiki Gtk With Cairo Module Download File|tut-gtk2-dancr-rbcatut-intro#Hiki Gtk With Cairo Module Download File>)) @@ -254,6 +255,13 @@ One reason I separated this paragraph from the rest of the tutorial is to stress the difference between using 'the into Ruby Gtk integrated Cairo Library' from the original pure (you can say stand-alone) Cairo Library. The first, integrated one, is available to Gtk programmers automatically, i.e. requiring Gtk module is all that is needed. But, if you want the full featured Cairo library, you need to((*require 'cairo'*)) yourself. Indeed, you can do that even if you are not running Gtk at all, that is you do not need to((*require 'gtk2',*)) and obviously, without this module you also can not run the gtk-main loop. +:Pure Ruby Cairo Library - rcairo API + + (12.3.0.2.1){{br}} + You can check the API for the Pure Ruby Cairo Library at ((<rcairo|URL:http://cairo.rubyforge.org/doc/en/>)). + +{{br}} The examples in ((<the official Cairo Tutorial|URL:http://www.cairographics.org/tutorial/>)) run outside any particular GUI system, hence, we should not, and we do not, have any trouble running them in Ruby directly without the Gtk. But, since this is the Gtk Tutorial, which, as anybody who read most of it before any Cairo features even came up, knows that Cairo should be part of the Gtk. Unfortunately, for those of us who have been struggling to learn or master Gtk for a while, encountering Cairo outside our GUI, it may seem odd, why would anyone consider running 2D graphic programs from a text based terminal. Why would I even try to look for solutions outside my GUI environment which as I could see includes Cairo Library. It never crossed my mind, that by requiring 'cairo' module, I'd gain power of pure Cairo beyond that available in my GUI! The fact is, that's exactly what you should do, to translate and run the official Cairo Tutorial examples in Ruby. Hence, you should forget, about Ruby's Gdk::Drawable#create_cairo_context, and resort to plain old Cairo ways of creating it via: