How to draw a colored line which changes from yellow to red?

View: New views
12 Messages — Rating Filter:   Alert me  

How to draw a colored line which changes from yellow to red?

by mhofert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I was wondering if it's possible to draw a colored line (using the  
\draw command) which continuously changes its color from yellow to  
red (or similarly, like a rainbow).
I know the \shade command, however, this is only for coloring areas,  
not lines.

Any help or comment is appreciated.

Thanks in advance.

Marius

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: How to draw a colored line which changes from yellow to red?

by Kjell Magne Fauske :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Sep 14, 2009 at 8:09 AM, Hofert Marius <m_hofert@...> wrote:

> Hi,
>
> I was wondering if it's possible to draw a colored line (using the
> \draw command) which continuously changes its color from yellow to
> red (or similarly, like a rainbow).
> I know the \shade command, however, this is only for coloring areas,
> not lines.
>
> Any help or comment is appreciated.
>

A similar question was asked some time ago. Mark Wibrow suggested
using a custom decoration:
http://www.nabble.com/shading-the-color-of-a-line-td16591651.html#a16594973

- Kjell Magne Fauske

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: How to draw a colored line which changes from yellow to red?

by mhofert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is there no other way of solving this problem? This seems to be a lot of code (which is not easy to understand, at least for me) for this simple problem.

Re: How to draw a colored line which changes from yellow to red?

by Hans Meine-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Monday 14 September 2009 13:37:40 mhofert wrote:
> Is there no other way of solving this problem? This seems to be a lot of
> code (which is not easy to understand, at least for me) for this simple
> problem.

No.  It's simply not supported.

OTOH, a line is just a thin rectangle (depending on the line width), so you
might want to go with a plain rectangle instead.

HTH,
  Hans

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: How to draw a colored line which changes from yellow to red?

by mhofert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Okay, thanks!
I already tried to use a rectangle but couldn't solve the problem. I will try again and see if it works (if so, I will post it).

Hans Meine-4 wrote:
On Monday 14 September 2009 13:37:40 mhofert wrote:
> Is there no other way of solving this problem? This seems to be a lot of
> code (which is not easy to understand, at least for me) for this simple
> problem.

No.  It's simply not supported.

OTOH, a line is just a thin rectangle (depending on the line width), so you
might want to go with a plain rectangle instead.

HTH,
  Hans

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: How to draw a colored line which changes from yellow to red?

by Goebel, Juergen, OPES27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Hans Meine-4 wrote:

> OTOH, a line is just a thin rectangle (depending on the line width),
so
> you might want to go with a plain rectangle instead.

ACK, that's a makeshift solution for straight lines,
but what about arcs, circles, arrows and so on?

Juergen


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: How to draw a colored line which changes from yellow to red?

by marco.sbodio :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

With a rectangle it's pretty simple:

[[
\documentclass[a4paper,10pt]{article}

\usepackage{tikz}

\title{Yellow-Red Line}
\author{Marco Luca Sbodio}

\begin{document}

\maketitle

\section{A Yellow-Red Line}

\begin{tikzpicture}

  \node
    [ rectangle,
      left color=yellow,
      right color=red,
      minimum height=1pt,
      minimum width=5cm,
      inner sep=0pt,
    ] {};

\end{tikzpicture}

\end{document}
]]

I hope this helps.

Best Regards,
marco

On Mon, Sep 14, 2009 at 2:06 PM, mhofert <m_hofert@...> wrote:

>
> Okay, thanks!
> I already tried to use a rectangle but couldn't solve the problem. I will
> try again and see if it works (if so, I will post it).
>
>
> Hans Meine-4 wrote:
>>
>> On Monday 14 September 2009 13:37:40 mhofert wrote:
>>> Is there no other way of solving this problem? This seems to be a lot of
>>> code (which is not easy to understand, at least for me) for this simple
>>> problem.
>>
>> No.  It's simply not supported.
>>
>> OTOH, a line is just a thin rectangle (depending on the line width), so
>> you
>> might want to go with a plain rectangle instead.
>>
>> HTH,
>>   Hans
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> 30-Day
>> trial. Simplify your report design, integration and deployment - and focus
>> on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> pgf-users mailing list
>> pgf-users@...
>> https://lists.sourceforge.net/lists/listinfo/pgf-users
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-to-draw-a-colored-line-which-changes-from-yellow-to-red--tp25430812p25434631.html
> Sent from the pgf-users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> pgf-users mailing list
> pgf-users@...
> https://lists.sourceforge.net/lists/listinfo/pgf-users
>



