[m-rev.] diff: more support for ps surface in cairo binding
Julien Fischer
juliensf at csse.unimelb.edu.au
Sat Sep 11 00:20:43 AEST 2010
Add more support for PostScript surfaces in the cairo binding.
extras/graphics/mercury_cairo/cairo.ps.m:
Support more of the PostScript surface functions.
extras/graphics/mercury_cairo/samples/.cvsignore:
extras/graphics/mercury_cairo/tutoria/.cvsignore:
extras/graphics/mercury_cairo/.cvsignore:
Ignore generated files.
Julien.
Index: .cvsignore
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/graphics/mercury_cairo/.cvsignore,v
retrieving revision 1.1
diff -u -r1.1 .cvsignore
--- .cvsignore 7 Sep 2010 15:18:35 -0000 1.1
+++ .cvsignore 10 Sep 2010 14:15:11 -0000
@@ -1,3 +1,7 @@
Mercury
*.mh
*.err
+*.init
+libmercury_cairo.a
+libmercury_cairo.so
+libmercury_cairo.dylib
Index: cairo.ps.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/graphics/mercury_cairo/cairo.ps.m,v
retrieving revision 1.2
diff -u -r1.2 cairo.ps.m
--- cairo.ps.m 7 Sep 2010 14:04:59 -0000 1.2
+++ cairo.ps.m 10 Sep 2010 14:15:11 -0000
@@ -55,6 +55,36 @@
:- pred restrict_to_level(ps_surface::in, ps_level::in,
io::di, io::uo) is det.
+ % ps.set_eps(Surface, EPS, !IO):
+ % If EPS is "yes" then Surface will output Encapsulated PostScript.
+ %
+:- pred set_eps(ps_surface::in, bool::in, io::di, io::uo) is det.
+
+ % ps.get_eps(Surface, EPS, !IO):
+ % EPS is "yes" if Surface is set to output Encapsulated PostScript.
+ %
+:- pred get_eps(ps_surface::in, bool::out, io::di, io::uo) is det.
+
+ % ps.set_size(Surface, Width, Height, !IO):
+ % Change the size of Surface for the current (and subsequent) pages.
+ %
+:- pred set_size(ps_surface::in, float::in, float::in, io::di, io::uo) is det.
+
+ % ps.dsc_begin_setup(Surface, !IO):
+ %
+:- pred dsc_begin_setup(ps_surface::in, io::di, io::uo) is det.
+
+ % ps.dsc_begin_page_setup(Surface, !IO):
+ %
+:- pred dsc_begin_page_setup(ps_surface::in, io::di, io::uo) is det.
+
+ % ps.dsc_comment(Surface, Comment, !IO):
+ % Emit Comment into the PostScript output as a comment for Surface.
+ % (See the cairo manual entry for cairo_ps_surface_dsc_comment() for
+ % further details.)
+ %
+:- pred dsc_comment(ps_surface::in, string::in, io::di, io::uo) is det.
+
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
@@ -184,10 +214,57 @@
#if defined(CAIRO_HAS_PS_SURFACE)
cairo_ps_surface_restrict_to_level(Surface->mcairo_raw_surface, Level);
#else
- MR_fatal_error(\"Cairo PDF surface not available\");
+ MR_fatal_error(\"Cairo PostScript surface not available\");
#endif
").
+:- pragma foreign_proc("C",
+ set_eps(Surface::in, EPS::in, _IO0::di, _IO::uo),
+ [promise_pure, will_not_call_mercury, tabled_for_io],
+"
+ cairo_ps_surface_set_eps(Surface->mcairo_raw_surface,
+ (EPS = MR_YES ? 1 : 0));
+").
+
+:- pragma foreign_proc("C",
+ get_eps(Surface::in, EPS::out, _IO0::di, _IO::uo),
+ [promise_pure, will_not_call_mercury, tabled_for_io],
+"
+ if (cairo_ps_surface_get_eps(Surface->mcairo_raw_surface)) {
+ EPS = MR_YES;
+ } else {
+ EPS = MR_NO;
+ }
+").
+
+:- pragma foreign_proc("C",
+ set_size(Surface::in, W::in, H::in, _IO0::di, _IO::uo),
+ [promise_pure, will_not_call_mercury, tabled_for_io],
+"
+ cairo_ps_surface_set_size(Surface->mcairo_raw_surface, W, H);
+").
+
+:- pragma foreign_proc("C",
+ dsc_begin_setup(Surface::in, _IO0::di, _IO::uo),
+ [promise_pure, will_not_call_mercury, tabled_for_io],
+"
+ cairo_ps_surface_dsc_begin_setup(Surface->mcairo_raw_surface);
+").
+
+:- pragma foreign_proc("C",
+ dsc_begin_page_setup(Surface::in, _IO0::di, _IO::uo),
+ [promise_pure, will_not_call_mercury, tabled_for_io],
+"
+ cairo_ps_surface_dsc_begin_page_setup(Surface->mcairo_raw_surface);
+").
+
+:- pragma foreign_proc("C",
+ dsc_comment(Surface::in, Comment::in, _IO0::di, _IO::uo),
+ [promise_pure, will_not_call_mercury, tabled_for_io],
+"
+ cairo_ps_surface_dsc_comment(Surface->mcairo_raw_surface, Comment);
+").
+
%---------------------------------------------------------------------------%
:- end_module cairo.ps.
%---------------------------------------------------------------------------%
Index: samples/.cvsignore
===================================================================
RCS file: samples/.cvsignore
diff -N samples/.cvsignore
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ samples/.cvsignore 10 Sep 2010 14:15:11 -0000
@@ -0,0 +1,22 @@
+Mercury
+*.err
+*.mh
+*.png
+arc
+arc_negative
+clip
+clip_image
+curve_to
+dash
+fill_and_stroke2
+fill_style
+gradient
+hello
+image
+imagepattern
+multi_segment_caps
+set_line_cap
+set_line_join
+text
+text_align_center
+text_extents
Index: tutorial/.cvsignore
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/graphics/mercury_cairo/tutorial/.cvsignore,v
retrieving revision 1.1
diff -u -r1.1 .cvsignore
--- tutorial/.cvsignore 7 Sep 2010 15:18:35 -0000 1.1
+++ tutorial/.cvsignore 10 Sep 2010 14:15:11 -0000
@@ -1,6 +1,7 @@
Mercury
*.err
*.mh
+*.png
fill
mask
paint
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list