Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Clippling of polygons within a defined region
Replies: 2   Last Post: Aug 5, 1999 2:27 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
John Tanner

Posts: 10
Registered: 12/7/04
Re: Clippling of polygons within a defined region
Posted: Aug 5, 1999 2:27 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

In article <7o5ff4$rgt@smc.vnet.net>, Allan Hayes
<hay@haystack.demon.co.uk> writes
>John,
>
>The same problem arises with big points, thick lines and with text.
>Here is an first attempt at dealing with it.
>

<Snip>
>
>One undesirable feature of this is that we are relying the hidden frame and
>ticks in gr to make room for the versions in fat.
>

<Snip>

Thank you very much! That gives me exactly what I needed. At first I
thought it was a complete solution but I now see what you mean about an
"undesirable feature". There seems to be a small problem with
FullGraphics in terms of the position and orientation of FrameLabels and
PlotLabel (fortunately easy to overcome: before, I had absolutely
nothing!).

*************example********************
In[1]:=
Masked[gr_Graphics, st___] :=
Module[{fat, pr, mask, e, x1, x2, y1,y2},
(*get the explicit graphics for frame, and frameticks*)
fat = Delete[FullGraphics[gr], {1, 1}];
(*get the explicit plotrange for gt*)
{{x1, x2}, {y1, y2}} = pr = PlotRange[gr];
(*calculate a suitable mask with style st*)
e = Max[x2 - x1, y2 - y1];
mask = Graphics[{st,
Polygon[{{x1, y1}, {x2, y1}, {x2, y2}, {x1, y2}, {x1, y1},
{x1 - e, y1 - e}, {x1 - e, y2 + e}, {x2 + e, y2 + e},
{x2 + e, y1 - e}, {x1 - e, y1 - e}}]}];
(*show the graphics in the right order*)
Show[gr, mask, fat, PlotRange -> pr]]

In[2]:=
gr2 = Show[
Graphics[{Polygon[{{-1, 0}, {2, -2}, {2, 1}}],
PointSize[0.5],Point[{1, 1}]}],
Frame -> True, FrameTicks -> True,
PlotRange -> {{0, 1}, {0, 1}},
FrameLabel -> {"X Axis", "Y Axis"},
PlotLabel -> "Plot Label"]

In[3]:=
Masked[gr2, RGBColor[1, 1, 1]]

In[4]:=
Select[ToString[#] & /@ Flatten[FullGraphics[gr2] /. Graphics -> List],
StringPosition[#, "Axis"] =!= {} &]

Out[4]=
{"Text[X Axis, {0.5, -0.0202254}, {0., 1.}]",
"Text[Y Axis, {-0.01875, 0.5}, {1., 0.}]"}
****************************************

This seems to show that Text is being called with 3 arguments, missing
the "offset" argument in position 3.

Incidentally, the behaviour of Display in generating output files is
rather different from Show. I still do not fully understand the
following, but it appears that the FrameLabel added by the Masked
function overrides the previous Text calls etc., completely the opposite
to the behaviour of Show. The new Export command does give the same as
Show.

****************************************
In[5]:=
Display["c:\\temp\\tmp1.gif", gr2, "GIF"]

In[6]:=
Display["c:\\temp\\tmp2.gif", Masked[gr2, RGBColor[1, 1, 1]], "GIF"]

In[7]:=
Select[ToString[#] & /@
Flatten[Masked[gr2, RGBColor[1, 1, 1]] /. Graphics -> List],
StringPosition[#, "Axis"] =!= {} &]

Out[7]=
{"Text[X Axis, {0.5, -0.0202254}, {0., 1.}]",
"Text[Y Axis, {-0.01875, 0.5}, {1., 0.}]",
"FrameLabel -> {X Axis, Y Axis}"}
****************************************

Thank you again! This saved me much time.

John.






Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.