MathGroup Archive 2001

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

Search the Archive

Re: Re: ColorFunction for ListPlot3D, ListContourPlot or ListDensityPlot ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29134] Re: Re: ColorFunction for ListPlot3D, ListContourPlot or ListDensityPlot ?
  • From: "John Jowett" <John.Jowett at cern.ch>
  • Date: Wed, 30 May 2001 23:28:22 -0400 (EDT)
  • Organization: CERN
  • References: <QAHQ6.4092$E6.30318@ralph.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

David,

You're right - in general CMYKColor does not get converted to RGBColor. My
example did work however because I happened to use the colours only for
surface illumination and, as it says in the help for CMYKColor:

"CMYKColor specifications are automatically converted to RGBColor when
simulated lighting calculations are done."

I suppose this is why there is a directive CMYColor (without the 'K') in the
Colors package, and it is defined in terms of RGBColor.

John

"David Park" <djmp at earthlink.net> wrote in message
news:QAHQ6.4092$E6.30318 at ralph.vnet.net...
> John,
>
> I think it is a great idea to always load the Graphics`Colors` package.
But
> my routine doesn't really work quite right with your example. As first
> presented, the routine assumes that the colors are both RGBColors. Here is
a
> modified routine which does some checking on the heads of the colors, and
> also clips z so it is always in the domain 0 to 1.
>
> ColorMix[color1_, color2_][z_] /; Head[color1] === Head[color2] :=
>    Module[{c1, c2, head, z2},
>     head = Head[color1];
>     z2 = Max[0, Min[1, z]];
>     c1 = List @@ color1;
>     c2 = List @@ color2;
>     head @@ ((1 - z2)c1 + z2 c2)]
>
> Then, either of these works.
>
> blend = ColorMix[CMYKColor[0, 1, .8, 0], CMYKColor[1, 0, .8, 0]];
> blend = ColorMix[BurntSienna, PaleGreen];
>
> Plot3D[Sin[x + 3*y - Random[]], {x, 0, 4}, {y, 0, 3},
>   ColorFunction -> blend, PlotPoints -> 31, ImageSize -> 450]
>
> I don't think Mathematica gives a direct way to convert one type of color
> specification to another, say CMYKColor to RGBColor, such that they could
be
> combined in a routine like ColorMix.
>
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
>
> > From: John Jowett [mailto:John.Jowett at cern.ch]
To: mathgroup at smc.vnet.net
> >
> > David,
> >     It  may be worth remarking that your function is even more useful
> > (without modification!) if you first load the standard package
> >
> > <<Graphics`Colors`
> >
> > Then you can mix ways of specifying colours to your heart's content,
e.g.,
> >
> > blend =ColorMix[BurntSienna,CMYKColor[1,..8,0]]
> >
> > Plot3D[Sin[x+3 y-Random[]],{x,0,4},{y,0,3},ColorFunction->blend]
> >
> > John Jowett
> >
> > "David Park" <djmp at earthlink.net> wrote in message
> > news:oplP6.3625$8I3.14298 at ralph.vnet.net...
> > > Joerg,
> > >
> > > Here is a ColorMix function for blending two colors. (I think that Bob
> > > Hanlon had a similar routine posted a few days ago.)
> > >
> > > ColorMix[color1_, color2_][z_] :=
> > >   Module[{c1, c2},
> > >     c1 = List @@ color1;
> > >     c2 = List @@ color2;
> > >     RGBColor @@ ((1 - z)c1 + z c2)]
> > >
> > > Here, I make a contour plot that shades from brown to green. I
> > picked the
> > > colors off the color selector in the menu.
> > >
> > > ContourPlot[Sin[x*y], {x, -Pi/2, Pi/2},
> > >    {y, -Pi/2, Pi/2}, PlotPoints -> 30, Contours -> 10,
> > >    ContourLines -> False, ColorFunction ->
> > >     ColorMix[RGBColor[0.867201, 0.660166, 0.312505],
> > >      RGBColor[0.265629, 0.398444, 0.101564]]];
> > >
> > > David Park
> > > djmp at earthlink.net
> > > http://home.earthlink.net/~djmp/
> > >
> >
> >
> >
> >
>
>
>




  • Prev by Date: AW: Need help writing geology software using cirlces
  • Next by Date: mutivariable interpolation functions
  • Previous by thread: RE: Re: ColorFunction for ListPlot3D, ListContourPlot or ListDensityPlot ?
  • Next by thread: CalculationCenter woes