Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: rasterarray border?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56056] Re: [mg55989] rasterarray border?
  • From: "David Park" <djmp at earthlink.net>
  • Date: Thu, 14 Apr 2005 08:55:30 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Manuel,

I would abandon RasterArray and instead make my own array of Polygons and
Lines. I made up my own von array and also reversed the rows so the plot
will correspond to the displayed MatrixForm of von. The Polygons have to be
drawn first and then the selected Polygons have to be outlined else the
blank polygon will cover up a previous outline.

Needs["Graphics`Colors`"]

pgon[j_, i_] :=
  Polygon[{{i, j}, {i + 1, j}, {i + 1, j + 1}, {i, j + 1}, {i, j}}]

polyarray[narray_] :=
  Module[{imax, jmax, poly, outline},
    {imax, jmax} = Dimensions[narray];
    {Table[
        poly = pgon[i - 1, j - 1];
        Switch[Part[narray, i, j],
          -1, {RGBColor[1, 1, 1], poly},
          0, {RGBColor[0.97, 0.97, 1], poly},
          1, {RGBColor[0.3, 0, 0], poly},
          2, {RGBColor[1, .78, .78], poly}], {i, 1, imax}, {j, 1, jmax}],
      Table[
        poly = pgon[i - 1, j - 1];
        outline = Sequence[Black, Line @@ poly];
        Switch[Part[narray, i, j],
          -1, {},
          0, {outline},
          1, {outline},
          2, {outline}], {i, 1, imax}, {j, 1, jmax}]}]


von = Array[Random[Integer, {-1, 2}] &, {5, 5}];
von2 = Reverse@von;
von//MatrixForm

Show[Graphics[
      {polyarray[von2]}],
    AspectRatio -> Automatic];

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

From: Manuel Marques-Pita [mailto:m.marques-pita at ed.ac.uk]
To: mathgroup at smc.vnet.net

hello,

I am drawing a rasterarray in which I need to draw a border/stroke round
some of the elements in the array (all the ones != -1 below).

Show[Graphics[RasterArray[von /.
           {-1 -> RGBColor[1, 1, 1],
             0 -> RGBColor[0.97, 0.97, 1],
             1 -> RGBColor[0.3, 0, 0],
             2 -> RGBColor[1, .78, .78]}]],
     AspectRatio -> Automatic];

I haven't found a way to do this yet, any ideas/suggestions?

Thanks in advance!

Manuel





  • Prev by Date: Re: confusion about Thread[]
  • Next by Date: Re: Mathlink
  • Previous by thread: Re: rasterarray border?
  • Next by thread: Font problems!