[cairo-commit] rcairo/samples gradients.rb,NONE,1.1
Oeyvind Kolaas
commit at pdx.freedesktop.org
Mon Feb 14 15:51:56 PST 2005
- Previous message: [cairo-commit] rcairo/packages/cairo/lib cairo.rb,1.5,1.6
- Next message: [cairo-commit] rcairo/packages/cairo/ext rb_cairo.c, 1.1,
1.2 rb_cairo_constants.c, 1.1, 1.2 rb_cairo_context.c, 1.1,
1.2 rb_cairo_matrix.c, 1.1, 1.2 rb_cairo_matrix.h, 1.1,
1.2 rb_cairo_pattern.c, 1.1, 1.2 rb_cairo_pattern.h, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: pippin
Update of /cvs/cairo/rcairo/samples
In directory gabe:/tmp/cvs-serv13901/samples
Added Files:
gradients.rb
Log Message:
adding pattern class
--- NEW FILE: gradients.rb ---
#!/usr/bin/env ruby
# vim: filetype=ruby:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
$LOAD_PATH.unshift "../packages/cairo/ext/"
$LOAD_PATH.unshift "../packages/cairo/lib/"
$:.push File.join(File.dirname($0), "cairo")
require 'cairo'
include Cairo
def normalize cr,width,height
cr.scale width, height
end
File.open("gradients.png", "wb") {|stream|
cr = Context.new
cr.set_target_png(stream, FORMAT_ARGB32, 200, 200);
normalize cr, 200, 200
pat = Pattern.create_linear(0,0,0,1)
pat.add_color_stop(1,0,0,0,1)
pat.add_color_stop(0,1,1,1,1)
cr.set_pattern(pat) # or cr.pattern=pat
cr.rectangle(0, 0, 1, 1)
cr.fill
# draw a sphere, using more syntactic sugar:
cr.pattern = Pattern.create_radial(0.45, 0.4, 0.1,
0.40, 0.4, 0.5) do
|pat|
pat.add_color_stop(0,1,1,1,1)
pat.add_color_stop(1,0,0,0,1)
end
cr.fill {
cr.arc 0.5, 0.5, 0.3, 0, 2*3.1415
}
cr.show_page
}
- Previous message: [cairo-commit] rcairo/packages/cairo/lib cairo.rb,1.5,1.6
- Next message: [cairo-commit] rcairo/packages/cairo/ext rb_cairo.c, 1.1,
1.2 rb_cairo_constants.c, 1.1, 1.2 rb_cairo_context.c, 1.1,
1.2 rb_cairo_matrix.c, 1.1, 1.2 rb_cairo_matrix.h, 1.1,
1.2 rb_cairo_pattern.c, 1.1, 1.2 rb_cairo_pattern.h, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list