* Background using Image Overlay
@ 2011-11-08 3:45 Syed N Haider
2011-11-08 5:31 ` Wolfgang Schuster
0 siblings, 1 reply; 2+ messages in thread
From: Syed N Haider @ 2011-11-08 3:45 UTC (permalink / raw)
To: ntg-context
[-- Attachment #1.1: Type: text/plain, Size: 1119 bytes --]
Hi All
I am new to the Metapost and Context world, and need some help regarding
the inclusion of Metapost graphics in ConTeXt documents. I am trying a very
simple approach, using a graphic as a background. Here's my sample (using a
very basic metapost graphic as a page background in a document):
Metapost:
========
beginfig(0);
theta := 360/7;
radius := 1in;
z0 = origin;
z1 = z0 + dir(90)*radius;
z2 = z0 + dir(90 + theta)*radius;
z3 = z0 + dir(90 + 2*theta)*radius;
z4 = z0 + dir(90 + 3*theta)*radius;
z5 = z0 + dir(90 + 4*theta)*radius;
z6 = z0 + dir(90 + 5*theta)*radius;
z7 = z0 + dir(90 + 6*theta)*radius;
draw z1 -- z2 -- z3 -- z4 -- z5 -- z6 -- z7
-- cycle;
endfig;
end;
ConTeXt (after running mpost on the metapost graphic to generate the
hexagon.0 file):
=====================================================================
\defineoverlay
[backg]
[{\externalfigure[hexagon.0][width=\overlaywidth,height=\overlayheight]}]
\starttext
\noheaderandfooterlines
\setupbackgrounds[page][background=backg]
%\placefigure
%{none}
%{\externalfigure[hexagon.0][width=12cm]}
\stoptext
Thanks in advance
Syed
[-- Attachment #1.2: Type: text/html, Size: 1662 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Background using Image Overlay
2011-11-08 3:45 Background using Image Overlay Syed N Haider
@ 2011-11-08 5:31 ` Wolfgang Schuster
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Schuster @ 2011-11-08 5:31 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 08.11.2011 um 04:45 schrieb Syed N Haider:
> Hi All
> I am new to the Metapost and Context world, and need some help regarding the inclusion of Metapost graphics in ConTeXt documents. I am trying a very simple approach, using a graphic as a background. Here's my sample (using a very basic metapost graphic as a page background in a document):
>
> Metapost:
> ========
> beginfig(0);
> theta := 360/7;
> radius := 1in;
> z0 = origin;
> z1 = z0 + dir(90)*radius;
> z2 = z0 + dir(90 + theta)*radius;
> z3 = z0 + dir(90 + 2*theta)*radius;
> z4 = z0 + dir(90 + 3*theta)*radius;
> z5 = z0 + dir(90 + 4*theta)*radius;
> z6 = z0 + dir(90 + 5*theta)*radius;
> z7 = z0 + dir(90 + 6*theta)*radius;
> draw z1 -- z2 -- z3 -- z4 -- z5 -- z6 -- z7
> -- cycle;
> endfig;
> end;
>
>
>
> ConTeXt (after running mpost on the metapost graphic to generate the hexagon.0 file):
> =====================================================================
>
> \defineoverlay
> [backg]
> [{\externalfigure[hexagon.0][width=\overlaywidth,height=\overlayheight]}]
>
> \starttext
> \noheaderandfooterlines
> \setupbackgrounds[page][background=backg]
> %\placefigure
> %{none}
> %{\externalfigure[hexagon.0][width=12cm]}
> \stoptext
With ConTeXt you can include your MetaPost code in the document and the graphic is generated at runtime.
\startuseMPgraphic{hexagon}
theta := 360/7;
radius := 1in;
z0 = origin;
z1 = z0 + dir(90)*radius;
z2 = z0 + dir(90 + theta)*radius;
z3 = z0 + dir(90 + 2*theta)*radius;
z4 = z0 + dir(90 + 3*theta)*radius;
z5 = z0 + dir(90 + 4*theta)*radius;
z6 = z0 + dir(90 + 5*theta)*radius;
z7 = z0 + dir(90 + 6*theta)*radius;
draw (z1 -- z2 -- z3 -- z4 -- z5 -- z6 -- z7 -- cycle) xysized(OverlayWidth,OverlayHeight) ;
\stopuseMPgraphic
\defineoverlay[hexagon][\useMPgraphic{hexagon}]
\setupbackgrounds[page][background=hexagon]
\starttext
\page[empty]
\stoptext
For more information about MetaPost graphics take a look into the MetaFun manual (http://pragma-ade.com/show-man-7.htm) which provides many examples.
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-11-08 5:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-08 3:45 Background using Image Overlay Syed N Haider
2011-11-08 5:31 ` Wolfgang Schuster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).