Files
mercury/extras/graphics/mercury_cairo/tutorial/path_close.m
Julien Fischer 7a85f13389 Add a Mercury binding to the cairo 2D graphics library to the extras
distribution.  (For further information see, <http://www.cairographics.org/>.)
The binding is currently fairly complete (enough for the cairo sample and
tutorial programs to be work in Mercury).  The main things missing are:

   * scaled fonts
   * a few operations on patterns (grep for NYI)
   * support for X, Quartz, or Win32 surfaces
   * font backends other than the builtin toy one

TODO: I'll add README files, Makefiles, update the NEWS file, etc
in a separate change.

extras/graphics/mercury_cairo/*.m:
extras/graphics/mercury_cairo/tutorial/*.m:
extras/graphics/mercury_cairo/samples/*.m:
extras/graphics/mercury_cairo/samples/data/*.png:
	Add the Mercury cairo binding.
2010-09-05 14:31:46 +00:00

50 lines
1.6 KiB
Mathematica

%-----------------------------------------------------------------------------%
:- module path_close.
:- interface.
:- import_module io.
%-----------------------------------------------------------------------------%
:- pred main(io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- implementation.
:- import_module cairo.
:- import_module cairo.image.
:- import_module cairo.path.
:- import_module cairo.png.
:- import_module cairo.transformations.
:- import_module float.
:- import_module math.
%-----------------------------------------------------------------------------%
main(!IO) :-
cairo.image.create_surface(format_argb32, 120, 120, Surface, !IO),
cairo.create_context(Surface, Context, !IO),
cairo.transformations.scale(Context, 120.0, 120.0, !IO),
cairo.set_line_width(Context, 0.1, !IO),
cairo.set_source_rgb(Context, 0.0, 0.0, 0.0, !IO),
cairo.path.move_to(Context, 0.25, 0.25, !IO),
cairo.path.line_to(Context, 0.5, 0.375, !IO),
cairo.path.rel_line_to(Context, 0.25, -0.125, !IO),
cairo.path.arc(Context, 0.5, 0.5, 0.25 * sqrt(2.0), -0.25 * pi, 0.25 * pi, !IO),
cairo.path.rel_curve_to(Context, -0.25, -0.125, -0.25, 0.125, -0.5, 0.0, !IO),
cairo.path.close_path(Context, !IO),
cairo.stroke(Context, !IO),
cairo.png.write_surface_to_png(Surface, "path_close.png", !IO).
%-----------------------------------------------------------------------------%
:- end_module path_close.
%-----------------------------------------------------------------------------%