added cairo.gadget and cairo.samples
parent
eb98145d2c
commit
f5a040cfc2
|
@ -703,7 +703,7 @@ cairo_status_to_string ( cairo_status_t status ) ;
|
|||
! Surface manipulation
|
||||
|
||||
FUNCTION: cairo_surface_t*
|
||||
cairo_surface_create_similar ( cairo_surface_t * other, cairo_content_t content, int width, int height ) ;
|
||||
cairo_surface_create_similar ( cairo_surface_t* other, cairo_content_t content, int width, int height ) ;
|
||||
|
||||
FUNCTION: cairo_surface_t*
|
||||
cairo_surface_reference ( cairo_surface_t* surface ) ;
|
||||
|
@ -744,8 +744,7 @@ FUNCTION: cairo_content_t
|
|||
cairo_surface_get_content ( cairo_surface_t* surface ) ;
|
||||
|
||||
FUNCTION: cairo_status_t
|
||||
cairo_surface_write_to_png ( cairo_surface_t *surface,
|
||||
const char *filename ) ;
|
||||
cairo_surface_write_to_png ( cairo_surface_t* surface, char* filename ) ;
|
||||
|
||||
FUNCTION: cairo_status_t
|
||||
cairo_surface_write_to_png_stream ( cairo_surface_t* surface, cairo_write_func_t write_func, void* closure ) ;
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
USING: cairo ui.render kernel opengl.gl opengl
|
||||
math byte-arrays ui.gadgets accessors arrays
|
||||
namespaces ;
|
||||
|
||||
IN: cairo.gadget
|
||||
|
||||
TUPLE: cairo-gadget width height quot ;
|
||||
: <cairo-gadget> ( width height quot -- cairo-gadget )
|
||||
cairo-gadget construct-gadget
|
||||
swap >>quot
|
||||
swap >>height
|
||||
swap >>width ;
|
||||
|
||||
: with-surface ( surface quot -- )
|
||||
>r dup cairo_create dup r> call
|
||||
cairo_destroy cairo_surface_destroy ;
|
||||
|
||||
: cairo>bytes ( width height quot -- byte-array )
|
||||
>r over 4 *
|
||||
[ * nip <byte-array> dup CAIRO_FORMAT_ARGB32 ]
|
||||
[ cairo_image_surface_create_for_data ] 3bi
|
||||
r> with-surface ;
|
||||
|
||||
M: cairo-gadget draw-gadget* ( gadget -- )
|
||||
origin get [
|
||||
0 0 glRasterPos2i
|
||||
1.0 -1.0 glPixelZoom
|
||||
[ width>> ] [ height>> ] [ quot>> ] tri
|
||||
[ drop GL_RGBA GL_UNSIGNED_BYTE ] [ cairo>bytes ] 3bi
|
||||
glDrawPixels
|
||||
] with-translation ;
|
||||
|
||||
M: cairo-gadget pref-dim* ( gadget -- rect )
|
||||
[ width>> ] [ height>> ] bi 2array ;
|
|
@ -0,0 +1,13 @@
|
|||
USING: cairo locals ;
|
||||
|
||||
IN: cairo.samples
|
||||
|
||||
SYMBOL: cr
|
||||
:: cairo-samp ( cr -- )
|
||||
[let | |
|
||||
cr 10.0 cairo_set_line_width
|
||||
cr 50.0 50.0 20.0 0.0 3.0 cairo_arc
|
||||
cr 1.0 1.0 0.0 1.0 cairo_set_source_rgba
|
||||
cr cairo_stroke
|
||||
cr cairo_fill
|
||||
] ;
|
Loading…
Reference in New Issue