[cairo-commit] rcairo/packages/cairo/lib cairo.rb,1.16,1.17
Kouhei Sutou
commit at pdx.freedesktop.org
Mon Oct 17 05:59:58 PDT 2005
- Previous message: [cairo-commit] rcairo/samples pac.rb,NONE,1.1 pac2.rb,NONE,1.1
- Next message: [cairo-commit] roadster ChangeLog, 1.92, 1.93 TODO, 1.2,
1.3 configure.ac, 1.13, 1.14
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: kou
Update of /cvs/cairo/rcairo/packages/cairo/lib
In directory gabe:/tmp/cvs-serv25512/packages/cairo/lib
Modified Files:
cairo.rb
Log Message:
* packages/cairo/lib/cairo.rb
(Cairo::Context#rounded_rectangle, Cairo::Context#circle):
Added convenience methods.
* samples/pac.rb: Port PDF::Writer sample.
* samples/pac2.rb: ditto.
Index: cairo.rb
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/lib/cairo.rb,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- cairo.rb 10 Oct 2005 16:07:16 -0000 1.16
+++ cairo.rb 17 Oct 2005 12:59:55 -0000 1.17
@@ -41,6 +41,38 @@
( x0, y0 ) = get_point
quad_to(x1 + x0, y1 + y0, x2 + x0, y2 + x0)
end
+
+ def rounded_rectangle(x, y, width, height, x_radius, y_radius=nil)
+ x1 = x
+ x2 = x1 + width
+ y1 = y
+ y2 = y1 - height
+
+ y_radius ||= x_radius
+
+ x_radius = [x_radius, width / 2].min
+ y_radius = [y_radius, height / 2].min
+
+ xr1 = x_radius
+ xr2 = x_radius / 2.0
+ yr1 = y_radius
+ yr2 = y_radius / 2.0
+
+ move_to(x1 + xr1, y1)
+ line_to(x2 - xr1, y1)
+ curve_to(x2 - xr2, y1, x2, y1 - yr2, x2, y1 - yr1)
+ line_to(x2, y2 + yr1)
+ curve_to(x2, y2 + yr2, x2 - xr2, y2, x2 - xr1, y2)
+ line_to(x1 + xr1, y2)
+ curve_to(x1 + xr2, y2, x1, y2 + yr2, x1, y2 + yr1)
+ line_to(x1, y1 - yr1)
+ curve_to(x1, y1 - yr2, x1 + xr2, y1, x1 + xr1, y1)
+ close_path
+ end
+
+ def circle(x, y, radius)
+ arc(x, y, radius, 0, 2 * Math::PI)
+ end
end
class Glyph
- Previous message: [cairo-commit] rcairo/samples pac.rb,NONE,1.1 pac2.rb,NONE,1.1
- Next message: [cairo-commit] roadster ChangeLog, 1.92, 1.93 TODO, 1.2,
1.3 configure.ac, 1.13, 1.14
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list