/src/wrappers/cairo/examples/simple/cairosimple.e
Specman e | 60 lines | 30 code | 12 blank | 18 comment | 0 complexity | 959c76729b581448aa008da4aca0d21d MD5 | raw file
1class CAIROSIMPLE 2 3insert 4 CAIRO_FORMAT 5 6create {ANY} 7 make 8 9feature {ANY} 10 11 pi: REAL is 3.14159265358979323846 -- PI 12 13 make 14 local 15 context: CAIRO_CONTEXT 16 surface: CAIRO_IMAGE_SURFACE 17 res: INTEGER 18 do 19 create surface.make (cairo_format_argb32, 300, 200) 20 create context.make (surface) 21 -- First draw something easy, say a redish rectangle 22 context.set_source_rgb (0.8, 0.2, 0.4) 23 context.rectangle (10, 10, 40, 80) 24 context.fill_preserve 25 context.set_source_rgb (0.4, 0.1, 0.2) 26 context.stroke 27 28 -- Now a semitransparent circle 29 context.set_source_rgba (0.4, 0.8, 1.0, 0.5) -- alpha 1=opaque, 0=transparent 30 context.set_line_width (1.0) 31 context.arc (75, 75, 45, 0, 2 * pi) 32 context.fill_preserve 33 context.set_source_rgba (0, 0, 0, 0.5) 34 context.stroke 35 36 -- Finally, write to a PNG file 37 res := surface.write_to_png ("cairosimple.png") 38 surface.finish 39 end 40 41end -- class CAIROSIMPLE 42 43 44-- Copyright (C) 2010-2017: Paolo Redaelli, 2013 Cyril Adrian 45 46-- This library is free software; you can redistribute it and/or 47-- modify it under the terms of the GNU Lesser General Public License 48-- as published by the Free Software Foundation; either version 2.1 of 49-- the License, or (at your option) any later version. 50-- 51-- This library is distributed in the hope that it will be useful, but 52-- WITHOUT ANY WARRANTY; without even the implied warranty of 53-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54-- Lesser General Public License for more details. 55-- 56-- You should have received a copy of the GNU Lesser General Public 57-- License along with this library; if not, write to the Free Software 58-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 59-- 02110-1301 USA 60