mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-24 05:43:53 +00:00
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.
38 lines
1.2 KiB
Mathematica
38 lines
1.2 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
|
|
:- module paint.
|
|
:- 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.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
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_source_rgb(Context, 0.0, 0.0, 0.0, !IO),
|
|
cairo.paint_with_alpha(Context, 0.5, !IO),
|
|
|
|
cairo.png.write_surface_to_png(Surface, "paint.png", !IO).
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
:- end_module paint.
|
|
%-----------------------------------------------------------------------------%
|