Well, you've just written that convenience function yourself :-). It's not
more complicated than that.
The reason there isn't an exported function is because the general case is not
quite as simple as it may seem. For example, BGR and RGB both mean "RGB
colors," but with different internal storage order. Which do you care about,
storage order or "meaning"? When you access a value as `red(col)`, you're
always getting the red channel no matter how it's stored, whereas `comp1(col)`
might give you the red channel or might give you the blue channel. So
"converting to a tuple" might mean different things to different people ("red
first" or "component 1 first"?), which is why there's no general
function---it's
so simple to write, you might as well write it yourself, because you know what
you want it to mean.
When you're dealing with arrays, you can always use `reinterpret` to force an
interpretation.
Best,
--Tim
On Tuesday, July 5, 2016 9:59:00 AM CDT Islam Badreldin wrote:
> Forgot to add `using ColorTypes` to the top of the minimal example.
>
> -Islam
>
> On Tuesday, July 5, 2016 at 12:55:37 PM UTC-4, Islam Badreldin wrote:
> > Hello,
> >
> > I was experimenting with plotting using PyPlot and I wanted to create line
> > plots with custom colors. I wanted to use a color palette from
> > ColorBrewer.jl, which returns the colors as an array of ColorTypes colors.
> > I wanted to convert the returned colors to a Tuple, e.g.
> > (0.894,0.102,0.11), in order to pass it to PyPlot. The following snippet
> > works for me,
> >
> >
> > using PyPlot
> >
> > using ColorBrewer
> >
> > myc=palette("Set1",9)
> >
> > for i in 1:9 plot(rand(100),c=(comp1(myc[i]),comp2(myc[i]),comp3(myc[i])))
> > end
> >
> >
> > My question is, is there a convenience function that can directly give me
> > the desired tuple, without having to manually construct it using
> > (comp1,comp2,comp3)?
> >
> > Thanks,
> > Islam