[cairo-commit] cairo-perl/examples simple.pl,1.1,1.2
Torsten Schoenfeld
commit at pdx.freedesktop.org
Tue Jul 12 13:29:51 PDT 2005
- Previous message: [cairo-commit] libsvg-cairo/src Makefile.am, 1.7,
1.8 svg-cairo-internal.h, 1.20, 1.21 svg_cairo.c, 1.38,
1.39 svg_cairo_sprintf_alloc.c, 1.4, 1.5 svg_cairo_state.c,
1.15, 1.16
- Next message: [cairo-commit] cairo-perl Cairo.pm, 1.2, 1.3 Cairo.xs, 1.4,
1.5 CairoFont.xs, 1.2, 1.3 CairoMatrix.xs, 1.4,
1.5 CairoPath.xs, NONE, 1.1 CairoPattern.xs, 1.4,
1.5 CairoSurface.xs, 1.5, 1.6 ChangeLog, 1.6,
1.7 MakeHelper.pm, 1.1, 1.2 Makefile.PL, 1.4, 1.5 README, 1.1,
1.2 cairo-perl.h, 1.5, 1.6 cairo-perl.typemap, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: tsch
Update of /cvs/cairo/cairo-perl/examples
In directory gabe:/tmp/cvs-serv30085/examples
Modified Files:
simple.pl
Log Message:
* Cairo.pm, Cairo.xs, t/Cairo.t: Replace the %backends hash with
Cairo::HAS_PS_SURFACE, HAS_PDF_SURFACE, HAS_XLIB_SURFACE,
HAS_FT_FONT and HAS_PNG_FUNCTIONS.
* Cairo.pm, CairoPattern.xs, CairoSurface.xs, Makefile.PL:
Implement the pattern and surface hierarchy suggested by the
language bindings guidelines.
* Cairo.xs: Use Cairo::Context for the namespace of cairo_t,
instead of just Cairo, as suggested by the guidelines.
* Cairo.xs, CairoFont.xs, CairoMatrix.xs, CairoPattern.xs,
CairoSurface.xs, cairo-perl.h: Add new, remove old API. Shuffle
some things around.
* Cairo.xs: Convert font and text extents and glyphs to and from
native Perl data structures.
* Cairo.xs, cairo-perl.h, cairo-perl.typemap: Remove everything
that cannot be used from Perl, like the XLib and Glitz stuff.
* CairoPath.xs, t/CairoPath.t: Add support for cairo_path_t,
including a nice tied interface that lets you iterate over paths
as if they were normal array references.
* MakeHelper.pm: Extend the typemap generator to support "const"
and "_noinc" types. Change the enum handling to use the Glib
convention, i.e. lowercase and hyphen instead of underscore.
* Makefile.PL, README: Use ExtUtils::Depends.
* examples/simple.pl, examples/png/caps_join.pl,
examples/png/hering.pl, examples/png/outline.pl,
examples/png/spiral.pl, examples/png/splines_tolerance.pl,
examples/png/stars.pl: Update the examples to make them work again
after all those API changes.
* t/Cairo.t, t/CairoFont.t, CairoMatrix.t, CairoPattern.t,
CairoSurface.t: Redo and/or expand the whole test suite.
Index: simple.pl
===================================================================
RCS file: /cvs/cairo/cairo-perl/examples/simple.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- simple.pl 28 Nov 2004 18:59:45 -0000 1.1
+++ simple.pl 12 Jul 2005 20:29:49 -0000 1.2
@@ -15,52 +15,49 @@
M_PI => 3.14159265,
};
-die "png backend not supported" unless ($Cairo::backends{png});
+die "png backend not supported" unless (Cairo::HAS_PNG_FUNCTIONS);
$0 =~ /(.*)\.pl/;
my $png = "$1.png";
-open OUT, ">$png" or die "unable to open ($png) for output";
-
-my $cr = Cairo->create;
-$cr->set_target_png (*OUT, 'ARGB32', IMG_WIDTH, IMG_HEIGHT);
+my $surf = Cairo::ImageSurface->create ('argb32', IMG_WIDTH, IMG_HEIGHT);
+my $cr = Cairo::Context->create ($surf);
$cr->rectangle (0, 0, IMG_WIDTH, IMG_HEIGHT);
-$cr->set_rgb_color (1, 1, 1);
+$cr->set_source_rgba (1, 1, 1, 0.5);
$cr->fill;
-$cr->set_alpha (0.5);
-
# black
$cr->save;
-$cr->set_rgb_color (0, 0, 0);
+$cr->set_source_rgba (0, 0, 0, 0.5);
$cr->translate (IMG_WIDTH / 2, IMG_HEIGHT - (IMG_HEIGHT / 4));
do_star ();
$cr->restore;
# red
$cr->save;
-$cr->set_rgb_color (1, 0, 0);
+$cr->set_source_rgba (1, 0, 0, 0.5);
$cr->translate (IMG_WIDTH / 2, IMG_HEIGHT / 4);
do_star ();
$cr->restore;
# green
$cr->save;
-$cr->set_rgb_color (0, 1, 0);
+$cr->set_source_rgba (0, 1, 0, 0.5);
$cr->translate (IMG_WIDTH / 4, IMG_HEIGHT / 2);
do_star ();
$cr->restore;
# blue
$cr->save;
-$cr->set_rgb_color (0, 0, 1);
+$cr->set_source_rgba (0, 0, 1, 0.5);
$cr->translate (IMG_WIDTH - (IMG_WIDTH / 4), IMG_HEIGHT / 2);
do_star ();
$cr->restore;
$cr->show_page;
-close OUT;
+
+$surf->write_to_png ($png);
sub do_star
{
- Previous message: [cairo-commit] libsvg-cairo/src Makefile.am, 1.7,
1.8 svg-cairo-internal.h, 1.20, 1.21 svg_cairo.c, 1.38,
1.39 svg_cairo_sprintf_alloc.c, 1.4, 1.5 svg_cairo_state.c,
1.15, 1.16
- Next message: [cairo-commit] cairo-perl Cairo.pm, 1.2, 1.3 Cairo.xs, 1.4,
1.5 CairoFont.xs, 1.2, 1.3 CairoMatrix.xs, 1.4,
1.5 CairoPath.xs, NONE, 1.1 CairoPattern.xs, 1.4,
1.5 CairoSurface.xs, 1.5, 1.6 ChangeLog, 1.6,
1.7 MakeHelper.pm, 1.1, 1.2 Makefile.PL, 1.4, 1.5 README, 1.1,
1.2 cairo-perl.h, 1.5, 1.6 cairo-perl.typemap, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list