seed r401 - trunk/modules/canvas
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r401 - trunk/modules/canvas
- Date: Sat, 6 Dec 2008 03:36:51 +0000 (UTC)
Author: racarr
Date: Sat Dec 6 03:36:51 2008
New Revision: 401
URL: http://svn.gnome.org/viewvc/seed?rev=401&view=rev
Log:
Seed-canvas: Line caps.
Added:
trunk/modules/canvas/test14.js (contents, props changed)
Modified:
trunk/modules/canvas/Makefile.am
trunk/modules/canvas/seed-canvas.c
Modified: trunk/modules/canvas/Makefile.am
==============================================================================
--- trunk/modules/canvas/Makefile.am (original)
+++ trunk/modules/canvas/Makefile.am Sat Dec 6 03:36:51 2008
@@ -7,7 +7,7 @@
libcanvas_la_LDFLAGS = \
`pkg-config --libs seed cairo`
-EXTRA_DIST=test1.js test2.js test3.js test4.js test5.js test6.js test7.js test8.js test9.js test10.js test11.js test12.js test13.js
+EXTRA_DIST=test1.js test2.js test3.js test4.js test5.js test6.js test7.js test8.js test9.js test10.js test11.js test12.js test13.js test14.js
AM_CPPFLAGS = \
-I../../libseed/ \
Modified: trunk/modules/canvas/seed-canvas.c
==============================================================================
--- trunk/modules/canvas/seed-canvas.c (original)
+++ trunk/modules/canvas/seed-canvas.c Sat Dec 6 03:36:51 2008
@@ -34,6 +34,10 @@
seed_object_set_property(ctx, obj, "globalAlpha",
seed_value_from_double(ctx, 1.0, exception));
+ seed_object_set_property(ctx, obj, "lineWidth",
+ seed_value_from_double(ctx, 1.0, exception));
+ seed_object_set_property(ctx, obj, "lineCap",
+ seed_value_from_string(ctx, "butt", exception));
return obj;
}
@@ -93,6 +97,7 @@
cairo_t * cr,
SeedException * exception)
{
+ cairo_line_cap_t cap = CAIRO_LINE_CAP_BUTT;
gchar * stroke_color =
seed_value_to_string(ctx,
seed_object_get_property(ctx, this_object,
@@ -108,9 +113,24 @@
seed_object_get_property(ctx, this_object,
"lineWidth"),
exception);
+ gchar * line_cap =
+ seed_value_to_string(ctx,
+ seed_object_get_property(ctx, this_object,
+ "lineCap"),
+ exception);
+
+ if (!strcmp(line_cap, "round"))
+ cap = CAIRO_LINE_CAP_ROUND;
+ else if (!strcmp(line_cap, "square"))
+ cap = CAIRO_LINE_CAP_SQUARE;
+
+ g_free(line_cap);
+
seed_canvas_parse_color(cr, stroke_color, global_alpha);
cairo_set_line_width(cr, line_width);
+ cairo_set_line_cap(cr, cap);
+
g_free(stroke_color);
}
Added: trunk/modules/canvas/test14.js
==============================================================================
--- (empty file)
+++ trunk/modules/canvas/test14.js Sat Dec 6 03:36:51 2008
@@ -0,0 +1,47 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gdk");
+Seed.import_namespace("Gtk");
+Seed.import_namespace("Canvas");
+
+
+Gtk.init(null, null);
+
+w = new Gtk.Window();
+d = new Gtk.DrawingArea();
+w.add(d);
+
+w.resize(150, 150);
+
+w.show_all();
+
+d.signal.expose_event.connect(function(){
+ var cr = Gdk.cairo_create(d.window);
+ var ctx = new Canvas.CairoCanvas(cr);
+ var lineCap = ['butt','round','square'];
+
+ ctx.strokeStyle = '#09f';
+ ctx.beginPath();
+ ctx.moveTo(10,10);
+ ctx.lineTo(140,10);
+ ctx.moveTo(10,140);
+ ctx.lineTo(140,140);
+ ctx.stroke();
+
+ // Draw lines
+ ctx.strokeStyle = "rgb(0,0,0)";
+ for (i=0;i<lineCap.length;i++){
+ ctx.lineWidth = 15;
+ ctx.lineCap = lineCap[i];
+ ctx.beginPath();
+ ctx.moveTo(25+i*50,10);
+ ctx.lineTo(25+i*50,140);
+ ctx.stroke();
+ }
+
+ return true;
+ });
+Gtk.main();
+
+
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]