--
Marco Sbodio
perl -e 'while(++$_){print$_,$/if("x"x$_)!~/^(xx+)\1+$/}'

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: How to draw a colored line which changes from yellow to red?

by marco.sbodio :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Sep 14, 2009 at 3:14 PM, Goebel, Juergen
<juergen.goebel@...> wrote:
>> Hans Meine-4 wrote:
>
>> OTOH, a line is just a thin rectangle (depending on the line width),
> so
>> you might want to go with a plain rectangle instead.
>
> ACK, that's a makeshift solution for straight lines,
> but what about arcs, circles, arrows and so on?
>

Here is an example with an arc

[[
\documentclass[a4paper,10pt]{article}

\usepackage{tikz}

\title{Yellow-Red Arc}
\author{Marco Luca Sbodio}

\begin{document}

\maketitle

\section{A Yellow-Red Arc}

\begin{tikzpicture}

  \path
    [ left color=yellow,
      right color=red,
    ] (0,0) to [bend left] (3,0) --
      (2.9,-0.1) to [bend right] (0.1,-0.1) --
      cycle;

\end{tikzpicture}

\end{document}
]]

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: How to draw a colored line which changes from yellow to red?

by Sebastián PEÑA SALDARRIAGA :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Juergen,
Most of the time you can draw a shape twice with different dimensions.
First you draw the shade-filled shape the you draw a second one filled
with the background color smaller than the first.
Assuming a white background, one can draw an empty circle with colored
shaded line :

\begin{tikzpicture}
   \path[coordinate] (0,0) coordinate (center);
   \shade[shading=color wheel] (center) circle (2.2cm);
   \path[draw=none, fill=white]  (center) circle (1.6cm);
\end{tikzpicture}

You need to better tune the shading style to get the effect you want on
your circle. Hope this helps,

Sebastian

Goebel, Juergen a écrit :

>> Hans Meine-4 wrote:
>>    
>
>  
>> OTOH, a line is just a thin rectangle (depending on the line width),
>>    
> so
>  
>> you might want to go with a plain rectangle instead.
>>    
>
> ACK, that's a makeshift solution for straight lines,
> but what about arcs, circles, arrows and so on?
>
> Juergen
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> pgf-users mailing list
> pgf-users@...
> https://lists.sourceforge.net/lists/listinfo/pgf-users
>  



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: How to draw a colored line which changes from yellow to red?

by Goebel, Juergen, OPES27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sebastián PEÑA SALDARRIAGA wrote:

> \begin{tikzpicture}
>    \path[coordinate] (0,0) coordinate (center);
>    \shade[shading=color wheel] (center) circle (2.2cm);
>    \path[draw=none, fill=white]  (center) circle (1.6cm);
> \end{tikzpicture}

Marco Luca Sbodio wrote:

> \begin{tikzpicture}
>
>   \path
>     [ left color=yellow,
>       right color=red,
>     ] (0,0) to [bend left] (3,0) --
>       (2.9,-0.1) to [bend right] (0.1,-0.1) --
>       cycle;
>
> \end{tikzpicture}


You're right, both of you (thanks), but that are still
some makeshift solutions (although they are working fine).

Juergen

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: How to draw a colored line which changes from yellow to red?

by Kjell Magne Fauske :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Sep 14, 2009 at 3:14 PM, Goebel, Juergen
<juergen.goebel@...> wrote:

>> Hans Meine-4 wrote:
>
>> OTOH, a line is just a thin rectangle (depending on the line width),
> so
>> you might want to go with a plain rectangle instead.
>
> ACK, that's a makeshift solution for straight lines,
> but what about arcs, circles, arrows and so on?
>
> Juergen
>

Mark Wibrow's solution works for arcs, circles and arrows. Don't be
afraid of the amount of code.

- Kjell Magne Fauske

>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> pgf-users mailing list
> pgf-users@...
> https://lists.sourceforge.net/lists/listinfo/pgf-users
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: How to draw a colored line which changes from yellow to red?

by Goebel, Juergen, OPES27 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kjell Magne Fauske wrote:

> Mark Wibrow's solution works for arcs, circles and arrows. Don't be
> afraid of the amount of code.

You really got my number. ;-))

I'll need to take some time and walk through Mark's code.

Juergen

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users