[cairo-commit] [cairo-www] src/backends.mdwn src/cairo-banner.svg src/cairomm.mdwn src/cairo-ocaml.mdwn src/cairo_rsvg_and_python_in_windows.mdwn src/cl-cairo.mdwn src/contact.mdwn src/cookbook src/cookbook.mdwn src/documentation src/documentation.mdwn src/end_to_end_build_for_mac_os_x.mdwn src/end_to_end_build_for_win32.mdwn src/examples.mdwn src/FAQ.mdwn src/hscairo.mdwn src/lists.mdwn src/news src/OpenGL.mdwn src/operators.mdwn src/pycairo src/rcairo.mdwn src/roadmap.mdwn src/sharplinescale.mdwn src/style.css src/summerofcode src/threaded_animation_with_cairo.mdwn src/todo.mdwn templates/editpage.tmpl templates/estseek.conf templates/passwordmail.tmpl
Nis Martensen
nmartensen at freedesktop.org
Mon Apr 25 19:01:56 UTC 2016
src/FAQ.mdwn | 18 +-
src/OpenGL.mdwn | 41 +++---
src/backends.mdwn | 3
src/cairo-banner.svg | 114 ++++++++---------
src/cairo-ocaml.mdwn | 18 +-
src/cairo_rsvg_and_python_in_windows.mdwn | 28 ++--
src/cairomm.mdwn | 9 -
src/cl-cairo.mdwn | 8 -
src/contact.mdwn | 6
src/cookbook.mdwn | 2
src/cookbook/animationrotation.mdwn | 132 ++++++++++----------
src/cookbook/emboss.mdwn | 2
src/cookbook/hittestpython.mdwn | 60 ++++-----
src/cookbook/librsvgpython.mdwn | 80 +++++-------
src/cookbook/matrix_transform.mdwn | 2
src/cookbook/perl_cairo_module.mdwn | 9 -
src/cookbook/pycairo_pango.mdwn | 3
src/cookbook/pyrsvg.mdwn | 53 +++-----
src/cookbook/pythoncairopil.mdwn | 12 -
src/cookbook/quickframework.mdwn | 30 ++--
src/cookbook/renderpdf.mdwn | 2
src/cookbook/roundedrectangles.mdwn | 22 +--
src/cookbook/svgtopycairo.mdwn | 50 +++----
src/cookbook/win32quickstart.mdwn | 100 +++++++--------
src/documentation.mdwn | 4
src/documentation/using_the_postscript_surface.mdwn | 16 +-
src/end_to_end_build_for_mac_os_x.mdwn | 6
src/end_to_end_build_for_win32.mdwn | 4
src/examples.mdwn | 2
src/hscairo.mdwn | 6
src/lists.mdwn | 6
src/news/cairo-1.0.0.mdwn | 104 +++++++--------
src/news/cairo-1.10.0.mdwn | 2
src/news/cairo-1.12.16.mdwn | 2
src/news/cairo-1.12.2.mdwn | 2
src/news/cairo-1.14.4.mdwn | 2
src/news/cairo-1.9.8.mdwn | 2
src/operators.mdwn | 8 -
src/pycairo/resources.mdwn | 2
src/pycairo/tutorial.mdwn | 2
src/rcairo.mdwn | 4
src/roadmap.mdwn | 2
src/sharplinescale.mdwn | 12 -
src/style.css | 4
src/summerofcode/ideas.mdwn | 26 +--
src/threaded_animation_with_cairo.mdwn | 66 +++++-----
src/todo.mdwn | 7 -
templates/editpage.tmpl | 2
templates/estseek.conf | 6
templates/passwordmail.tmpl | 2
50 files changed, 546 insertions(+), 559 deletions(-)
New commits:
commit e837b803fa2e58c06f969290890f1a26c3702ecc
Author: Lawrence D'Oliveiro <ldo at geek-central.gen.nz>
Date: Sat Apr 23 04:02:00 2016 +0000
Remove whitespace at ends of lines and empty lines at ends of files
diff --git a/src/FAQ.mdwn b/src/FAQ.mdwn
index bc9e6ef..0d86520 100644
--- a/src/FAQ.mdwn
+++ b/src/FAQ.mdwn
@@ -30,10 +30,10 @@ new users to cairo.
<h2 id="minimal_C_program">What would a minimal C program look like using cairo?</h2>
-Create a file called `hello.c` containing
-
+Create a file called `hello.c` containing
+
#include <cairo.h>
-
+
int
main (int argc, char *argv[])
{
@@ -41,7 +41,7 @@ Create a file called `hello.c` containing
cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
cairo_t *cr =
cairo_create (surface);
-
+
cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 32.0);
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
@@ -53,7 +53,7 @@ Create a file called `hello.c` containing
cairo_surface_destroy (surface);
return 0;
}
-
+
After compiling, run the resulting `hello` program you'll have a PNG
image file named `hello.png` with "Hello World" written in blue.
@@ -68,7 +68,7 @@ But the exact flags and paths will depend on your compiler and your
installation of cairo. To simplify this, cairo uses pkg-config which
can help you determine the correct flags to use. If you have
pkg-config installed, then you can compile the above hello.c with:
-
+
cc -o hello $(pkg-config --cflags --libs cairo) hello.c
If you are using a csh style shell, use backquotes:
@@ -92,7 +92,7 @@ or for csh:
If you want to clear your surface to a uniform, opaque color then it
is quite straightforward:
-
+
/* Set surface to opaque color (r, g, b) */
cairo_set_source_rgb (cr, r, g, b);
cairo_paint (cr);
@@ -174,7 +174,7 @@ and half-intensity). What's wrong?
Answer: This problem usually shows up with code like the following,
(and with the default transformation matrix):
-
+
cairo_move_to (cr, 10, 10);
cairo_line_to (cr, 20, 10);
cairo_set_line_width (cr, 1);
@@ -231,7 +231,7 @@ would lead to undesired jitter in the result). The trick to snapping
is simply to perform rounding in device-space so that rectilinear
geometry lands at integer position in the device-space grid. So, the
process might look something like:
-
+
cairo_user_to_device (cr, &x, &y);
do_rounding (&x, &y);
cairo_device_to_user (cr, &x, &y);
diff --git a/src/OpenGL.mdwn b/src/OpenGL.mdwn
index 1c5739a..10d9b5b 100644
--- a/src/OpenGL.mdwn
+++ b/src/OpenGL.mdwn
@@ -86,12 +86,12 @@ vector-graphics into an OpenGL-rendered scene...
[glitz](http://www.freedesktop.org/wiki/Software/glitz)-based) you
want to use as a source for later texture-map generation.
- * Render into the cairo-context with normal cairo-calls.
+ * Render into the cairo-context with normal cairo-calls.
* Copy the cairo-surface into an OpenGL-texture with
`glTexImage2D()`.
- * Use this texture to map your OpenGL-primitives with.
+ * Use this texture to map your OpenGL-primitives with.
* Rendering to the cairo-surface and copying that to the
OpenGL-texture afterwards, can also be done in your
@@ -110,9 +110,9 @@ This example program tries to be as simple as possible, without being
too boring. It is written in plain ANSI C and uses cairo, OpenGL and
SDL. Thus it should "translate" to other platforms or languages
without much effort. Download the sources with this command...
-
+
bzr branch lp:gl-cairo-simple
-
+
... or just head over to the project page [here](https://edge.launchpad.net/gl-cairo-simple)
@@ -150,11 +150,11 @@ it makes use of GTK+ and GtkGlExt for the typical windowing-system
boilerplate-code. You can grab the up-to-date version of this with...
bzr branch lp:gl-cairo-cube
-
+
... or just head over to the project page [here](https://edge.launchpad.net/gl-cairo-cube)
-Once successfully compiled it will look like this...
+Once successfully compiled it will look like this...
<a href="http://macslow.thepimp.net/clips/gl-cairo-cube.ogg">
<img src="http://macslow.thepimp.net/shots/small_gl-cairo-cube-1.png" alt="gl-cairo-cube screenshot" />
@@ -183,9 +183,9 @@ nearly on every system. To throttle the framerate you
can pass -r <desired framerate> and the program will try to match that
frame-rate. The default is to try to render with 30 Hz. Be sure to
read the supplied README. You can grab the up-to-date version of this with...
-
+
bzr branch lp:cairo-gimmicks
-
+
... or just head over to the project page [here](https://code.edge.launchpad.net/cairo-gimmicks)
@@ -230,12 +230,12 @@ see what one can do image-filter-wise without using FBOs (note: I am
well aware that doing gaussian blurring without FBOs is anything but
fast).
-You can check it out the sources via bazaar, like this...
-
+You can check it out the sources via bazaar, like this...
+
bzr branch lp:gl-cairo-aatrick
-Once successfully compiled it will look like this when running...
+Once successfully compiled it will look like this when running...
<a href="http://macslow.thepimp.net/clips/gl-cairo-aatrick.ogg">
<img src="http://macslow.thepimp.net/shots/small_gl-cairo-aatrick_ogg.png">
@@ -254,23 +254,23 @@ You can find another simplest example [here](http://code.google.com/p/gtk-gl-sli
## Further reading
- * [OpenGL][10], the main resource for OpenGL on the web
+ * [OpenGL][10], the main resource for OpenGL on the web
- * [MacSlow's site][36] with several example programs using cairo, OpenGL, glitz and librsvg
+ * [MacSlow's site][36] with several example programs using cairo, OpenGL, glitz and librsvg
- * [librsvg][37], a library for adding SVG-support to your application
+ * [librsvg][37], a library for adding SVG-support to your application
- * [gtk+][12], the native UI-toolkit of Gnome, used by many Linux-programs, cross-platform
+ * [gtk+][12], the native UI-toolkit of Gnome, used by many Linux-programs, cross-platform
- * [pigment][38], library for fast, visually rich graphical user interfaces (currently geared towards [Elisa][39])
+ * [pigment][38], library for fast, visually rich graphical user interfaces (currently geared towards [Elisa][39])
- * [clutter][40], another library for fast, visually rich graphical user interfaces
+ * [clutter][40], another library for fast, visually rich graphical user interfaces
- * [GtkGlExt][13], a very good OpenGL-widget/binding for gtk+
+ * [GtkGlExt][13], a very good OpenGL-widget/binding for gtk+
- * [SDL][11], a handy and ultra-thin "convenience" library for platform-abstraction
+ * [SDL][11], a handy and ultra-thin "convenience" library for platform-abstraction
- * [Amanith][41], the "competition", good, but not as free and versatile
+ * [Amanith][41], the "competition", good, but not as free and versatile
[10]: http://www.opengl.org/
[11]: http://www.libsdl.org/
@@ -283,4 +283,3 @@ You can find another simplest example [here](http://code.google.com/p/gtk-gl-sli
[39]: http://elisa.fluendo.com/
[40]: http://clutter-project.org
[41]: http://www.amanith.org/
-
diff --git a/src/backends.mdwn b/src/backends.mdwn
index 759aae9..fea5060 100644
--- a/src/backends.mdwn
+++ b/src/backends.mdwn
@@ -30,7 +30,7 @@ The backends currently present in cairo include:
* win32: Windows GDI backend
- * svg: To generate SVG files.
+ * svg: To generate SVG files.
* beos: BeOS/Zeta backend
@@ -49,4 +49,3 @@ Other backends that are in progress or have been proposed include :
[2]: http://www.khronos.org/egl/
[3]: http://xcb.freedesktop.org/
[4]: http://www.khronos.org/openvg/
-
diff --git a/src/cairo-banner.svg b/src/cairo-banner.svg
index 13b91c3..5f245ac 100644
--- a/src/cairo-banner.svg
+++ b/src/cairo-banner.svg
@@ -84,75 +84,75 @@
<g transform="scale(0.085,0.085)"> <g transform="translate(-1139,-208.5)">
<!-- 63 (c), advance 444, 0 horiBearing 38,522 -->
<path transform="translate(-151,0)" d="
- M 412, 433
- C 385, 422 336, 413 298, 413
- C 142, 413 38, 525 38, 680
- C 38, 826 144, 947 298, 947
- C 332, 947 377, 944 416, 926
- L 409, 842
- C 380, 861 340, 871 308, 871
- C 187, 871 138, 771 138, 680
- C 138, 583 197, 489 302, 489
- C 332, 489 368, 496 404, 511
+ M 412, 433
+ C 385, 422 336, 413 298, 413
+ C 142, 413 38, 525 38, 680
+ C 38, 826 144, 947 298, 947
+ C 332, 947 377, 944 416, 926
+ L 409, 842
+ C 380, 861 340, 871 308, 871
+ C 187, 871 138, 771 138, 680
+ C 138, 583 197, 489 302, 489
+ C 332, 489 368, 496 404, 511
L 412, 433 " />
<!-- 61 (a), advance 556, 0 horiBearing 46,522 -->
<path transform="translate(379.5,0)" d="
- M 109, 541
- C 147, 509 204, 489 257, 489
- C 351, 489 383, 534 383, 622
- C 346, 620 320, 620 283, 620
- C 186, 620 46, 660 46, 788
- C 46, 899 123, 947 233, 947
- C 319, 947 369, 900 391, 869
- L 393, 869
- L 393, 938
- L 481, 938
- C 479, 920 477, 893 477, 835
- L 477, 624
- C 477, 485 418, 413 272, 413
- C 207, 413 151, 433 104, 461
- L 109, 541
- M 383, 737
- C 383, 813 334, 871 241, 871
- C 198, 871 146, 842 146, 788
- C 146, 698 272, 690 323, 690
- C 343, 690 363, 692 383, 692
+ M 109, 541
+ C 147, 509 204, 489 257, 489
+ C 351, 489 383, 534 383, 622
+ C 346, 620 320, 620 283, 620
+ C 186, 620 46, 660 46, 788
+ C 46, 899 123, 947 233, 947
+ C 319, 947 369, 900 391, 869
+ L 393, 869
+ L 393, 938
+ L 481, 938
+ C 479, 920 477, 893 477, 835
+ L 477, 624
+ C 477, 485 418, 413 272, 413
+ C 207, 413 151, 433 104, 461
+ L 109, 541
+ M 383, 737
+ C 383, 813 334, 871 241, 871
+ C 198, 871 146, 842 146, 788
+ C 146, 698 272, 690 323, 690
+ C 343, 690 363, 692 383, 692
L 383, 737 " />
<!-- 69 (i), advance 278, 0 horiBearing 86,730 -->
<path transform="translate(1000,0)" d="
- M 92, 938
- L 186, 938
- L 186, 420.3
- L 92, 420.3
- L 92, 938
+ M 92, 938
+ L 186, 938
+ L 186, 420.3
+ L 92, 420.3
+ L 92, 938
M 88, 261
A 51, 51 0 1 1 190,261
A 51, 51 0 1 1 88,261" />
<!-- 72 (r), advance 389, 0 horiBearing 80,522 -->
<path transform="translate(1341.5,0)" d="
- M 80, 938
- L 174, 938
- L 174, 703
- C 174, 575 229, 495 313, 495
- C 329, 495 348, 497 365, 504
- L 365, 420
- C 345, 416 331, 413 303, 413
- C 249, 413 195, 451 170, 504
- L 168, 504
- L 168, 420.3
- L 80, 420.3
+ M 80, 938
+ L 174, 938
+ L 174, 703
+ C 174, 575 229, 495 313, 495
+ C 329, 495 348, 497 365, 504
+ L 365, 420
+ C 345, 416 331, 413 303, 413
+ C 249, 413 195, 451 170, 504
+ L 168, 504
+ L 168, 420.3
+ L 80, 420.3
L 80, 938 " />
<!-- 6f (o), advance 611, 0 horiBearing 46,522 -->
<path transform="translate(1826,0)" d="
- M 46, 680
- C 46, 826 152, 947 306, 947
- C 459, 947 565, 826 565, 680
- C 565, 525 461, 413 306, 413
- C 150, 413 46, 525 46, 680
- M 146, 680
- C 146, 583 205, 489 306, 489
- C 406, 489 465, 583 465, 680
- C 465, 771 416, 871 306, 871
+ M 46, 680
+ C 46, 826 152, 947 306, 947
+ C 459, 947 565, 826 565, 680
+ C 565, 525 461, 413 306, 413
+ C 150, 413 46, 525 46, 680
+ M 146, 680
+ C 146, 583 205, 489 306, 489
+ C 406, 489 465, 583 465, 680
+ C 465, 771 416, 871 306, 871
C 195, 871 146, 771 146, 680 " />
<!-- bounds: 38, 205 <-> 2232, 947 -->
</g> </g>
@@ -176,11 +176,11 @@
</g>
</g>
</g>
-
+
<use xlink:href="#scarab" transform="translate(0,47) scale(.2)" />
</g>
-
+
</defs>
<use xlink:href="#scarab_and_dung" transform="translate(30.5,0)" />
diff --git a/src/cairo-ocaml.mdwn b/src/cairo-ocaml.mdwn
index 6c4c4bb..f885ae4 100644
--- a/src/cairo-ocaml.mdwn
+++ b/src/cairo-ocaml.mdwn
@@ -3,9 +3,9 @@
[Objective Caml](http://caml.inria.fr/) bindings are in the
[cairo-ocaml](http://cgit.freedesktop.org/cairo-ocaml/) module of the git repository.
-The following [[backends]] are supported:
+The following [[backends]] are supported:
- * image (via the Bigarray module)
+ * image (via the Bigarray module)
* ps
@@ -35,27 +35,27 @@ ocamldoc format.
# A very simple example
This is a simple example, (ported from a [[pycairo]] example):
-
+
let width = 400
let height = 400
-
- let main =
+
+ let main =
(* Setup Cairo *)
let surface = Cairo.image_surface_create Cairo.FORMAT_ARGB32 ~width ~height in
let ctx = Cairo.create surface in
-
+
(* Set thickness of brush *)
Cairo.set_line_width ctx 15. ;
-
+
(* Draw out the triangle using absolute coordinates *)
Cairo.move_to ctx 200. 100. ;
Cairo.line_to ctx 300. 300. ;
Cairo.rel_line_to ctx (-200.) 0. ;
Cairo.close_path ctx ;
-
+
(* Apply the ink *)
Cairo.stroke ctx ;
-
+
(* Output a PNG file *)
Cairo_png.surface_write_to_file surface "triangle.png"
diff --git a/src/cairo_rsvg_and_python_in_windows.mdwn b/src/cairo_rsvg_and_python_in_windows.mdwn
index b7b4af0..6311fd5 100644
--- a/src/cairo_rsvg_and_python_in_windows.mdwn
+++ b/src/cairo_rsvg_and_python_in_windows.mdwn
@@ -13,53 +13,53 @@ An extremely minimal wrapper for rsvg that can be used in Windows as a drop-in r
if os.name == 'nt':
print "Detected windows, creating rsvg."
#some workarounds for windows
-
+
from ctypes import *
-
+
l=CDLL('librsvg-2-2.dll')
g=CDLL('libgobject-2.0-0.dll')
g.g_type_init()
-
+
class rsvgHandle():
class RsvgDimensionData(Structure):
_fields_ = [("width", c_int),
("height", c_int),
("em",c_double),
("ex",c_double)]
-
+
class PycairoContext(Structure):
_fields_ = [("PyObject_HEAD", c_byte * object.__basicsize__),
("ctx", c_void_p),
("base", c_void_p)]
-
+
def __init__(self, path):
self.path = path
error = ''
self.handle = l.rsvg_handle_new_from_file(self.path,error)
-
-
+
+
def get_dimension_data(self):
svgDim = self.RsvgDimensionData()
l.rsvg_handle_get_dimensions(self.handle,byref(svgDim))
return (svgDim.width,svgDim.height)
-
+
def render_cairo(self, ctx):
ctx.save()
z = self.PycairoContext.from_address(id(ctx))
l.rsvg_handle_render_cairo(self.handle, z.ctx)
ctx.restore()
-
-
-
+
+
+
class rsvgClass():
def Handle(self,file):
return rsvgHandle(file)
-
+
rsvg = rsvgClass()
This wrapper may be used to render svg's with the same syntax as rsvg. i.e.:
-
+
h = rsvg.Handle("box.svg")
- s = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)
+ s = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)
ctx = cairo.Context(s)
h.render_cairo(ctx)
diff --git a/src/cairomm.mdwn b/src/cairomm.mdwn
index a029035..3f8a60b 100644
--- a/src/cairomm.mdwn
+++ b/src/cairomm.mdwn
@@ -13,9 +13,9 @@ API/ABI-stable. cairomm is used by [gtkmm](http://gtkmm.org/) since 2.10.
# Download
You can download released versions of cairomm from the
-[cairo release area](/releases/).
+[cairo release area](/releases/).
-## Git Repository
+## Git Repository
If you want bleeding-edge code, (or if you want to help out with development of cairomm), you can also
check out cairomm from git, which you can also [browse online](http://cgit.freedesktop.org/cairomm/tree/).
@@ -23,13 +23,13 @@ Anybody can checkout the latest source code **anonymously** with the following c
git clone git://git.cairographics.org/git/cairomm
-You can commit changes to your local repository but will not be able to push them to the central repository.
+You can commit changes to your local repository but will not be able to push them to the central repository.
**If you are a developer** with a freedesktop.org account and would like to be able to push your changes to the central repository, you should use the following command to checkout the latest source code (notice the lack of the git:// protocol prefix and the ':' after the domain name):
git clone git.cairographics.org:/git/cairomm
-This will use ssh to perform the checkout and will require you to have a freedesktop.org account.
+This will use ssh to perform the checkout and will require you to have a freedesktop.org account.
For some basic information on using git, see the "Using Git" section below.
@@ -114,4 +114,3 @@ Freedesktop.org has some additional instructions on
[LGPL]: http://www.gnu.org/licenses/lgpl.html
[bugs]: https://bugs.freedesktop.org/enter_bug.cgi?product=cairomm
[open bugs]: https://bugs.freedesktop.org/buglist.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&product=cairomm&content=
-
diff --git a/src/cl-cairo.mdwn b/src/cl-cairo.mdwn
index 63350ba..c399a95 100644
--- a/src/cl-cairo.mdwn
+++ b/src/cl-cairo.mdwn
@@ -3,18 +3,18 @@
I'm working on some bindings for Common Lisp.
It can be downloaded with Darcs like this:
-
+
darcs get http://nostdal.org/~lars/programming/lisp/cl-cairo/
-
+
You can also browse the code:
<http://nostdal.org/~lars/programming/lisp/cl-cairo/>
-Here are some simple examples:
+Here are some simple examples:
[http://nostdal.org/~lars/programming/lisp/cl-cairo/cl-cairo-font-test.png]
[http://nostdal.org/~lars/programming/lisp/cl-cairo/test.png]
-..and the first one in SVG-format:
+..and the first one in SVG-format:
[http://nostdal.org/~lars/programming/lisp/cl-cairo/cl-cairo-svg-test.svg]
diff --git a/src/contact.mdwn b/src/contact.mdwn
index 37f8485..0e5d3dc 100644
--- a/src/contact.mdwn
+++ b/src/contact.mdwn
@@ -1,6 +1,6 @@
[[!meta title="Contact"]]
-There are several ways to contact developers and users of cairo.
+There are several ways to contact developers and users of cairo.
# Mailing Lists
@@ -22,10 +22,10 @@ enter a bug report against the cairo product at
Some people IRC. If you're one of them, you can find other like-minded
cairo folk here:
-
+
server: irc.freenode.net
channel: #cairo
-
+
If you think IRC is nothing but a big waste of time, feel free to
ignore IRC since any significant discussion there will be reflected on
the mailing lists. You'll just miss out on hearing things like how
diff --git a/src/cookbook.mdwn b/src/cookbook.mdwn
index f9cb78e..68ae549 100644
--- a/src/cookbook.mdwn
+++ b/src/cookbook.mdwn
@@ -18,7 +18,7 @@
* [[How_to:Render text with Pango using Python|pycairo_pango]]
+ Graphics Formats
- * [[Load_jpg/png/gif/bmp/etc_into_CairoContext_with_help_from_gdk-pixbuf_in_Pycairo/Pygtk|gdkpixbufpycairo]]
+ * [[Load_jpg/png/gif/bmp/etc_into_CairoContext_with_help_from_gdk-pixbuf_in_Pycairo/Pygtk|gdkpixbufpycairo]]
* [[Python:_Converting_PIL_images_to_Cairo_surfaces_and_back|pythoncairopil]]
* [[Rendering_SVG_using_librsvg_in_Python|librsvgpython]]
* [[How_to:Open_a_simple_SVG_file_without_Pyrsvg|svgtopycairo]]
diff --git a/src/cookbook/animationrotation.mdwn b/src/cookbook/animationrotation.mdwn
index f0b4938..3c13801 100644
--- a/src/cookbook/animationrotation.mdwn
+++ b/src/cookbook/animationrotation.mdwn
@@ -2,7 +2,7 @@
There are two demos now, the first shows (gasp) a square rotating around an arbitrary point. Scroll down for the second one which is longer and a bit more interesting.
-This demo is two things: First it's a nice little framework that gives "life" to a function so that animation becomes possible. If you want stuff to be drawn again and again with little changes, this is a good start. (I'd love to see other solutions).
+This demo is two things: First it's a nice little framework that gives "life" to a function so that animation becomes possible. If you want stuff to be drawn again and again with little changes, this is a good start. (I'd love to see other solutions).
Secondly it shows how to rotate a "shape" (set of cairo commands) around any given ( x, y ) point.
I tried to comment it thoroughly, so it will 'splain itself.
@@ -38,20 +38,20 @@ I tried to comment it thoroughly, so it will 'splain itself.
self.connect ( "expose_event", self.do_expose_event )
## This is what gives the animation life!
gobject.timeout_add( 50, self.tick ) # Go call tick every 50 whatsits.
-
+
def tick ( self ):
## This invalidates the screen, causing the expose event to fire.
self.alloc = self.get_allocation ( )
rect = gtk.gdk.Rectangle ( self.alloc.x, self.alloc.y, self.alloc.width, self.alloc.height )
- self.window.invalidate_rect ( rect, True )
+ self.window.invalidate_rect ( rect, True )
return True # Causes timeout to tick again.
-
+
## When expose event fires, this is run
def do_expose_event( self, widget, event ):
self.cr = self.window.cairo_create( )
## Call our draw function to do stuff.
self.draw( *self.window.get_size( ) )
-
+
class MyStuff ( Screen ):
"""This class is also a Drawing Area, coming from Screen."""
def __init__ ( self ):
@@ -68,7 +68,7 @@ I tried to comment it thoroughly, so it will 'splain itself.
def draw( self, width, height ):
## A shortcut
cr = self.cr
-
+
## First, let's shift 0,0 to be in the center of page
## This means:
## -y | -y
@@ -76,25 +76,25 @@ I tried to comment it thoroughly, so it will 'splain itself.
## ----0------
## -x | +x
## +y | +y
-
+
matrix = cairo.Matrix ( 1, 0, 0, 1, width/2, height/2 )
cr.transform ( matrix ) # Make it so...
-
+
## Now save that situation so that we can mess with it.
## This preserves the last context ( the one at 0,0)
## and let's us do new stuff.
cr.save ( )
-
+
## Now attempt to rotate something around a point
## Use a matrix to change the shape's position and rotation.
-
+
## First, make a matrix. Don't look at me, I only use this stuff :)
ThingMatrix = cairo.Matrix ( 1, 0, 0, 1, 0, 0 )
-
+
## Next, move the drawing to it's x,y
cairo.Matrix.translate ( ThingMatrix, self.x, self.y )
cr.transform ( ThingMatrix ) # Changes the context to reflect that
-
+
## Now, change the matrix again to:
cairo.Matrix.translate( ThingMatrix, self.rx, self.ry ) # move it all to point of rotation
cairo.Matrix.rotate( ThingMatrix, self.rot ) # Do the rotation
@@ -102,39 +102,39 @@ I tried to comment it thoroughly, so it will 'splain itself.
cairo.Matrix.scale( ThingMatrix, self.sx, self.sy ) # Now scale it all
cr.transform ( ThingMatrix ) # and commit it to the context
- ## Now, whatever is draw is "under the influence" of the
+ ## Now, whatever is draw is "under the influence" of the
## context and all that matrix magix we just did.
self.drawCairoStuff ( cr )
-
+
## Let's inc the angle a little
self.rot += 0.1
-
+
## Now mess with scale too
self.sx += 0 # Change to 0 to see if rotation is working...
if self.sx > 4: self.sx=0.5
self.sy = self.sx
-
+
## We restore to a clean context, to undo all that hocus-pocus
cr.restore ( )
-
+
## Let's draw a crosshair so we can identify 0,0
## Drawn last to be above the red square.
- self.drawcross ( cr )
-
+ self.drawcross ( cr )
+
def drawCairoStuff ( self, cr ):
## Thrillingly, we draw a red rectangle.
## It's drawn such that 0,0 is in it's center.
cr.rectangle( -25, -25, 50, 50 )
- cr.set_source_rgb( 1, 0, 0)
+ cr.set_source_rgb( 1, 0, 0)
cr.fill( )
## Now a visual indicator of the point of rotation
- ## I have no idea (yet) how to keep this as a
+ ## I have no idea (yet) how to keep this as a
## tiny dot when the entire thing scales.
cr.set_source_rgb( 1, 1, 1 )
cr.move_to( self.rx, self.ry )
cr.line_to ( self.rx+1, self.ry+1 )
cr.stroke( )
-
+
def drawcross ( self, ctx ):
## Also drawn around 0,0 in the center
ctx.set_source_rgb ( 0, 0, 0 )
@@ -143,8 +143,8 @@ I tried to comment it thoroughly, so it will 'splain itself.
ctx.move_to ( -10, 0 )
ctx.line_to ( 10, 0 )
ctx.stroke ( )
-
-
+
+
def run( Widget ):
window = gtk.Window( )
window.connect( "delete-event", gtk.main_quit )
@@ -154,14 +154,14 @@ I tried to comment it thoroughly, so it will 'splain itself.
window.add( widget )
window.present( )
gtk.main( )
-
+
run( MyStuff )
## Here's a longer version with many things moving
I spent some time (and got some help from the list - thanks) working on a better version to demonstrate how to move many things around. This one also shows how you can use context.save() to create what I call "bubbles" of private space on the screen where different rules can apply for a short time. By putting bubbles within other bubbles you can create parent->child relationships. The sample has a red square that is a parent to a green one. What the red does, the green does too.
-This also shows primitive mouse hit detection (prints to the console, so hold onto your seats because the budget was just blown baby!) on the green square.
+This also shows primitive mouse hit detection (prints to the console, so hold onto your seats because the budget was just blown baby!) on the green square.
I hope this help someone out there.
@@ -198,30 +198,30 @@ I hope this help someone out there.
## We want to know where the mouse is:
self.connect ( "motion_notify_event", self._mouseMoved )
## More GTK voodoo : unmask events
- self.add_events ( gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.POINTER_MOTION_MASK )
+ self.add_events ( gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.POINTER_MOTION_MASK )
## This is what gives the animation life!
gobject.timeout_add( speed, self.tick ) # Go call tick every 'speed' whatsits.
self.width, self.height = w, h
self.set_size_request ( w, h )
self.x, self.y = 11110,11111110 #unlikely first coord to prevent false hits.
-
+
def tick ( self ):
"""This invalidates the screen, causing the expose event to fire."""
self.alloc = self.get_allocation ( )
rect = gtk.gdk.Rectangle ( self.alloc.x, self.alloc.y, self.alloc.width, self.alloc.height )
- self.window.invalidate_rect ( rect, True )
+ self.window.invalidate_rect ( rect, True )
return True # Causes timeout to tick again.
-
+
## When expose event fires, this is run
def do_expose_event( self, widget, event ):
self.cr = self.window.cairo_create( )
## Call our draw function to do stuff.
self.draw( )
-
+
def _mouseMoved ( self, widget, event ):
self.x = event.x
self.y = event.y
-
+
class BunchOfStuff ( object ):
"""Stores a bunch of data"""
def __init__ ( self, x=0, y=0, rx=0, ry=0, rot=0, sx=1, sy=1 ):
@@ -232,24 +232,24 @@ I hope this help someone out there.
self.rot = rot
self.sx = sx
self.sy = sy
-
+
class MyStuff ( Screen ):
"""This class is also a Drawing Area, coming from Screen."""
def __init__ ( self, w, h, speed):
Screen.__init__( self, w, h, speed )
-
+
## Setup three sets of data for the three objects to be drawn
self.red = BunchOfStuff ( x=50, y=-10, rx=50, ry=25 )
self.green = BunchOfStuff ( x=-10, y=10 )
self.blue = BunchOfStuff ( x=-70,y=30, sx=1, sy=1 )
-
+
self.sign = +1 # to flip the blue animation's sign
-
+
def setToCenter ( self ):
"""Shift 0,0 to be in the center of page."""
matrix = cairo.Matrix ( 1, 0, 0, 1, self.width/2, self.height/2 )
self.cr.transform ( matrix ) # Make it so...
-
+
def doMatrixVoodoo ( self, bos ):
"""Do all the matrix mumbo to get stuff to the right place on the screen."""
ThingMatrix =cairo.Matrix ( 1, 0, 0, 1, 0, 0 )
@@ -260,32 +260,32 @@ I hope this help someone out there.
if bos.rx != 0 and bos.ry != 0 : # Only do this if there's a special reason
cairo.Matrix.translate( ThingMatrix, bos.rx, bos.ry ) # move it all to point of rotation
cairo.Matrix.rotate( ThingMatrix, bos.rot ) # Do the rotation
- if bos.rx != 0 and bos.ry != 0 :
+ if bos.rx != 0 and bos.ry != 0 :
cairo.Matrix.translate( ThingMatrix, -bos.rx, -bos.ry ) # move it back again
cairo.Matrix.scale( ThingMatrix, bos.sx, bos.sy ) # Now scale it all
self.cr.transform ( ThingMatrix ) # and commit it to the context
def draw( self ):
cr = self.cr # Shabby shortcut.
-
+
#---------TOP LEVEL - THE "PAGE"
self.cr.identity_matrix ( ) # VITAL LINE :: I'm not sure what it's doing.
self.setToCenter ( )
-
+
#----------FIRST LEVEL
cr.save ( ) # Creates a 'bubble' of private coordinates. Save # 1
-
+
## RED - draw the red object
- self.doMatrixVoodoo ( self.red )
+ self.doMatrixVoodoo ( self.red )
self.drawCairoStuff ( self.red )
-
+
#---------- SECOND LEVEL - RELATIVE TO FIRST
cr.save ( ) #save 2
-
+
## GREEN - draw the green one
self.doMatrixVoodoo ( self.green )
self.drawCairoStuff ( self.green, col= ( 0,1,0 ) )
-
+
## Demonstrate how to detect a mouse hit on this shape:
## Draw the hit shape :: It *should* be drawn exactly over the green rectangle.
self.drawHitShape ( )
@@ -294,41 +294,41 @@ I hope this help someone out there.
hit = cr.in_fill ( self.x, self.y ) # Use Cairo's built-in hit test
cr.new_path ( ) # stops the hit shape from being drawn
cr.restore ( ) # Close the bubble like this never happened.
-
-
+
+
cr.restore ( ) #restore 2 :: "pop" the bubble.
-
+
## We are in level one's influence now
-
+
cr.restore ( ) #restore 1
## Back on PAGE's influence now
-
+
#-------- THIRD LEVEL -- RELATIVE TO PAGE
cr.save ( ) # Creates a 'bubble' of private coordinates.
## Draw the blue object
self.doMatrixVoodoo ( self.blue ) # within the bubble, this will not effect the PAGE
self.drawCairoStuff ( self.blue, col= ( 0,0,1 ) )
cr.restore ( )
-
+
## Back on the PAGE level again.
-
+
#indicate center
- self.drawCrosshair ( )
+ self.drawCrosshair ( )
self.guageScale ( )
-
- ## Let's animate the red object
- ## ( which *also* moves the green because it's a 'child'
+
+ ## Let's animate the red object
+ ## ( which *also* moves the green because it's a 'child'
## of the red by way of being in the same "bubble" )
self.red.rot += 0.01
## Now animate the blue
self.blue.sx += self.sign * 0.1
- if self.blue.sx < 0 or self.blue.sx > 4:
+ if self.blue.sx < 0 or self.blue.sx > 4:
self.sign *= -1
self.blue.sy = self.blue.sx
-
+
## Print to the console -- low-tech special effects :)
if hit: print "HIT!", self.x, self.y
-
+
def guageScale ( self ):
"""Draw some axis so we can see where stuff is."""
c = self.cr
@@ -343,14 +343,14 @@ I hope this help someone out there.
c.rectangle ( -w/2, -x , w, 1 )
c.set_source_rgb ( 0,0,0 )
c.fill ( )
-
+
def drawCairoStuff ( self, bos, col= ( 1,0,0 ) ):
"""This draws the squares we see. Pass it a BagOfStuff (bos) and a colour."""
cr = self.cr
## Thrillingly, we draw a rectangle.
## It's drawn such that 0,0 is in it's center.
cr.rectangle( -25, -25, 50, 50 )
- cr.set_source_rgb( col[0],col[1],col[2] )
+ cr.set_source_rgb( col[0],col[1],col[2] )
cr.fill( )
## Now draw an axis
self.guageScale ( )
@@ -358,12 +358,12 @@ I hope this help someone out there.
cr.set_source_rgb( 1,1,1 )
cr.rectangle ( bos.rx - 2, bos.ry - 2, 4, 4 )
cr.fill ( )
-
+
## Same as the rectangle we see. No fill.
def drawHitShape ( self ):
"""Draws a shape that we'll use to test hits."""
self.cr.rectangle( -25, -25, 50, 50 ) # Same as the shape of the squares
-
+
def drawCrosshair ( self ):
"""Another visual aid."""
ctx = self.cr
@@ -373,8 +373,8 @@ I hope this help someone out there.
ctx.move_to ( -10, 0 )
ctx.line_to ( 10, 0 )
ctx.stroke ( )
-
-
+
+
def run( Widget, w, h, speed ):
window = gtk.Window( )
window.connect( "delete-event", gtk.main_quit )
@@ -383,5 +383,5 @@ I hope this help someone out there.
window.add( widget )
window.present( )
gtk.main( )
-
+
run( MyStuff, 400, 400, speed = 20 )
diff --git a/src/cookbook/emboss.mdwn b/src/cookbook/emboss.mdwn
index 0face4f..f6a8769 100644
--- a/src/cookbook/emboss.mdwn
+++ b/src/cookbook/emboss.mdwn
@@ -133,7 +133,7 @@ This sample shows how to apply an emboss effect to a cairo A8 image surface.
cairo_show_text(cr, text);
cairo_surface_t* emboss = create_embossed_surface_from_surface(
- surface,
+ surface,
atoi(argv[1]) * (M_PI / 180.0f),
atoi(argv[2]) * (M_PI / 180.0f)
);
diff --git a/src/cookbook/hittestpython.mdwn b/src/cookbook/hittestpython.mdwn
index 6ea465f..13e3ec8 100644
--- a/src/cookbook/hittestpython.mdwn
+++ b/src/cookbook/hittestpython.mdwn
@@ -31,13 +31,13 @@ Jeff Muizelaar informed me that Cairo has a built-in function to do this anyway.
pygtk.require('2.0')
import gtk, gobject, cairo
from gtk import gdk
-
+
# Create a GTK+ widget on which we will draw using Cairo
class Screen(gtk.DrawingArea):
-
+
# Draw in response to an expose-event
__gsignals__ = { "expose-event": "override" }
-
+
def __init__(self):
super(Screen,self).__init__()
# gtk.Widget signals
@@ -48,24 +48,24 @@ Jeff Muizelaar informed me that Cairo has a built-in function to do this anyway.
self.add_events(gdk.BUTTON_PRESS_MASK |
gdk.BUTTON_RELEASE_MASK |
gdk.POINTER_MOTION_MASK)
-
+
# Handle the expose-event by drawing
def do_expose_event(self, event):
-
+
# Create the cairo context
cr = self.window.cairo_create()
self.hitpath = None #Is set later
-
+
# Restrict Cairo to the exposed area; avoid extra work
cr.rectangle(event.area.x, event.area.y,
event.area.width, event.area.height)
cr.clip()
-
+
self.draw(cr, *self.window.get_size())
-
+
def makeHitPath(self,cairopath):
## Make a simpler list of tuples
-
+
## Internally, a cairo path looks like this:
## (0, (10.0, 10.0))
## (1, (60.0, 10.0))
@@ -76,19 +76,19 @@ Jeff Muizelaar informed me that Cairo has a built-in function to do this anyway.
## (1, (10.0, 60.0))
## (1, (-40.0, 60.0))
## (3, ()) #want to ignore this one
- ## (0, (10.0, 10.0))
-
+ ## (0, (10.0, 10.0))
+
self.hitpath = []
for sub in cairopath:
if sub[1]: #kick out the close path () empty tuple
self.hitpath.append(sub[1]) #list of tuples
-
+
def draw(self, cr, width, height):
# Fill the background with gray
cr.set_source_rgb(0.5, 0.5, 0.5)
cr.rectangle(0, 0, width, height)
cr.fill()
-
+
def hitTest(self,*p):
## Code lifted from http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/
## converted to Python. I won't pretend I grok it at all, just glad it works!
@@ -97,10 +97,10 @@ Jeff Muizelaar informed me that Cairo has a built-in function to do this anyway.
py = p[1]
counter = i = xinters = 0
p1 = p2 = ()
-
+
p1 = self.hitpath[0]
N = len(self.hitpath)
-
+
# Mathemagic loop-de-loop
for i in range(0,N):
p2 = self.hitpath[i % N]
@@ -111,18 +111,18 @@ Jeff Muizelaar informed me that Cairo has a built-in function to do this anyway.
xinters = ( py - p1[1] ) * ( p2[0] - p1[0] ) / ( p2[1] - p1[1] ) + p1[0]
if p1[0] == p2[0] or px <= xinters: counter += 1
p1 = p2
-
+
if counter % 2 == 0:
return "outside"
return "inside"
-
+
def button_press(self,widget,event):
pass
def button_release(self,widget,event):
pass
def motion_notify(self,widget,event):
pass
-
+
# GTK mumbo-jumbo to show the widget in a window and quit when it's closed
def run(Widget):
window = gtk.Window()
@@ -132,12 +132,12 @@ Jeff Muizelaar informed me that Cairo has a built-in function to do this anyway.
window.add(widget)
window.present()
gtk.main()
-
+
class Shapes(Screen):
#Override the press event
def button_press(self,widget,event):
print self.hitTest(event.x, event.y)
-
+
def draw(self, cr, width, height):
x = y = 10
sx = sy = 50
@@ -151,12 +151,12 @@ Jeff Muizelaar informed me that Cairo has a built-in function to do this anyway.
cr.line_to(x-sx,y+sy)
cr.close_path()
cr.set_source_rgb(1,0,0)
-
+
self.makeHitPath(cr.copy_path_flat()) #record the path to use as a hit area.
-
+
cr.fill() #consumes the path, so get it before the fill
-
-
+
+
run(Shapes)
##Code Listing 2 : It's already done.
@@ -164,7 +164,7 @@ Jeff Muizelaar informed me that Cairo has a built-in function to do this anyway.
...snip
class Shapes(Screen):
-
+
#Override the press event
def button_press(self,widget,event):
@@ -177,7 +177,7 @@ Jeff Muizelaar informed me that Cairo has a built-in function to do this anyway.
self.cr.append_path(self.hitpath) # re-gen the path
result = self.cr.in_fill(event.x, event.y) # Test it. Sweet.
print result
-
+
def draw(self, cr, width, height):
x = y = 10
sx = sy = 50
@@ -191,10 +191,10 @@ Jeff Muizelaar informed me that Cairo has a built-in function to do this anyway.
cr.line_to(x-sx,y+sy)
cr.close_path()
cr.set_source_rgb(1,0,0)
-
+
self.hitpath = cr.copy_path_flat() #record the path to use as a hit area.
-
+
cr.fill() #consumes the path, so get it before the fill
-
-
+
+
run(Shapes)
diff --git a/src/cookbook/librsvgpython.mdwn b/src/cookbook/librsvgpython.mdwn
index 254d063..d2ae306 100644
--- a/src/cookbook/librsvgpython.mdwn
+++ b/src/cookbook/librsvgpython.mdwn
@@ -2,72 +2,72 @@
Back to [[cookbook]]
Normally it's easier to use librsvg Python bindings from PyGTK, so you can import rsvg. When that's not an option, you may be able to bind just enough of it using the ctypes module to use it. Example for win32 follows.
-
+
# Very primitive librsvg bindings for win32
# no error checking, etc.
# but hey it works!
-
+
from ctypes import *
import cairo
l=CDLL('librsvg-2-2.dll')
g=CDLL('libgobject-2.0-0.dll')
- g.g_type_init()
-
-
+ g.g_type_init()
+
+
class PycairoContext(Structure):
_fields_ = [("PyObject_HEAD", c_byte * object.__basicsize__),
("ctx", c_void_p),
("base", c_void_p)]
-
-
-
+
+
+
class RsvgDimensionData(Structure):
_fields_ = [("width", c_int),
("height", c_int),
("em",c_double),
("ex",c_double)]
-
-
+
+
svghandlecache = {}
-
-
- def renderSVG(ctx,filename,x,y):
-
- if not filename in svghandlecache:
+
+
+ def renderSVG(ctx,filename,x,y):
+
+ if not filename in svghandlecache:
error=''
handle1 = l.rsvg_handle_new_from_file(filename,error)
svghandlecache[filename] = handle1
else:
handle1 = svghandlecache[filename]
#print error
- #print handle1
-
+ #print handle1
+
#svgDim = RsvgDimensionData()
-
+
#l.rsvg_handle_get_dimensions(handle1,byref(svgDim))
-
+
#print 'SVG Dimensions: ',svgDim.width,'x',svgDim.height
-
+
#scaleX = float(WIDTH) / float(svgDim.width)
#scaleY = float(HEIGHT) / float(svgDim.height)
#scaleY = scaleX
#scaleX = 1
#scaleY = 1
-
+
#print scaleY
-
+
ctx.save()
#ctx.scale(scaleX, scaleY)
ctx.translate(x,y)
-
+
z = PycairoContext.from_address(id(ctx))
#print z.ctx
-
+
#print '>>',l.rsvg_handle_render_cairo(handle1, z.ctx)
l.rsvg_handle_render_cairo(handle1, z.ctx)
- ctx.restore()
+ ctx.restore()
@@ -100,55 +100,53 @@ An extremely minimal wrapper for rsvg that can be used in windows as a drop-in r
if os.name == 'nt':
print "Detected windows, creating rsvg."
#some workarounds for windows
-
+
from ctypes import *
-
+
l=CDLL('librsvg-2-2.dll')
g=CDLL('libgobject-2.0-0.dll')
g.g_type_init()
-
+
class rsvgHandle():
class RsvgDimensionData(Structure):
_fields_ = [("width", c_int),
("height", c_int),
("em",c_double),
("ex",c_double)]
-
+
class PycairoContext(Structure):
_fields_ = [("PyObject_HEAD", c_byte * object.__basicsize__),
("ctx", c_void_p),
("base", c_void_p)]
-
+
def __init__(self, path):
self.path = path
error = ''
self.handle = l.rsvg_handle_new_from_file(self.path,error)
-
-
+
+
def get_dimension_data(self):
svgDim = self.RsvgDimensionData()
l.rsvg_handle_get_dimensions(self.handle,byref(svgDim))
return (svgDim.width,svgDim.height)
-
+
def render_cairo(self, ctx):
ctx.save()
z = self.PycairoContext.from_address(id(ctx))
l.rsvg_handle_render_cairo(self.handle, z.ctx)
ctx.restore()
-
-
-
+
+
+
class rsvgClass():
def Handle(self,file):
return rsvgHandle(file)
-
+
rsvg = rsvgClass()
This wrapper may be used to render svg's with the same syntax as rsvg. i.e.:
-
+
h = rsvg.Handle("box.svg")
- s = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)
+ s = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)
ctx = cairo.Context(s)
h.render_cairo(ctx)
-
-
diff --git a/src/cookbook/matrix_transform.mdwn b/src/cookbook/matrix_transform.mdwn
index 93acde1..81e1645 100644
--- a/src/cookbook/matrix_transform.mdwn
+++ b/src/cookbook/matrix_transform.mdwn
@@ -28,6 +28,6 @@ The rule of matrix multiplication is illustrated with a picture here:
[[!img "matrix_multiplication.gif" width="911" height="117" link="no"]]
In a cairo.matrix(1,2,3,4,5,6), 1 is a11, 2 is a21, 3 is a12, 4 is a22, 5 is a13 and 6 is a23.
-a31 and a32 are 0, a33 is 1.
+a31 and a32 are 0, a33 is 1.
Cairo provides matrix <a href="http://cairographics.org/manual/cairo-cairo-matrix-t.html#cairo-matrix-multiply">multiplication</a> and some other matrix <a href="http://cairographics.org/manual/cairo-cairo-matrix-t.html">functions</a>.
diff --git a/src/cookbook/perl_cairo_module.mdwn b/src/cookbook/perl_cairo_module.mdwn
index 728e361..5512d41 100644
--- a/src/cookbook/perl_cairo_module.mdwn
+++ b/src/cookbook/perl_cairo_module.mdwn
@@ -3,11 +3,11 @@ Back to [[cookbook]]
# Install Cairo CPAN Module
Using CPAN:
-
+
# cpan Cairo
Using CPANPLUS
-
+
# cpanp -i Cairo
# Examples
@@ -42,7 +42,7 @@ Using CPANPLUS
my %padding;
@padding{ qw/top right bottom left/ } = split /\s+/,PADDING;
- my @point = (
+ my @point = (
[ $padding{left}, $padding{top} ] ,
[ IMG_WIDTH - $padding{right} , $padding{top} ],
[ IMG_WIDTH - $padding{right} , IMG_HEIGHT - $padding{bottom} ],
@@ -64,7 +64,7 @@ Using CPANPLUS
$cr->move_to ( @$p );
$cr->line_to ( @$next_p );
$cr->stroke;
-
+
}
$cr->restore;
@@ -72,4 +72,3 @@ Using CPANPLUS
$surf->write_to_png ($png);
-
diff --git a/src/cookbook/pycairo_pango.mdwn b/src/cookbook/pycairo_pango.mdwn
index 754c85c..8595d91 100644
--- a/src/cookbook/pycairo_pango.mdwn
+++ b/src/cookbook/pycairo_pango.mdwn
@@ -12,7 +12,7 @@ Documentation on using pango along with cairo is scarce, and most examples are i
My system has all the libraries available - I suppose pangocairo comes along with
the python-pango bindings.
-The snippet bellow can render a sample text in a given font family,
+The snippet bellow can render a sample text in a given font family,
that can be specified as a command line parameter. It also prints
the available font families to stdout.
@@ -59,4 +59,3 @@ the available font families to stdout.
with open("cairo_text.png", "wb") as image_file:
surf.write_to_png(image_file)
-
diff --git a/src/cookbook/pyrsvg.mdwn b/src/cookbook/pyrsvg.mdwn
index e9dd1fe..73840f4 100644
--- a/src/cookbook/pyrsvg.mdwn
+++ b/src/cookbook/pyrsvg.mdwn
@@ -9,22 +9,22 @@ The first demo is directly from the example I found on my drive.
(*) You can find this demo in /usr/share/doc/python-gnome2-desktop/examples/rsvg on \*buntu Gutsy 7.10
#!/usr/bin/env python
-
+
import sys
import cairo
import rsvg
import gtk
-
-
+
+
BORDER_WIDTH = 10
-
-
+
+
def delete_cb(win, event):
gtk.main_quit()
-
-
+
+
def expose_cairo(win, event, svg):
-
+
x, y, w, h = win.allocation
cr = win.window.cairo_create()
cr.set_source_color(win.style.fg[win.state])
@@ -33,33 +33,33 @@ The first demo is directly from the example I found on my drive.
cr.set_line_width(5.0)
cr.set_line_join(cairo.LINE_JOIN_ROUND)
cr.stroke()
-
+
if svg != None:
matrix = cairo.Matrix(3,0,0,3,0, 0)
#cairo.Matrix.rotate( matrix, prop.rot )
cr.transform (matrix)
svg.render_cairo(cr)
-
+
return True
-
+
def main():
win = gtk.Window ()
win.connect("delete-event", delete_cb)
-
+
svg = None
if (len (sys.argv) > 1):
svg = rsvg.Handle(file=sys.argv[1])
else:
raise SystemExit("need svg file")
-
+
win.connect("expose-event", expose_cairo, svg)
-
+
print svg.props.width, svg.props.height, svg.props.em, svg.props.ex
-
+
win.show_all()
win.connect("destroy", lambda w: gtk.main_quit())
gtk.main()
-
+
if __name__ == '__main__':
main()
@@ -71,14 +71,14 @@ I thought I'd see how writing **out** an SVG file from Cairo works, this is a sh
import cairo
import rsvg
import math
-
+
fo = file('test.svg', 'w')
-
+
WIDTH, HEIGHT = 256, 256
-
+
## Prepare a destination surface -> out to an SVG file!
surface = cairo.SVGSurface (fo, WIDTH, HEIGHT)
-
+
## draw something - this taken from the web.
ctx = cairo.Context (surface)
ctx.scale (WIDTH/1.0, HEIGHT/1.0) # Normalizing the canvas
@@ -97,7 +97,7 @@ I thought I'd see how writing **out** an SVG file from Cairo works, this is a sh
ctx.set_source_rgb (0.3, 0.2, 0.5) # Solid color
ctx.set_line_width (0.02)
ctx.stroke ()
-
+
## Do the deed.
surface.finish()
@@ -109,18 +109,17 @@ What happens when you feed the snake its tail?
import cairo
import rsvg
-
+
fo = file('test.svg', 'w')
-
+
WIDTH, HEIGHT = 256, 256
surface = cairo.SVGSurface (fo, WIDTH, HEIGHT)
-
+
ctx = cairo.Context (surface)
-
+
svg = rsvg.Handle(file="test2.svg")
svg.render_cairo(ctx)
-
+
surface.finish()
Well, it works! test.svg comes in and comes out as test2.svg. I don't think it proves anything, but it's fun.
-
diff --git a/src/cookbook/pythoncairopil.mdwn b/src/cookbook/pythoncairopil.mdwn
index ffd8a57..109ac7e 100644
--- a/src/cookbook/pythoncairopil.mdwn
+++ b/src/cookbook/pythoncairopil.mdwn
@@ -5,17 +5,17 @@ Please note that the code below was to only blur an cairo image surface and thus
import cairo, Image, array
im = cairo.ImageSurface.create_from_png("img11.png")
-
+
im1 = Image.frombuffer("RGBA",( im.get_width(),im.get_height() ),im.get_data(),"raw","RGBA",0,1)
-
+
im1 = im1.filter(ImageFilter.BLUR)
im1 = im1.filter(ImageFilter.BLUR)
- im1 = im1.filter(ImageFilter.SMOOTH_MORE)
-
+ im1 = im1.filter(ImageFilter.SMOOTH_MORE)
+
#imgd = im1.tostring("raw","RGBA",0,1)
imgd = im1.tostring()
a = array.array('B',imgd)
-
+
stride = self.width * 4
surface = cairo.ImageSurface.create_for_data (a, cairo.FORMAT_ARGB32,
- self.width, self.height, stride)
+ self.width, self.height, stride)
diff --git a/src/cookbook/quickframework.mdwn b/src/cookbook/quickframework.mdwn
index 5718910..0f6fea3 100644
--- a/src/cookbook/quickframework.mdwn
+++ b/src/cookbook/quickframework.mdwn
@@ -9,32 +9,32 @@ This sample shows how to use a mask (a second source to filter the first source.
import pygtk
pygtk.require('2.0')
import gtk, gobject, cairo
-
+
# Create a GTK+ widget on which we will draw using Cairo
class Screen(gtk.DrawingArea):
-
+
# Draw in response to an expose-event
__gsignals__ = { "expose-event": "override" }
-
+
# Handle the expose-event by drawing
def do_expose_event(self, event):
-
+
# Create the cairo context
cr = self.window.cairo_create()
-
+
# Restrict Cairo to the exposed area; avoid extra work
cr.rectangle(event.area.x, event.area.y,
event.area.width, event.area.height)
cr.clip()
-
+
self.draw(cr, *self.window.get_size())
-
+
def draw(self, cr, width, height):
# Fill the background with gray
cr.set_source_rgb(0.5, 0.5, 0.5)
cr.rectangle(0, 0, width, height)
cr.fill()
-
+
# GTK mumbo-jumbo to show the widget in a window and quit when it's closed
def run(Widget):
window = gtk.Window()
@@ -46,25 +46,25 @@ This sample shows how to use a mask (a second source to filter the first source.
gtk.main()
-
+
## Do all your testing in Shapes ##
-
+
class Shapes(Screen):
def draw(self, cr, width, height):
-
+
## This will draw using a mask.
cr.scale(width,height) #Without this line the mask does not seem to work!
self.linear = cairo.LinearGradient(0, 0, 1, 1)
self.linear.add_color_stop_rgb(0, 0, 0.3, 0.8)
self.linear.add_color_stop_rgb(1, 0, 0.8, 0.3)
-
+
self.radial = cairo.RadialGradient(0.5, 0.5, 0.25, 0.5, 0.5, 0.5)
self.radial.add_color_stop_rgba(0, 0, 0, 0, 1)
self.radial.add_color_stop_rgba(0.5, 0, 0, 0, 0)
-
+
cr.set_source(self.linear)
- cr.mask(self.radial)
-
+ cr.mask(self.radial)
+
run(Shapes)
diff --git a/src/cookbook/renderpdf.mdwn b/src/cookbook/renderpdf.mdwn
index 790daf9..e750e6c 100644
--- a/src/cookbook/renderpdf.mdwn
+++ b/src/cookbook/renderpdf.mdwn
@@ -182,7 +182,7 @@ pdftoimage.c - Render a one page of a PDF file to a cairo image surface.
cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
-
+
status = cairo_status(cr);
if (status)
printf("%s\n", cairo_status_to_string (status));
diff --git a/src/cookbook/roundedrectangles.mdwn b/src/cookbook/roundedrectangles.mdwn
index bf046f8..7421f55 100644
--- a/src/cookbook/roundedrectangles.mdwn
+++ b/src/cookbook/roundedrectangles.mdwn
@@ -4,16 +4,16 @@ From the cairo samples, modified. Gives a very nice shape but takes width and he
def roundedrecA(self,cr,x,y,width,height,radius=5):
#/* a custom shape, that could be wrapped in a function */
- #radius = 5 #/*< and an approximate curvature radius */
+ #radius = 5 #/*< and an approximate curvature radius */
x0 = x+radius/2.0 #/*< parameters like cairo_rectangle */
y0 = y+radius/2.0
rect_width = width - radius
rect_height = height - radius
-
+
cr.save()
#cr.set_line_width (0.04)
#self.snippet_normalize (cr, width, height)
-
+
x1=x0+rect_width
y1=y0+rect_height
#if (!rect_width || !rect_height)
@@ -32,7 +32,7 @@ From the cairo samples, modified. Gives a very nice shape but takes width and he
cr.line_to (x1 , y1 - radius)
cr.curve_to (x1, y1, x1, y1, (x1 + x0)/2, y1)
cr.curve_to (x0, y1, x0, y1, x0, y1- radius)
-
+
else:
if rect_height/2<radius:
cr.move_to (x0, (y0 + y1)/2)
@@ -51,9 +51,9 @@ From the cairo samples, modified. Gives a very nice shape but takes width and he
cr.curve_to (x1, y1, x1, y1, x1 - radius, y1)
cr.line_to (x0 + radius, y1)
cr.curve_to (x0, y1, x0, y1, x0, y1- radius)
-
+
cr.close_path ()
-
+
cr.restore()
##Method B
@@ -68,11 +68,11 @@ From mono moonlight aka mono silverlight. Works very well on larger shapes.
radius_x = w / 2
if radius_y > h - radius_y:
radius_y = h / 2
-
+
#approximate (quite close) the arc using a bezier curve
c1 = ARC_TO_BEZIER * radius_x
c2 = ARC_TO_BEZIER * radius_y
-
+
cr.new_path();
cr.move_to ( x + radius_x, y)
cr.rel_line_to ( w - 2 * radius_x, 0.0)
@@ -83,7 +83,7 @@ From mono moonlight aka mono silverlight. Works very well on larger shapes.
cr.rel_curve_to ( -c1, 0, -radius_x, -c2, -radius_x, -radius_y)
cr.rel_line_to (0, -h + 2 * radius_y)
cr.rel_curve_to (0.0, -c2, radius_x - c1, -radius_y, radius_x, -radius_y)
- cr.close_path ()
+ cr.close_path ()
##Method C
I can't remember where I got this. If you are the author please add your name. Works well on smaller shapes.
@@ -95,7 +95,7 @@ I can't remember where I got this. If you are the author please add your name. W
# * *
# G D
# F****E
-
+
context.move_to(x+r,y) # Move to A
context.line_to(x+w-r,y) # Straight line to B
context.curve_to(x+w,y,x+w,y,x+w,y+r) # Curve to C, Control points are both at Q
@@ -105,7 +105,7 @@ I can't remember where I got this. If you are the author please add your name. W
context.curve_to(x,y+h,x,y+h,x,y+h-r) # Curve to G
context.line_to(x,y+r) # Line to H
context.curve_to(x,y,x,y,x+r,y) # Curve to A
- return
+ return
##Method D
Created by Helton Moraes (heltonbiker at gmail dot com). Uses round arcs and takes advantage of the segment-creation property of cairo.arc() - just draw the arcs, no need to draw straight segments in between.
diff --git a/src/cookbook/svgtopycairo.mdwn b/src/cookbook/svgtopycairo.mdwn
index 2b3ac6a..5c5e815 100644
--- a/src/cookbook/svgtopycairo.mdwn
+++ b/src/cookbook/svgtopycairo.mdwn
@@ -2,14 +2,14 @@
This took a while, the pyparsing had me in knots, but now it's short and sweet. A fuller implementation of what can be done in SVG would be really nice. (Hint...)
-Make sure you pass it a very simple SVG file (from Inkscape is best) -- one that has had all the shapes reduced to paths. Oh, and keep your canvas 400 by 400 or it may draw clear off the screen.
+Make sure you pass it a very simple SVG file (from Inkscape is best) -- one that has had all the shapes reduced to paths. Oh, and keep your canvas 400 by 400 or it may draw clear off the screen.
-**Depends on**
+**Depends on**
1. *elementree*: **import** elementree **as** myDearWatson :) It's a great module for slicing through XML.
2. *pyparsing*: This module is deeply wonderful. I won't pretend to savvy even 1% of it, but it really does the job. They have a great mailing list where I got a lot of help. It let's you parse strings into lists and that is no small feat.
-**SVG Path element**
+**SVG Path element**
To briefly explain, inside an svg file (which is just xml) you'll find a tag named 'g' and under that one or more tags named 'path'. Inside path there is an element called 'd'; that's the actual path. It's formed like this: "COMMAND NUMBER COMMA NUMBER Optionally[NUMBER COMMA NUMBER a few more times]", where COMMAND is M for move, L for line, C for curve and Z for close path. There may be others, but that's what I tackled. Have a look at the pyparsing grammar which makes it fairly clear how different commands have different numbers behind them.
@@ -20,7 +20,7 @@ Please forgive any bugs.
"""\
Usage: drawsvg.py file
file - one SVG file (from Inkscape!) that is all simple paths
-
+
"""
## svg2py Copyright (C) 2007 Donn.C.Ingle
##
@@ -40,39 +40,39 @@ Please forgive any bugs.
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
-
+
import pygtk
pygtk.require('2.0')
import gtk, gobject, cairo
from pyparsing import *
import os, sys
from elementtree import ElementTree as et
-
+
# Create a GTK+ widget on which we will draw using Cairo
class Screen(gtk.DrawingArea):
-
+
# Draw in response to an expose-event
__gsignals__ = { "expose-event": "override" }
-
+
# Handle the expose-event by drawing
def do_expose_event(self, event):
-
+
# Create the cairo context
cr = self.window.cairo_create()
-
+
# Restrict Cairo to the exposed area; avoid extra work
cr.rectangle(event.area.x, event.area.y,
event.area.width, event.area.height)
cr.clip()
-
+
self.draw(cr, *self.window.get_size())
-
+
def draw(self, cr, width, height):
# Fill the background with gray
cr.set_source_rgb(0.5, 0.5, 0.5)
cr.rectangle(0, 0, width, height)
cr.fill()
-
+
# GTK mumbo-jumbo to show the widget in a window and quit when it's closed
def run(Widget):
window = gtk.Window()
@@ -83,12 +83,12 @@ Please forgive any bugs.
window.add(widget)
window.present()
gtk.main()
-
+
## Do the drawing ##
-
+
class Shapes(Screen):
def draw(self, ctx, width, height):
-
+
#Build a string of cairo commands
cairo_commands = ""
command_list = []
@@ -103,21 +103,21 @@ Please forgive any bugs.
cairo_commands += "ctx.line_to(%s,%s);" % (c[0],c[1])
if command == "Z":
cairo_commands += "ctx.close_path();"
-
+
command_list.append(cairo_commands) #Add them to the list
cairo_commands = ""
#Draw it. Only stroked, to fill as per the SVG drawing is another whole story.
- ctx.set_source_rgb(1,0,0)
+ ctx.set_source_rgb(1,0,0)
for c in command_list:
exec(c)
ctx.stroke()
-
+
#Check args:
if len(sys.argv) < 2:
raise SystemExit(__doc__)
file = sys.argv[1]
-
+
## Pyparsing grammar:
## With HUGE help from Paul McGuire <paul at alanweberassociates.com>
## Thanks!
@@ -132,15 +132,15 @@ Please forgive any bugs.
L_command = "L" + Group(couple)
Z_command = "Z"
svgcommand = M_command | C_command | L_command | Z_command
- phrase = OneOrMore(Group(svgcommand))
-
+ phrase = OneOrMore(Group(svgcommand))
+
## Find and open the svg file
xml_file = os.path.abspath(__file__)
xml_file = os.path.dirname(xml_file)
xml_file = os.path.join(xml_file, file)
-
+
tree = et.parse(xml_file)
-
+
ns = "http://www.w3.org/2000/svg" #The XML namespace.
paths = []
for group in tree.getiterator('{%s}g' % ns):
@@ -148,5 +148,5 @@ Please forgive any bugs.
p = e.get("d")
tokens = phrase.parseString(p.upper())
paths.append(tokens) # paths is a global var.
-
+
run(Shapes)
diff --git a/src/cookbook/win32quickstart.mdwn b/src/cookbook/win32quickstart.mdwn
index dcd7feb..1d45dc5 100644
--- a/src/cookbook/win32quickstart.mdwn
+++ b/src/cookbook/win32quickstart.mdwn
@@ -9,17 +9,17 @@ The following is a minimal windows application that uses cairo. It has double bu
from winxpgui import *
except ImportError:
from win32gui import *
-
+
import win32con
import sys, os
import cairo
-
+
def WebColour(sCol):
#print sCol
ic = [int(sCol[i:i+2], 16)/255.0 for i in range(1, 7, 2)]
#print ic
return ic
-
+
def roundedRectangle(cr,x,y,w,h,radius_x=5,radius_y=5):
#from mono moonlight aka mono silverlight
#test limits (without using multiplications)
@@ -29,11 +29,11 @@ The following is a minimal windows application that uses cairo. It has double bu
radius_x = w / 2
if radius_y > h - radius_y:
radius_y = h / 2
-
+
#approximate (quite close) the arc using a bezier curve
c1 = ARC_TO_BEZIER * radius_x
c2 = ARC_TO_BEZIER * radius_y
-
+
cr.new_path();
cr.move_to ( x + radius_x, y)
cr.rel_line_to ( w - 2 * radius_x, 0.0)
@@ -45,10 +45,10 @@ The following is a minimal windows application that uses cairo. It has double bu
cr.rel_line_to (0, -h + 2 * radius_y)
cr.rel_curve_to (0.0, -c2, radius_x - c1, -radius_y, radius_x, -radius_y)
cr.close_path ()
-
-
+
+
class MainWindow(object):
- def __init__(self):
+ def __init__(self):
message_map = {
win32con.WM_DESTROY: self.OnDestroy,
win32con.WM_PAINT: self.OnPaint,
@@ -75,18 +75,18 @@ The following is a minimal windows application that uses cairo. It has double bu
0, 0, 550, 350, \
0, 0, hinst, None)
UpdateWindow(self.hwnd)
-
-
+
+
def OnKey(self, hWnd, msg, wParam, lparam):
if wParam == 38: #up
print "up"
elif wParam == 40: #down
print "down"
-
+
def OnClick(self, hWnd, msg, wparam, lparam):
x = LOWORD(lparam)
- y = HIWORD(lparam)
-
+ y = HIWORD(lparam)
+
def Render(self):
try:
InvalidateRect(self.hwnd, None, True)
@@ -94,74 +94,74 @@ The following is a minimal windows application that uses cairo. It has double bu
except:
print "That didn't work"
return False
-
- def OnPaint(self, hWnd, msg, wparam, lparam):
+
+ def OnPaint(self, hWnd, msg, wparam, lparam):
hdc, ps = BeginPaint(hWnd)
rc = GetClientRect(hWnd)
- left, top, right, bottom = rc
-
+ left, top, right, bottom = rc
+
width = right - left
height = bottom - top
x = left
- y = top
-
- _buffer = CreateCompatibleDC(hdc)
+ y = top
+
+ _buffer = CreateCompatibleDC(hdc)
#Double Buffer Stage 1
hBitmap = CreateCompatibleBitmap(hdc,width,height)
hOldBitmap = SelectObject(_buffer, hBitmap )
-
-
+
+
surf = cairo.Win32Surface(_buffer)
- ctx = cairo.Context(surf)
-
+ ctx = cairo.Context(surf)
+
ctx.set_source_rgb(1,1,1)
ctx.paint()
-
-
+
+
roundedRectangle(ctx, 50, 50, 250, 250, 10, 10)
- clr = WebColour("#F0FEE9")
+ clr = WebColour("#F0FEE9")
ctx.set_source_rgb(clr[0],clr[1],clr[2])
ctx.fill_preserve()
- clr = WebColour("#B3FF8D")
+ clr = WebColour("#B3FF8D")
ctx.set_source_rgb(clr[0],clr[1],clr[2])
- ctx.stroke()
-
+ ctx.stroke()
+
ctx.set_source_rgb(0,0,0)
ctx.select_font_face("Arial",cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
- ctx.set_font_size(10)
-
+ ctx.set_font_size(10)
+
txt = "Cairo is the greatest thing!"
-
- ctx.move_to(5,10)
+
+ ctx.move_to(5,10)
ctx.show_text(txt)
-
+
surf.finish()
-
+
BitBlt(hdc,0, 0, width, height,
- _buffer, x, y, win32con.SRCCOPY)
-
- SelectObject( _buffer, hOldBitmap )
- DeleteObject( hBitmap )
- DeleteDC( _buffer )
-
- EndPaint(hWnd,ps)
-
+ _buffer, x, y, win32con.SRCCOPY)
+
+ SelectObject( _buffer, hOldBitmap )
+ DeleteObject( hBitmap )
+ DeleteDC( _buffer )
+
+ EndPaint(hWnd,ps)
+
def OnCursor(self, hwnd, msg, wparam, lparam):
#IDC_HAND = 32649
#IDC_ARROW
cur_normal = LoadCursor(0, win32con.IDC_ARROW)
SetCursor(cur_normal)
-
+
def OnBackgroundErase(self, hwnd, msg, wparam, lparam):
return False
-
-
+
+
def OnDestroy(self, hwnd, msg, wparam, lparam):
#nid = (self.hwnd, 0)
#Shell_NotifyIcon(NIM_DELETE, nid)
- PostQuitMessage(0) # Terminate the app.
+ PostQuitMessage(0) # Terminate the app.
print "Exited."
-
-
+
+
w=MainWindow()
PumpMessages()
diff --git a/src/documentation.mdwn b/src/documentation.mdwn
index a6e4cab..04a302f 100644
--- a/src/documentation.mdwn
+++ b/src/documentation.mdwn
@@ -85,8 +85,8 @@ Tutorials
* [[Using_Cairo_with_OpenGL|OpenGL]] How to make use of cairo from within
OpenGL-programs.
- * [The Cairo graphics tutorial][13] A 100+ pages tutorial in C programming
- language and GTK+ library, the largest tutorial on the Internet, ZetCode
+ * [The Cairo graphics tutorial][13] A 100+ pages tutorial in C programming
+ language and GTK+ library, the largest tutorial on the Internet, ZetCode
* [Monochrome icon][14] by Mike Massonnet, March 2010. A step-by-step tutorial that explains how to
include a monochrome icon inside a GTK+ application. It starts with a
diff --git a/src/documentation/using_the_postscript_surface.mdwn b/src/documentation/using_the_postscript_surface.mdwn
index eb41990..890489b 100644
--- a/src/documentation/using_the_postscript_surface.mdwn
+++ b/src/documentation/using_the_postscript_surface.mdwn
@@ -11,7 +11,7 @@ cairo_scale (cr, 72/25.4, 72/25.4);
inches
cairo_scale (cr, 72, 72);
-
+
# Page Size
The page size is in points. For example A4 paper is 595 points wide by 842 points high. Letter paper is 612 by 792 points.
@@ -33,7 +33,7 @@ Note that when when Language Level 3 is permitted the, "LanguageLevel" DSC comme
When generating PostScript output that will be imported as diagrams into applications the EPS format is used. EPS files must contain only one page. Language level 2 or 3 can be used with EPS mode.
-Note that cairo does not include the device independent preview.
+Note that cairo does not include the device independent preview.
The [Encapsulated PostScript Specification](https://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf) contains describes how to embed EPS files into PostScript.
@@ -68,7 +68,7 @@ The following code prints one portrait page followed by one landscape page.
void draw (cairo_t *cr, const char *text, int width, int height)
{
char buf[100];
-
+
cairo_rectangle (cr, BORDER, BORDER, width - 2*BORDER, height - 2*BORDER);
cairo_set_line_width (cr, 2);
cairo_stroke (cr);
@@ -89,7 +89,7 @@ The following code prints one portrait page followed by one landscape page.
cairo_surface_t *surface;
cairo_t *cr;
cairo_matrix_t matrix;
-
+
surface = cairo_ps_surface_create ("output.ps", PAGE_WIDTH, PAGE_HEIGHT);
cr = cairo_create (surface);
@@ -128,7 +128,7 @@ The following code prints one portrait page followed by one landscape page.
When generating landscape EPS output the surface width can be greater than the height.
-For example:
+For example:
surface = cairo_ps_surface_create (filename, 400, 200)
cairo_ps_surface_set_eps (surface, TRUE);
@@ -145,9 +145,9 @@ Fonts are always subsetted and embedded.
Cairo will ensure that the PostScript output looks the same as the image surface for the same set of cairo commands. When cairo drawing operations are performed that cannot be natively represented in PostScript, the drawing is rasterized and embedded in the output.
-Since cairo 1.6 the rasterization of unsupported operations is limited to the smallest rectangle or set of rectangles required to draw the unsupported operations.
+Since cairo 1.6 the rasterization of unsupported operations is limited to the smallest rectangle or set of rectangles required to draw the unsupported operations.
-Fallback images are the main cause of large file sizes and slow printing times. Fallback images have a comment containing the size and location of the fallback.
+Fallback images are the main cause of large file sizes and slow printing times. Fallback images have a comment containing the size and location of the fallback.
> grep 'Fallback' output.ps
output.ps:% Fallback Image: x=100, y=100, w=299, h=50 res=300dpi size=783750
@@ -172,5 +172,3 @@ The following table lists the features that are natively supported by the PostSc
CAIRO_OPERATOR_SOURCE yes
CAIRO_OPERATOR_OVER yes (opaque colors only)
all other operators no
-
-
diff --git a/src/end_to_end_build_for_mac_os_x.mdwn b/src/end_to_end_build_for_mac_os_x.mdwn
index 9dfecc0..1d5f752 100644
--- a/src/end_to_end_build_for_mac_os_x.mdwn
+++ b/src/end_to_end_build_for_mac_os_x.mdwn
@@ -23,8 +23,8 @@ Designate a directory to work in. Clean it out and then we'll do all work in the
### Download and untar tarballs
Use curl to download FOUR tarballs: pkg-config, libpng, pixman, cairo. Adjust specific version paths as desired
-
-
+
+
curl http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz -o pkgconfig.tgz
curl ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.40.tar.gz -o libpng.tgz
curl http://www.cairographics.org/releases/pixman-0.16.2.tar.gz -o pixman.tgz
@@ -144,5 +144,3 @@ Your freshly copied dylib's still have one problem. They have absolute filenames
### Congratulations!
You've got a Frameworks directory you can move around now with relocatable path entries in it. Place it in your .app bundle in the Contents directory, next to the MacOS directory. In your executable, you can load and bind Cairo by passing "@executable_path/../Frameworks/libcairo.2.dylib" to dlopen().
-
-
diff --git a/src/end_to_end_build_for_win32.mdwn b/src/end_to_end_build_for_win32.mdwn
index c619f6c..070d20b 100644
--- a/src/end_to_end_build_for_win32.mdwn
+++ b/src/end_to_end_build_for_win32.mdwn
@@ -4,7 +4,7 @@ Original Author: Travis Griggs (travisgriggs at gmail.com)
Original Version: 1.8.8
-Other Tested Versions:
+Other Tested Versions:
Tools Needed:
<ul>
@@ -163,7 +163,7 @@ This is similiar to pixman. There's an additional edit we do to the Makefile (re
make -f Makefile.win32 "CFG=release"
- if you have errors, try to remove all chars " from src/cairo-features.h
+ if you have errors, try to remove all chars " from src/cairo-features.h
### Congratulations!
You've got a standalone cairo.dll... (found in %ROOTDIR%\cairo\src\release)
diff --git a/src/examples.mdwn b/src/examples.mdwn
index 609aa5c..951ebec 100644
--- a/src/examples.mdwn
+++ b/src/examples.mdwn
@@ -211,7 +211,7 @@ small Cairo C__ in FLTK1 example of animation along spline paths.
* Nicola Fontana is working on [ADG][68] (link broken?), a non-interactive cairo canvas
- * Juan Manuel Mouriz also is working on [sanaviron][72], a 2D drawing engine
+ * Juan Manuel Mouriz also is working on [sanaviron][72], a 2D drawing engine
fully written in Python to represent composite vector graphics. This
is essentially a GTK+ Cairo based canvas.
diff --git a/src/hscairo.mdwn b/src/hscairo.mdwn
index 56215d7..1664e09 100644
--- a/src/hscairo.mdwn
+++ b/src/hscairo.mdwn
@@ -1,12 +1,12 @@
[[!meta title="Haskell bindings"]]
The haskell bindings are available via darcs:
-
+
darcs get http://ofb.net/~abe/darcs/cairo
There are also haskell bindings for libsvg-cairo, designed to work
well with hscairo:
-
+
darcs get http://ofb.net/~abe/darcs/svg-cairo
-- Abe Egnor (1 Dec 2004)
@@ -23,7 +23,7 @@ blog](http://haskell.org/gtk2hs/archives/category/cairo/).
The current version of these bindings are built as part of Gtk2Hs but
they will eventually be released separately.
-
+
darcs get --partial http://darcs.haskell.org/gtk2hs/
-- Duncan Coutts (11 Jan 2006)
diff --git a/src/lists.mdwn b/src/lists.mdwn
index 34d94bd..fed7c25 100644
--- a/src/lists.mdwn
+++ b/src/lists.mdwn
@@ -43,7 +43,7 @@ this may cause.
</tr>
<tr>
<td>
- cairo-announce at cairographics.org
+ cairo-announce at cairographics.org
</td>
<td>
Moderated, low-traffic list for announcements (i.e., new cairo
@@ -58,7 +58,7 @@ this may cause.
</tr>
<tr>
<td>
- cairo-commit at cairographics.org
+ cairo-commit at cairographics.org
</td>
<td>
Automated git commit messages of every change to the code of
@@ -75,7 +75,7 @@ this may cause.
</tr>
<tr>
<td>
- cairo-bugs at cairographics.org
+ cairo-bugs at cairographics.org
</td>
<td>
Automated messages of every change to any bug in
diff --git a/src/news/cairo-1.0.0.mdwn b/src/news/cairo-1.0.0.mdwn
index bf2e3dd..84d7fc2 100644
--- a/src/news/cairo-1.0.0.mdwn
+++ b/src/news/cairo-1.0.0.mdwn
@@ -4,31 +4,31 @@
2005-08-24:
The cairo team is very pleased to announce cairo 1.0 available from:
-
+
http://cairographics.org/releases/cairo-1.0.0.tar.gz
-
+
which can be verified with:
-
+
http://cairographics.org/releases/cairo-1.0.0.tar.gz.sha1
abc50d6a657cba15b3956c8c3aaea080b71172bb cairo-1.0.0.tar.gz
-
+
http://cairographics.org/releases/cairo-1.0.0.tar.gz.sha1.asc
(signed by Carl Worth)
-
+
All future 1.x.y releases of cairo will be source and binary
compatible with cairo 1.0.0.
-
+
With this release, we'd like to remind everyone of the proper position
for the number 1 in software releases, which is at the beginning.
While this release does mark the culmination of months or years of
work by many people, it's more significant in marking what is yet to
come. Cairo has just begun and we're excited to see where it will go
from here.
-
+
In this release, we have marked three backends as "supported"
-
+
xlib, image, win32
-
+
and all other backends as "experimental" which as such, do not have
part in the API guarantees of this release. The experimental backends
will not be compiled by default, but they are still available for
@@ -39,71 +39,71 @@
we do think it is important to carefully advertise which backends are
not yet up to the standards of stability, completeness, and rendering
fidelity expected from a cairo backend.
-
+
These "experimental" backends are certainly not going away, and we
hope that each one will become a "supported" backend in a future cairo
release quite soon.
-
+
-Carl
-
+
PS. Call it "cairo" or the "cairo graphics library", but try not to
ever call it "Cairo" unless writing it at the beginning of a sentence.
-
+
What is cairo
=============
Cairo is a 2D graphics library with support for multiple output
devices. Currently supported output targets include the X Window
System, win32, and image buffers. Experimental backends include OpenGL
(through glitz), Quartz, XCB, PostScript and PDF file output.
-
+
Cairo is designed to produce consistent output on all output media
while taking advantage of display hardware acceleration when available
(for example, through the X Render Extension).
-
+
The cairo API provides operations similar to the drawing operators of
PostScript and PDF. Operations in cairo including stroking and filling
cubic Bézier splines, transforming and compositing translucent images,
and antialiased text rendering. All drawing operations can be
transformed by any affine transformation (scale, rotation, shear,
etc.).
-
+
Cairo has been designed to let you draw anything you want in a modern
2D graphical user interface. At the same time, the cairo API has been
designed to be as fun and easy to learn as possible. If you're not
having fun while programming with cairo, then we have failed
somewhere---let us know and we'll try to fix it next time around.
-
+
Cairo is free software and is available to be redistributed and/or
modified under the terms of either the GNU Lesser General Public
License (LGPL) version 2.1 or the Mozilla Public License (MPL) version
1.1.
-
+
Where to get more information about cairo
=========================================
The primary source of information about cairo is:
-
+
http://cairographics.org/
-
+
The latest releases of cairo can be found at:
-
+
http://cairographics.org/releases
-
+
Snapshots of in-development versions of cairo:
-
+
http://cairographics.org/snapshots
-
+
The programming manual for using cairo:
-
+
http://cairographics.org/manual
-
+
Mailing lists for contacting cairo users and developers:
-
+
http://cairographics.org/lists
-
+
Answers to some frequently asked questions about cairo:
-
+
http://cairographics.org/FAQ
-
+
What's new in 1.0.0 compared to 0.9.2
=====================================
Experimental backends
@@ -113,17 +113,17 @@
this release. They are not built by default, even when the required
libraries are available, and must be enabled explicitly with
--enable options to configure.
-
+
It is very painful for us to be pushing out a major release without
these backends enabled. There has been a tremendous amount of work
put into each one and all are quite functional to some
extent. However, each also has some limitations. And none of these
backends have been tested to the level of completeness and
correctness that we expect from cairo backends.
-
+
We do encourage people to experiment with these backends and report
success, failure, or means of improving them.
-
+
Operator behavior
-----------------
* Prior to 0.9.0 the SOURCE, CLEAR and a number of other operators
@@ -135,72 +135,72 @@
the behavior of SOURCE and CLEAR has been changed again. They now
affect areas only within both the source and shape. We can write
the new operators as:
-
+
SOURCE: dest' = (mask IN clip) ? source : dest
CLEAR: dest' = (mask IN clip) ? 0 : dest
-
+
Behavior and API changes
------------------------
* Setting the filter on a gradient pattern would change the
interpolation between color stops away from the normal linear
interpolation. This dubious behavior has been removed.
-
+
* The CAIRO_CONTENT_VALID() and CAIRO_FORMAT_VALID() macros --
implementation details that leaked into cairo.h -- have been moved
into an internal header.
-
+
* The cairo_show_text function now advances the current point
according to the total advance values of the string.
-
+
API additions
-------------
* cairo_set_dash can now detect error and can set
CAIRO_STATUS_INVALID_DASH.
-
+
Features
--------
* When compiled against recent versions of fontconfig and FreeType,
artificial bold fonts can now be turned on from fonts.conf using
the FC_EMBOLDEN fontconfig key.
-
+
Optimization
------------
* The compositing code from the 'xserver' code tree has now been
completely merged into libpixman. This includes MMX optimization of
common operations.
-
+
* The image transformation code in libpixman has been improved and
now performs significantly faster.
-
+
Bug fixes
---------
* Several crashes related to corruption in the font caches have been
fixed.
-
+
* All test cases now match pixel-for-pixel on x86 and PPC; this
required fixing bugs in the compositing, stroking, and pattern
rendering code.
-
+
* Negative dash offsets have been fixed to work correctly.
-
+
* The stroking of paths with multiple subpaths has now been fixed to
apply caps to all subpaths rather than just the last one.
-
+
* Many build fixes for better portability on various systems.
-
+
* Lots of other bug fixes, but we're too tired to describe them in
more detail here.
-
+
Acknowledgments
================
We would like to express our appreciation to everyone who has
contributed to making cairo everything it is today. Hundreds of people
have debated API on mailing lists, tested early snapshots, submitted
bug reports, and contributed code.
-
+
The following list has been extracted from cairo's ChangeLog, and we
recognize that is only a very small subset of those who have helped.
-
+
Josh Aas - Memory leak fix for quartz backend
Shawn T. Amundson - Build fix
Olivier Andrieu - PNG backend
@@ -216,7 +216,7 @@
Behdad Esfahbod - Release script improvements, bug fixes.
Bertram Felgenhauer - Fixes for subtle arithmetic errors
J. Ali Harlow - win32 backend updates
- Richard Henderson - "slim" macros for better shared libraries
+ Richard Henderson - "slim" macros for better shared libraries
James Henstridge - Build fixes related to freetype
Graydon Hoare - Support for non-render X server, first real text support
Thomas Hunger - Initial version of cairo_in_stroke/fill
@@ -251,5 +251,5 @@
Vladimir Vukicevic - Bug fix for clipping
Carl Worth - Original library, support for paths, images
Richard D. Worth - Build fixes for cygwin
-
+
(please let us know if you're aware of someone we've missed)
diff --git a/src/news/cairo-1.10.0.mdwn b/src/news/cairo-1.10.0.mdwn
index 038fa8d..d535d47 100644
--- a/src/news/cairo-1.10.0.mdwn
+++ b/src/news/cairo-1.10.0.mdwn
@@ -46,7 +46,7 @@
applications to understand issues and as a means for profiling
real-world usage of cairo.
- The traces generated by cairo-trace have been collected in
+ The traces generated by cairo-trace have been collected in
git://git.cairographics.org/git/cairo-traces
diff --git a/src/news/cairo-1.12.16.mdwn b/src/news/cairo-1.12.16.mdwn
index ee0aa85..7db2f9b 100644
--- a/src/news/cairo-1.12.16.mdwn
+++ b/src/news/cairo-1.12.16.mdwn
@@ -239,5 +239,5 @@
egag (1):
xlib: Aquire display before using it in DEBUG message.
- --
+ --
Chris Wilson, Intel Open Source Technology Centre
diff --git a/src/news/cairo-1.12.2.mdwn b/src/news/cairo-1.12.2.mdwn
index 115130c..fab123a 100644
--- a/src/news/cairo-1.12.2.mdwn
+++ b/src/news/cairo-1.12.2.mdwn
@@ -48,7 +48,7 @@
Allow applications to create 0x0 xlib surfaces, such as used by LibreOffice.
https://bugs.freedesktop.org/show_bug.cgi?id=49118
-
+
Trim composite extents for SOURCE/CLEAR operators to the mask.
Use fallback fonts in PDF for unhandled computed glyph widths
diff --git a/src/news/cairo-1.14.4.mdwn b/src/news/cairo-1.14.4.mdwn
index aad76ef..50973ac 100644
--- a/src/news/cairo-1.14.4.mdwn
+++ b/src/news/cairo-1.14.4.mdwn
@@ -267,7 +267,7 @@
江頭幸路 (1):
Avoid appending an empty slot to an user data array when user_data is NULL.
- --
+ --
cairo mailing list
cairo at cairographics.org
http://lists.cairographics.org/mailman/listinfo/cairo
diff --git a/src/news/cairo-1.9.8.mdwn b/src/news/cairo-1.9.8.mdwn
index 0080007..2979b5f 100644
--- a/src/news/cairo-1.9.8.mdwn
+++ b/src/news/cairo-1.9.8.mdwn
@@ -90,7 +90,7 @@
The Cairo region API was actually added a couple of snapshots ago, but we
forgot to mention it at the time. A simple API for the handling of
rectangular pixel-aligned regions by Soeren Sandmann.
-
+
Backend-specific improvements
-----------------------------
diff --git a/src/operators.mdwn b/src/operators.mdwn
index 69b3d63..505cbac 100644
--- a/src/operators.mdwn
+++ b/src/operators.mdwn
@@ -99,7 +99,7 @@ conventions:
by a tuple (r, g, b, a). We will use "x" as a shorthand for any
color component, since they are always treated the same. "a"
describes the alpha value (opacity) and is treated differently.
-
+
3. The product of xA and aA is described by xaA. xaB and xaR have
analogous meaning.
@@ -156,7 +156,7 @@ source. In cairo, this operator is **bounded**.
<div class="tutright">[[!img "over.png" link="no"]]</div>
The image shows what you would expect if you held two semi-transparent
-slides on top of each other. This operator is cairo's default operator.
+slides on top of each other. This operator is cairo's default operator.
The output of the `OVER` operator is the same for both bounded and
unbounded source.
@@ -700,7 +700,7 @@ was conceived of as an optimisation of the XRender-kind
definition to take advantage of the fact that for many operators the two coincide.
The Bounded definition is a variation of the XRender-kind
definition where the mask is considered to be a part of the clip. It
-is used for the SOURCE and CLEAR operators only, and is used
+is used for the SOURCE and CLEAR operators only, and is used
to make those operators be explicitly bounded by <i>mask</i>.
The following table gives the rendering equation used by each of cairo's
operators. The entries marked with Any are operators for
@@ -773,7 +773,7 @@ which all three variants coincide.
* The original paper by Thomas Porter and Tom Duff:
<http://keithp.com/~keithp/porterduff/p253-porter.pdf>,
-
+
* The description of the X Rendering Extension by Keith Packard
is where the information about the `ADD` and `SATURATE` operators
comes from:
diff --git a/src/pycairo/resources.mdwn b/src/pycairo/resources.mdwn
index 5657fc6..8671ec6 100644
--- a/src/pycairo/resources.mdwn
+++ b/src/pycairo/resources.mdwn
@@ -15,7 +15,7 @@ Precompiled binaries for the Microsoft Windows platform can be obtained from the
* [PyCha][13]: PYthon CHArts - a Python package for drawing charts
* [PyGoocanvas][5]: python bindings for GooCanvas which is a canvas widget for GTK+
* [PyGTK][14]: GTK+ for Python.
- * rsvg: part of [gnome-python-desktop][16], it provides Python bindings for librsvg
+ * rsvg: part of [gnome-python-desktop][16], it provides Python bindings for librsvg
# Some Applications Using pycairo
diff --git a/src/pycairo/tutorial.mdwn b/src/pycairo/tutorial.mdwn
index e4ba239..d7d0403 100644
--- a/src/pycairo/tutorial.mdwn
+++ b/src/pycairo/tutorial.mdwn
@@ -29,7 +29,7 @@ Nearly all the work revolves around using the cairo.Context (or cairo_t the cair
* One of cairo's most powerful features is that it can output graphics in many different formats (it can use multiple back ends). For printing, we can have cairo translate our graphics into Postscript to be sent off to the printer. For on screen display, we can have cairo translate our graphics into something glitz can understand for hardware accelerated rendering! It has many more important and useful target back ends.
On initializing the cairo.Context, we set its target back end, supplying a few details (such as colour depth and size), as in the example below.
-
+
# Example
#!/usr/bin/env python
diff --git a/src/rcairo.mdwn b/src/rcairo.mdwn
index 5e79b7c..a4461b8 100644
--- a/src/rcairo.mdwn
+++ b/src/rcairo.mdwn
@@ -62,6 +62,6 @@ For developers:
# Dependencies (cairo binding)
- * cairo, cairo development files
+ * cairo, cairo development files
- * ruby, ruby header development files
+ * ruby, ruby header development files
diff --git a/src/roadmap.mdwn b/src/roadmap.mdwn
index c7435de..dd8370a 100644
--- a/src/roadmap.mdwn
+++ b/src/roadmap.mdwn
@@ -79,7 +79,7 @@ to get involved with cairo.
✓ SHM transport for image transfers to and form the X server.
✓ Make font handling by pango/cairo/fontconfig fully threadsafe.
-
+
# cairo 1.14 (Oct 13, 2014)
diff --git a/src/sharplinescale.mdwn b/src/sharplinescale.mdwn
index 12178d4..bb841d8 100644
--- a/src/sharplinescale.mdwn
+++ b/src/sharplinescale.mdwn
@@ -11,10 +11,10 @@ Feel free to fix it or comment in [my blog](http://blogs.gnome.org/frob/)
#!/usr/bin/env python
import gtk
import cairo
-
+
def shift(x,sz):
return 0.5-(x*sz)%1
-
+
def lineshift(x1,y1,x2,y2,sz):
dx1 = shift(x1,sz)
dy1 = shift(y1,sz)
@@ -40,7 +40,7 @@ Feel free to fix it or comment in [my blog](http://blogs.gnome.org/frob/)
self.add(self.da)
self.da.connect('expose_event', self.expose)
self.show_all()
-
+
def expose (self,da,event):
ctx = da.window.cairo_create()
sz = self.zoom
@@ -49,7 +49,7 @@ Feel free to fix it or comment in [my blog](http://blogs.gnome.org/frob/)
## red 'x' starts here
ctx.save()
## coords of the 1st stem
- x1,y1,x2,y2 = 30,10,50,30
+ x1,y1,x2,y2 = 30,10,50,30
ctx.set_source_rgb(1,0,0)
m = cairo.Matrix(self.zoom,0,0,self.zoom,0,0)
ctx.transform(m)
@@ -68,7 +68,7 @@ Feel free to fix it or comment in [my blog](http://blogs.gnome.org/frob/)
ctx.line_to(x2,y2)
ctx.stroke()
ctx.restore()
-
+
## black '+' starts here
ctx.save()
x1,y1,x2,y2 = 10,20,20,20
@@ -106,6 +106,6 @@ Feel free to fix it or comment in [my blog](http://blogs.gnome.org/frob/)
def main():
MainWindow()
gtk.main()
-
+
if __name__ == '__main__':
main()
\ No newline at end of file
diff --git a/src/style.css b/src/style.css
index 4a79af7..dd2f270 100644
--- a/src/style.css
+++ b/src/style.css
@@ -250,7 +250,7 @@ input#openid_url {
border: 2px solid;
background-color: #dee;
color: black;
-
+
/* Nonstandard, but very nice. */
/*
opacity: 0.95;
@@ -278,6 +278,6 @@ legend {
#signin_openid {
padding: 10px 10px;
border: 1px solid #aaa;
- background: #eee;
+ background: #eee;
color: black !important;
}
diff --git a/src/summerofcode/ideas.mdwn b/src/summerofcode/ideas.mdwn
index 2a05bce..45bb80b 100644
--- a/src/summerofcode/ideas.mdwn
+++ b/src/summerofcode/ideas.mdwn
@@ -113,19 +113,19 @@ challenge you're looking for.
* [Hard] Add appropriate color-management support to cairo.
- Cairo needs the ability to allow for color management. By this project it
- will become possible to work in different color spaces, convert
- automatically to blend different content and tag graphics objects to tell
- backends about the color spaces involved. The color space information
+ Cairo needs the ability to allow for color management. By this project it
+ will become possible to work in different color spaces, convert
+ automatically to blend different content and tag graphics objects to tell
+ backends about the color spaces involved. The color space information
will follow the ICC standard.
- In this project you will learn about the constraints at different OS'es and handle API abstraction.
- During the programming work you will design and implement the
- corresponding means covering frontside API's and backend specific code due
+ In this project you will learn about the constraints at different OS'es and handle API abstraction.
+ During the programming work you will design and implement the
+ corresponding means covering frontside API's and backend specific code due
to file formats and other specific requirements.
- A small application, showing the new capabilities, will help in spotting
+ A small application, showing the new capabilities, will help in spotting
problems and can later be used for demonstrations.
- A unit test and documentation is required for maintainablility and further
+ A unit test and documentation is required for maintainablility and further
easy deployment.
Some relevant threads from various mailing lists:
@@ -141,7 +141,7 @@ challenge you're looking for.
The new image format will implement the [scRGB](http://en.wikipedia.org/wiki/Scrgb) colorspace.
This involves either extending the pixman library to support the new format, or write code for
- Porter-Duff compositing on the new format and make cairo use them for ARGB64.
+ Porter-Duff compositing on the new format and make cairo use them for ARGB64.
Conversions between the 16-bit floats used by colour spaces such as scRGB and 32-bit floats
should use the algorithms explained in Jeroen van der Zijp’s [Fast Half Float Conversions](ftp://www.fox-toolkit.org/pub/fasthalffloatconversion.pdf).
@@ -155,9 +155,9 @@ challenge you're looking for.
* [Hard] Add support for PDF/PostScript Type 6 (Coons patch mesh) and/or Type 7 (Tensor-Product patch mesh) shading functions to the image backend
The Type 6 shading is a special case of the Type 7 shading so only implementing Type 7 may be all that is required.
-
+
One possible solution would be to create a triangle mesh (similar to Type 4 shadings) from the Type 7 patch mesh and shade the triangles using Gouraud shading.
-
+
The [Poppler](http://poppler.freedesktop.org/) source may be used to get an idea how Poppler renders these gradients . However the approach Poppler uses of recursively breaking each patch into smaller patches then filling the tiny patches with a solid color is not appropriate for cairo due to the visible seams between patches due to antialising.
The algorithm for Gouraud shading is in many books on computer graphics.
@@ -169,7 +169,7 @@ challenge you're looking for.
[PDF Reference](http://www.adobe.com/devnet/pdf/pdf_reference.html)
-
+
* [Hard ?] Implement path operations like combine/intersect/overlay
diff --git a/src/threaded_animation_with_cairo.mdwn b/src/threaded_animation_with_cairo.mdwn
index 12f618e..b9a671e 100644
--- a/src/threaded_animation_with_cairo.mdwn
+++ b/src/threaded_animation_with_cairo.mdwn
@@ -41,7 +41,7 @@ A minimal thread-aware gtk program might look like:
}
##Setting up Callbacks for Animation
-We will use a `g_timeout_add` to call our `do_draw()` routine at 30 fps. Eventually, our `do_draw` will draw to a global `GdkPixmap` and we will paint this pixmap to the screen upon an `expose_event`. It is considered good practice to draw on a widget during its `expose_event` only.
+We will use a `g_timeout_add` to call our `do_draw()` routine at 30 fps. Eventually, our `do_draw` will draw to a global `GdkPixmap` and we will paint this pixmap to the screen upon an `expose_event`. It is considered good practice to draw on a widget during its `expose_event` only.
#include <gtk/gtk.h>
#include <unistd.h>
@@ -87,26 +87,26 @@ We will use a `g_timeout_add` to call our `do_draw()` routine at 30 fps. Eventu
}
* `g_thread_init(NULL)` starts a bunch of threading preparation. This functions should only be called once in any given program. Consequentially, it is called as `if (!g_thread_supported ()){ g_thread_init(NULL); }` This is not strictly necessary (because we are fully aware that `g_threads_init()` is called nowhere else in our code; however, when integrating with other projects, it is a good safety precaution.
- * `g_signal_connect(G_OBJECT(window), "configure_event", G_CALLBACK(on_window_configure_event), NULL)` adds a callback to the configure event so that we can detect and handle resizes.
+ * `g_signal_connect(G_OBJECT(window), "configure_event", G_CALLBACK(on_window_configure_event), NULL)` adds a callback to the configure event so that we can detect and handle resizes.
* `gtk_widget_set_app_paintable(window, TRUE)` and `gtk_widget_set_double_buffered(window, FALSE)` tells gtk that we will be doing our own buffering of the window
- * `(void)g_timeout_add(33, (GSourceFunc)timer_exe, window)` adds a timer that will be executed by `gtk_main()` 30 times a second (unless `gtk_main()` is too busy with other things). We pass it the name of the function we'd like to call `timer_exe` cast as a `GSourceFunc` and we also pass it a pointer to the object we'd like to draw on, this time
+ * `(void)g_timeout_add(33, (GSourceFunc)timer_exe, window)` adds a timer that will be executed by `gtk_main()` 30 times a second (unless `gtk_main()` is too busy with other things). We pass it the name of the function we'd like to call `timer_exe` cast as a `GSourceFunc` and we also pass it a pointer to the object we'd like to draw on, this time
`window`.
##Timer Function
Our timer function will be responsible for launching a new thread that executes our `do_draw()` function. It will then artifically send an expose event to our window so that
it knows it should redraw (sending an expose event rather than doing the drawing ourself will allow gtk to process events closer tot he way it wants).
-Before, we implement our timer function, we must consider one important issue. If our drawing application is going to take a long time (longer than 1/30th of a second) then simply launching a new drawing thread every time the timer executes could result in a pile-up of threads and a lot of memory badness. To solve this problem, we will have a variable `currently_drawing`. If `currently_drawing=0` then it is safe to launch a drawing thread. If it isn't, we know we haven't finished the drawing we started last time! Using this solution instead of sending a signal from our thread when it finishes, results in simpler code and has the added benefit that our framerate is limited to whatever rate our timer is called at.
+Before, we implement our timer function, we must consider one important issue. If our drawing application is going to take a long time (longer than 1/30th of a second) then simply launching a new drawing thread every time the timer executes could result in a pile-up of threads and a lot of memory badness. To solve this problem, we will have a variable `currently_drawing`. If `currently_drawing=0` then it is safe to launch a drawing thread. If it isn't, we know we haven't finished the drawing we started last time! Using this solution instead of sending a signal from our thread when it finishes, results in simpler code and has the added benefit that our framerate is limited to whatever rate our timer is called at.
gboolean timer_exe(GtkWidget * window){
-
+
static gboolean first_execution = TRUE;
//use a safe function to get the value of currently_drawing so
//we don't run into the usual multithreading issues
int drawing_status = g_atomic_int_get(¤tly_drawing);
-
- //if we are not currently drawing anything, launch a thread to
+
+ //if we are not currently drawing anything, launch a thread to
//update our pixmap
if(drawing_status == 0){
static pthread_t thread_info;
@@ -131,15 +131,15 @@ Before, we implement our timer function, we must consider one important issue.
* `g_atomic_int_get(¤tly_drawing)` is a thread-safe way to get the value of our global integer `currently_drawing`. Using this function allows us to avoid the possibility of reading a number at the same moment our other thread is trying to change it. It is also much easier to implement than mutexes for reading a single integer.
* `pthread_create( &thread_info, NULL, do_draw, NULL)` is the `unistd.h` way to launch the function `do_draw()` as a separate thread. (The final `NULL` is actually a `(void *)` to a data structure that we pass to `do_draw()`.)
* `gtk_widget_queue_draw_area(window, 0, 0, width, height)` sends an artificial expose event with upper left corner 0,0 and width and heigh of `width`, `height`, respectively. This allows our `expose_event` to do the actual painting.
- * `pthread_join(thread_info, NULL)` re-joins the drawing thread and ensures that it terminates and it's OS-related memory is freed.
+ * `pthread_join(thread_info, NULL)` re-joins the drawing thread and ensures that it terminates and it's OS-related memory is freed.
##Do the Drawing
-We now have a `timer_exe` function that launches our `do_draw()` in a new thread for us. Now lets implement `do_draw()`. Because we are now in a thread that is running outside of `gtk_main()`, we need to encase any calls involving gtk objects between `gdk_threads_enter()` and `gdk_threads_leave()`. This includes interactions with `GdkPixmap`s!
+We now have a `timer_exe` function that launches our `do_draw()` in a new thread for us. Now lets implement `do_draw()`. Because we are now in a thread that is running outside of `gtk_main()`, we need to encase any calls involving gtk objects between `gdk_threads_enter()` and `gdk_threads_leave()`. This includes interactions with `GdkPixmap`s!
_Note: the `gtk_main()` thread will be blocked until the code between `gdk_threads_enter()` and `gdk_threads_leave()` has executed, so don't put avoidable, processor-intensive code there._
-Our goal is to draw with cairo and have our drawing end up in `pixmap`, our global pixmap to be drawn upon `expose_event`. However, any cairo context created from `pixmap` must be accessed between `gdk_threads_enter()` and `gdk_threads_leave()`. If we did all our drawing this way, it would defeat the purpose of multi-threading, as we would have no speedup. We need to create a cairo context that that is independent from GTK so that we may draw upon it without a lock. After we have done the processor-intensive drawing, we can do the relatively-quick operation of copying our drawing to `pixmap` between `gdk_threads_enter()` and `gdk_threads_leave()`.
+Our goal is to draw with cairo and have our drawing end up in `pixmap`, our global pixmap to be drawn upon `expose_event`. However, any cairo context created from `pixmap` must be accessed between `gdk_threads_enter()` and `gdk_threads_leave()`. If we did all our drawing this way, it would defeat the purpose of multi-threading, as we would have no speedup. We need to create a cairo context that that is independent from GTK so that we may draw upon it without a lock. After we have done the processor-intensive drawing, we can do the relatively-quick operation of copying our drawing to `pixmap` between `gdk_threads_enter()` and `gdk_threads_leave()`.
The solution comes from `cairo_image_surface_create()`, which will create an area in memory from which we can create a cairo context that can be drawn upon without fear of thread issues.
@@ -151,7 +151,7 @@ The solution comes from `cairo_image_surface_create()`, which will create an are
void *do_draw(void *ptr){
currently_drawing = 1;
-
+
int width, height;
gdk_threads_enter();
gdk_drawable_get_size(pixmap, &width, &height);
@@ -162,7 +162,7 @@ The solution comes from `cairo_image_surface_create()`, which will create an are
cairo_t *cr = cairo_create(cst);
/* do all your drawing here */
-
+
cairo_destroy(cr);
@@ -176,11 +176,11 @@ The solution comes from `cairo_image_surface_create()`, which will create an are
cairo_destroy(cr_pixmap);
gdk_threads_leave();
-
+
cairo_surface_destroy(cst);
-
+
currently_drawing = 0;
-
+
return NULL;
}
@@ -210,7 +210,7 @@ The last thing we need to do is handle our callbacks. These are `on_window_conf
if( event->height < minh ){ minh = event->height; }
gdk_draw_drawable(tmppixmap, da->style->fg_gc[GTK_WIDGET_STATE(da)], pixmap, 0, 0, 0, 0, minw, minh);
//we're done with our old pixmap, so we can get rid of it and replace it with our properly-sized one.
- g_object_unref(pixmap);
+ g_object_unref(pixmap);
pixmap = tmppixmap;
}
oldw = event->width;
@@ -228,7 +228,7 @@ The last thing we need to do is handle our callbacks. These are `on_window_conf
return TRUE;
}
-##Compiling
+##Compiling
To compile, use `pkg-config --cflags --libs gtk+-2.0 --libs gthread-2.0` For example, if you save this code to `threaded_examp.c`, you would compile it with the command:
@@ -259,7 +259,7 @@ For your compiling pleasure, the full source in proper order.
if( event->height < minh ){ minh = event->height; }
gdk_draw_drawable(tmppixmap, da->style->fg_gc[GTK_WIDGET_STATE(da)], pixmap, 0, 0, 0, 0, minw, minh);
//we're done with our old pixmap, so we can get rid of it and replace it with our properly-sized one.
- g_object_unref(pixmap);
+ g_object_unref(pixmap);
pixmap = tmppixmap;
}
oldw = event->width;
@@ -284,7 +284,7 @@ For your compiling pleasure, the full source in proper order.
void *do_draw(void *ptr){
currently_drawing = 1;
-
+
int width, height;
gdk_threads_enter();
gdk_drawable_get_size(pixmap, &width, &height);
@@ -303,7 +303,7 @@ For your compiling pleasure, the full source in proper order.
for(k=0; k<100; ++k){ //lets just redraw lots of times to use a lot of proc power
for(j=0; j < 1000; ++j){
cairo_set_source_rgb (cr, (double)j/1000.0, (double)j/1000.0, 1.0 - (double)j/1000.0);
- cairo_move_to(cr, i,j/2);
+ cairo_move_to(cr, i,j/2);
cairo_line_to(cr, i+100,j/2);
cairo_stroke(cr);
}
@@ -321,23 +321,23 @@ For your compiling pleasure, the full source in proper order.
cairo_destroy(cr_pixmap);
gdk_threads_leave();
-
+
cairo_surface_destroy(cst);
-
+
currently_drawing = 0;
-
+
return NULL;
}
gboolean timer_exe(GtkWidget * window){
-
+
static gboolean first_execution = TRUE;
//use a safe function to get the value of currently_drawing so
//we don't run into the usual multithreading issues
int drawing_status = g_atomic_int_get(¤tly_drawing);
-
- //if we are not currently drawing anything, launch a thread to
+
+ //if we are not currently drawing anything, launch a thread to
//update our pixmap
if(drawing_status == 0){
static pthread_t thread_info;
@@ -424,7 +424,7 @@ Below is the full source of `threaded_examp`, but with signals used to trigger d
if( event->height < minh ){ minh = event->height; }
gdk_draw_drawable(tmppixmap, da->style->fg_gc[GTK_WIDGET_STATE(da)], pixmap, 0, 0, 0, 0, minw, minh);
//we're done with our old pixmap, so we can get rid of it and replace it with our properly-sized one.
- g_object_unref(pixmap);
+ g_object_unref(pixmap);
pixmap = tmppixmap;
}
oldw = event->width;
@@ -458,9 +458,9 @@ Below is the full source of `threaded_examp`, but with signals used to trigger d
while(1){
//wait for our SIGALRM. Upon receipt, draw our stuff. Then, do it again!
while (sigwaitinfo(&sigset, &info) > 0) {
-
+
currently_drawing = 1;
-
+
int width, height;
gdk_threads_enter();
gdk_drawable_get_size(pixmap, &width, &height);
@@ -479,7 +479,7 @@ Below is the full source of `threaded_examp`, but with signals used to trigger d
for(k=0; k<100; ++k){ //lets just redraw lots of times to use a lot of proc power
for(j=0; j < 1000; ++j){
cairo_set_source_rgb (cr, (double)j/1000.0, (double)j/1000.0, 1.0 - (double)j/1000.0);
- cairo_move_to(cr, i,j/2);
+ cairo_move_to(cr, i,j/2);
cairo_line_to(cr, i+100,j/2);
cairo_stroke(cr);
}
@@ -497,11 +497,11 @@ Below is the full source of `threaded_examp`, but with signals used to trigger d
cairo_destroy(cr_pixmap);
gdk_threads_leave();
-
+
cairo_surface_destroy(cst);
-
+
currently_drawing = 0;
-
+
}
}
}
diff --git a/src/todo.mdwn b/src/todo.mdwn
index 398f8bd..876cf5c 100644
--- a/src/todo.mdwn
+++ b/src/todo.mdwn
@@ -302,7 +302,7 @@ Other fixes
2) Disable anti-aliasing.
- 3) Tolerance? Other scaling issue?
+ 3) Tolerance? Other scaling issue?
4) Draw scene
@@ -389,7 +389,7 @@ Test-suite improvements
* Font integration
* Font-backend specific reference images?
* Quick mode: disable similar testing, device offset iterations.
-
+
From <https://bugs.freedesktop.org/show_bug.cgi?id=9465#c2>
* I prefer finding the font backend using `cairo_font_type_t`.
@@ -434,9 +434,8 @@ Not strictly in cairo-land, but noted lest we forget.
* Add a pre-multiplied ARGB colorspace to avoid conversion issues, and make
GdkPixbuf match hardware requirements for improved performance
- * refactor GdkPixbuf for Gtk 3.0, so it's a thin wrapper around cairo surfaces
+ * refactor GdkPixbuf for Gtk 3.0, so it's a thin wrapper around cairo surfaces
and make sure it makes use of Cairo performance effectively:
* make GdkEditablePixbuf different from GdkPixbuf (treat editing as a special case)
* ensure loaded-from-file pixbufs store their raw image data for writing to JPEG
* possibly add subclasses for themed pixbufs/icon pixbufs and invent a sane object hierarchy
-
diff --git a/templates/editpage.tmpl b/templates/editpage.tmpl
index e77e8cf..d7b5ec3 100644
--- a/templates/editpage.tmpl
+++ b/templates/editpage.tmpl
@@ -48,7 +48,7 @@ this page with your text, click "Save Page" again.
with the same name.</b>
</p>
<p>
-The edit box below contains the page's current content, followed by the
+The edit box below contains the page's current content, followed by the
content you entered previously, to allow you to merge the two
together before saving.
</p>
diff --git a/templates/estseek.conf b/templates/estseek.conf
index 43bd303..5192452 100644
--- a/templates/estseek.conf
+++ b/templates/estseek.conf
@@ -2,7 +2,7 @@ indexname: <TMPL_VAR INDEX>
tmplfile: <TMPL_VAR TMPLFILE>
topfile: /dev/null
logfile:
-logformat:
+logformat:
replace: ^file://<TMPL_VAR DESTDIR>{{!}}<TMPL_VAR URL>
showreal: false
perpage: 10,20,30,40,50,100
@@ -26,6 +26,6 @@ spcache:
wildmax: 256
qxpndcmd:
helpfile: estseek.help
-deftitle:
+deftitle:
attrwidth: 80
-dispproxy:
+dispproxy:
diff --git a/templates/passwordmail.tmpl b/templates/passwordmail.tmpl
index 8484d39..7a375e0 100644
--- a/templates/passwordmail.tmpl
+++ b/templates/passwordmail.tmpl
@@ -3,7 +3,7 @@ Someone[1], possibly you, requested that you be emailed the password for user
The password is: <TMPL_VAR USER_PASSWORD>
---
+--
ikiwiki
[1] The user requesting the password was at IP address <TMPL_VAR REMOTE_ADDR>
More information about the cairo-commit
mailing list