seed r394 - trunk/modules/canvas
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r394 - trunk/modules/canvas
- Date: Sat, 6 Dec 2008 02:32:38 +0000 (UTC)
Author: racarr
Date: Sat Dec 6 02:32:38 2008
New Revision: 394
URL: http://svn.gnome.org/viewvc/seed?rev=394&view=rev
Log:
Implement Canvas.quadraticCurveTo.
Added:
trunk/modules/canvas/test7.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 02:32:38 2008
@@ -7,7 +7,7 @@
libsqlite_la_LDFLAGS = \
`pkg-config --libs seed cairo`
-EXTRA_DIST=test1.js test2.js test3.js test4.js test5.js test6.js
+EXTRA_DIST=test1.js test2.js test3.js test4.js test5.js test6.js test7.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 02:32:38 2008
@@ -426,6 +426,38 @@
return seed_make_null(ctx);
}
+SeedValue seed_canvas_quadratic (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ GET_CR;
+
+ gdouble p0x, p0y, cp1x, cp1y, cp2x, cp2y, cp3x, cp3y;
+ gdouble qp1x, qp1y, qp2x, qp2y;
+
+ cairo_get_current_point(cr, &p0x, &p0y);
+
+ qp1x = seed_value_to_double(ctx, arguments[0], exception);
+ qp1y = seed_value_to_double(ctx, arguments[1], exception);
+ qp2x = seed_value_to_double(ctx, arguments[2], exception);
+ qp2y = seed_value_to_double(ctx, arguments[3], exception);
+
+ cp3x = qp2x;
+ cp3y = qp2y;
+
+ cp1x = p0x + 2/3.0 * (qp1x-p0x);
+ cp1y = p0y + 2/3.0 * (qp1y-p0y);
+
+ cp2x = cp1x + 1/3.0 * (qp2x-p0x);
+ cp2y = cp1y + 1/3.0 * (qp2y-p0y);
+
+ cairo_curve_to(cr, cp1x, cp1y, cp2x, cp2y, cp3x, cp3y);
+
+ return seed_make_null(ctx);
+}
static void canvas_finalize(SeedObject object)
{
@@ -451,6 +483,7 @@
{"stroke", seed_canvas_stroke, 0},
{"clip", seed_canvas_clip, 0},
{"arc", seed_canvas_arc, 0},
+ {"quadraticCurveTo", seed_canvas_quadratic, 0},
{0, 0, 0}
};
Added: trunk/modules/canvas/test7.js
==============================================================================
--- (empty file)
+++ trunk/modules/canvas/test7.js Sat Dec 6 02:32:38 2008
@@ -0,0 +1,37 @@
+#!/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, 200);
+
+w.show_all();
+
+d.signal.expose_event.connect(function(){
+ var cr = Gdk.cairo_create(d.window);
+ var ctx = new Canvas.CairoCanvas(cr);
+
+ ctx.beginPath();
+ ctx.moveTo(75,25);
+ ctx.quadraticCurveTo(25,25,25,62.5);
+ ctx.quadraticCurveTo(25,100,50,100);
+ ctx.quadraticCurveTo(50,120,30,125);
+ ctx.quadraticCurveTo(60,120,65,100);
+ ctx.quadraticCurveTo(125,100,125,62.5);
+ ctx.quadraticCurveTo(125,25,75,25);
+ ctx.stroke();
+
+ return true;
+});
+Gtk.main();
+
+
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]