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

Zurück zum Archiv-Index

ruby-****@sourc***** ruby-****@sourc*****
2013年 3月 22日 (金) 06:38:31 JST


-------------------------
REMOTE_ADDR = 70.49.48.128
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-dancr-rbcatut
-------------------------
@@ -19,6 +19,75 @@
 
 
 
+{{br}}
+
+== Cairo's Drawing Model
+(12.3.1){{br}}
+
+In order to explain the operations used by cairo, we first delve into a model of how cairo models drawing. There are only a few concepts involved, which are then applied over and over by the different methods. First I'll describe the nouns: destination, source, mask, path, and context. After that I'll describe the verbs which offer ways to manipulate the nouns and draw the graphics you wish to create.
+
+
+
+
+{{br}}
+
+=== Nouns
+(12.3.1.1){{br}}
+
+Cairo's nouns are somewhat abstract. To make them concrete I'm including diagrams that depict how they interact. The first three nouns are the three layers in the diagrams you see in this section. The fourth noun, the path, is drawn on the middle layer when it is relevant. The final noun, the context, isn't shown.
+
+
+
+:Destination
+    (12.3.1.1.1){{br}}
+
+    {{image_right("123-01-destination.png")}}
+
+    The destination is the surface on which you're drawing. It may be tied to an array of pixels like in this tutorial, or it might be tied to a SVG or PDF file, or something else. This surface collects the elements of your graphic as you apply them, allowing you to build up a complex work as though painting on a canvas.
+
+
+:Source
+    (12.3.1.1.2){{br}}
+
+    {{image_right("123-02-source.png")}}
+
+    The ((<source|URL:http://www.cairographics.org/manual/cairo-surfaces.html>)) is the "paint" you're about to work with. I show this as it is用lain black for several examples傭ut translucent to show lower layers. Unlike real paint, it doesn't have to be a single color; it can be a pattern or even a previously created destination surface (see: ((<How do I paint from one surface to another?|URL:http://cairographics.org/FAQ/#paint_from_a_surface>))). Also unlike real paint it can contain transparency information葉he Alpha channel.
+
+
+
+
+
+
+
+:Mask
+    (12.3.1.1.3){{br}}
+
+    {{image_right("123-03-mask.png")}}
+
+    The mask is the most important piece: it controls where you apply the source to the destination. I will show it as a yellow layer with holes where it lets the source through. When you apply a drawing verb, it's like you stamp the source to the destination. Anywhere the mask allows, the source is copied. Anywhere the mask disallows, nothing happens.
+
+
+:Path
+    (12.3.1.1.4){{br}}
+
+    The path is somewhere between part of the mask and part of the context. I will show it as thin green lines on the mask layer. It is manipulated by path verbs, then used by drawing verbs.
+
+
+:Context
+    (12.3.1.1.5){{br}}
+
+
+    The context keeps track of everything that verbs affect. It tracks one source, one destination, and one mask. It also tracks several helper variables like your line width and style, your font face and size, and more. Most importantly it tracks the path, which is turned into a mask by drawing verbs.
+
+    Before you can start to draw something with cairo, you need to create the context. In Ruby you obtain context with Gdk::Drawable#create_cairo_context instance method. Note, you do not supply the ((<source|URL:http://www.cairographics.org/manual/cairo-surfaces.html>)) to cairo create method. Instead, you invoke the((*create_cairo_context*)) instance method on a Gdk::Drawable object, which can be either Gdk::Pixmap,  or a Gdk::Window. (Original GTK API for Gdk::Drawable also lists((*bitmap,*)) however, it fails to identify it sufficiently?)
+
+    :Caveat
+        {{image_right("dialog-warning.png")}}
+        In traditional 'C' GTK Cairo implementations and in its cousins like 'gtkmm', cairo context is typically bound to different surfaces, however, currently in Ruby, other than active GTK Window surfaces are not available! (We will talk about this more extensively shortly.)
+
+
+
+
 # ------- REQUIRED FILES:  -----------
 {{br}}
 {{br}}




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