MathGroup Archive 2006

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

Search the Archive

Re: Graphics3D polygon face colors

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65085] Re: Graphics3D polygon face colors
  • From: "J Siehler" <jsiehler at gmail.com>
  • Date: Tue, 14 Mar 2006 06:00:03 -0500 (EST)
  • Organization: http://groups.google.com
  • References: <NDBBJGNHKLMPLILOIPPOGEHNEOAA.djmp@earthlink.net> <dv3083$qpf$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

AJ Friend wrote:
> Hi, thanks for the response. My problem isn't that I want to change the
> object color, I want to have the values of the colors of the faces so
> that I can use them elsewhere. I am taking each face from a polyhedron
> and displaying it as a flat polygon, but I want the polygon to have the
> same color as it has on the polyhedron (the outside face, specifically).
> Any ideas on how to do such a thing?

Well, this is tricky, but here's a start.  Use DisplayString applied to
your graphics object to get the low-level postscript code for it.
You'll find lots of lines that look like
0.123 0.707 0.542 r

which are abbreviated RGB color commands.  You need to pick these out
of the display string.  That's not hard, but matching them up to their
corresponding polygons will take a little more work than I can do
offhand right now.  But, for example, here you can make a list of
random triangles and extract all the different face colors that were
used (there's a lot of redundancy).

p = Table[Random[Real, {0, 1}], {8}, {3}, {3}];
polys = Graphics3D[Polygon /@ p];
colors = RGBColor @@ Take[
    StringSplit[#], 3] & /@ Select[StringSplit[DisplayString[polys],
"\n"], \
MatchQ[StringSplit[#], {a___, "r"}] &]


  • Prev by Date: Re: ShadowPlot3D
  • Next by Date: Re: Plot resolution
  • Previous by thread: Re: Graphics3D polygon face colors
  • Next by thread: Re: Graphics3D polygon face colors