|
View:
New views
14 Messages
—
Rating Filter:
Alert me
|
|
|
The hsb color modelHi
I wondered if it is possible to define colors in the hsv / hsb color model, when making drawings in tikz? According to the manual (14.2 Specifying a color) the \definecolor command only implements the rgb and gray color models, but is it possible to bypass this limitation? Henrik ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color modelOn Wed, Oct 22, 2008 at 9:33 PM, Henrik Skov Midtiby
<henrikmidtiby@...> wrote: > Hi > > I wondered if it is possible to define colors in the hsv / hsb color model, when making drawings in tikz? > > According to the manual (14.2 Specifying a color) the \definecolor command > only implements the rgb and gray color models, but is it possible to bypass > this limitation? > > Henrik > If I understand the manual correctly, the limitation only applies to plain TeX. When using LaTeX xcolor is used and I believe xcolor supports the hsv/hsb color model. - Kjell Magne Fauske ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color model> If I understand the manual correctly, the limitation only applies to
> plain TeX. When using LaTeX xcolor is used and I believe xcolor > supports the hsv/hsb color model. I have tried the code given below, which renders badly and raises the a warning (see warning after the code snippet). It seems that tikz doesn't implement the hsb color model. In the manual (14.2 Specifying a Color) > Because of this, pgf emulates the xcolor package, > though the emulation is extremely basic... The goal for my coding is to draw the hsv color cone from this address: http://en.wikipedia.org/wiki/Image:HSV_cone.png Henrik <code> \documentclass{article} \usepackage{xcolor} \usepackage{tikz} \begin{document} \begin{tikzpicture} % Draws a yellow filled circle \definecolor{currentcolor}{rgb}{1, 1, 0} \draw[fill=currentcolor] (0, 0) circle (1cm); % Draws a black filled circle (it should be red ...) \definecolor{currentcolor}{hsb}{1, 1, 1} \draw[fill=currentcolor] (3, 0) circle (1cm); \end{tikzpicture} \end{document} </code> <warning> ./hsvcolorcone.tex:14:Package pgfbase Error: Unsupported color model `hsb'. Sorry. \draw[fill=currentcolor] (3, 0) circle (1cm); </warning> ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color modelOn Wed, Oct 22, 2008 at 11:13 PM, Henrik Skov Midtiby
<henrikmidtiby@...> wrote: >> If I understand the manual correctly, the limitation only applies to >> plain TeX. When using LaTeX xcolor is used and I believe xcolor >> supports the hsv/hsb color model. > I have tried the code given below, which renders badly and raises the a warning (see warning after the code snippet). > > It seems that tikz doesn't implement the hsb color model. In the manual (14.2 Specifying a Color) >> Because of this, pgf emulates the xcolor package, >> though the emulation is extremely basic... > > The goal for my coding is to draw the hsv color cone from this address: > http://en.wikipedia.org/wiki/Image:HSV_cone.png > > Henrik > > <code> > \documentclass{article} > \usepackage{xcolor} > \usepackage{tikz} > > \begin{document} > > \begin{tikzpicture} > % Draws a yellow filled circle > \definecolor{currentcolor}{rgb}{1, 1, 0} > \draw[fill=currentcolor] (0, 0) circle (1cm); > > % Draws a black filled circle (it should be red ...) > \definecolor{currentcolor}{hsb}{1, 1, 1} > \draw[fill=currentcolor] (3, 0) circle (1cm); > \end{tikzpicture} > > \end{document} > </code> > > <warning> > ./hsvcolorcone.tex:14:Package pgfbase Error: Unsupported color model `hsb'. Sorry. \draw[fill=currentcolor] (3, 0) circle (1cm); > </warning> > You are right. A workaround is to set the target color model to rgb. xcolor will then do the necessary conversions for you: <code> \documentclass{article} \usepackage[rgb]{xcolor}%<- set target model \usepackage{tikz} \begin{document} \begin{tikzpicture} % Draws a yellow filled circle \definecolor{currentcolor}{rgb}{1, 1, 0} \draw[fill=currentcolor] (0, 0) circle (1cm); % Draws a black filled circle (it should be red ...) \foreach \x in {0,0.05,...,1.1} { \definecolor{currentcolor}{hsb}{\x, 1, \x} \draw[fill=currentcolor,xshift=40*\x] (3, 0) circle (1cm); } \end{tikzpicture} \end{document} </code> - Kjell Magne Fauske ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color model> You are right. A workaround is to set the target color model to rgb. > xcolor will then do the necessary conversions for you: Great! Thanks for the workaround. Henrik PS: My code new looks like <code> \documentclass{article} \usepackage[rgb]{xcolor} \usepackage{tikz} \begin{document} \begin{tikzpicture} \foreach \x in {0,0.0111,...,1} { \definecolor{currentcolor}{hsb}{\x, 1, 1} \draw[draw=none, fill=currentcolor] (-360*\x+88:2) -- (-360*\x+88:3.8) -- (-360*\x+92:3.8) -- (-360*\x+92:2) -- cycle; } \draw [draw=none, fill=red] (90:1.5) circle (2cm); \draw [draw=none, fill=green] (-30:1.5) circle (2cm); \draw [draw=none, fill=blue] (210:1.5) circle (2cm); \begin{scope} % red + green = yellow \clip (90:1.5) circle(2cm); \draw [draw=none, fill=yellow] (-30:1.5) circle (2cm); \end{scope} % blue + red = purple \begin{scope} \clip (210:1.5) circle(2cm); \draw [draw=none, fill=magenta] (90:1.5) circle (2cm); \end{scope} \begin{scope} % green + blue = cyan \clip (-30:1.5) circle(2cm); \draw [draw=none, fill=cyan] (210:1.5) circle (2cm); \end{scope} \begin{scope} % red + green + blue = white \clip (90:1.5) circle(2cm); \clip (210:1.5) circle(2cm); \draw [draw=none, fill=white] (-30:1.5) circle (2cm); \end{scope} \draw (0, 0) circle (3.9cm); %\foreach \x/\y in {0/270, 30/300, 60/330, 90/0, 120/30, 150/60, 180/90, 210/120, 240/150, 270/180, 300/210, 330/240} % \draw (\x:3.8) -- (\x:4.0) (\x:4.4) node {$\y^\circ$}; \foreach \x in {0, 30, ..., 330} \draw (-\x+90:3.8) -- (-\x+90:4.0) (-\x+90:4.4) node {$\x^\circ$}; \end{tikzpicture} \end{document} </code> ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color modelOn Thu, Oct 23, 2008 at 4:40 PM, Henrik Skov Midtiby
<henrikmidtiby@...> wrote: > >> You are right. A workaround is to set the target color model to rgb. >> xcolor will then do the necessary conversions for you: > Great! Thanks for the workaround. > > Henrik > > PS: My code new looks like > <code> > \documentclass{article} > \usepackage[rgb]{xcolor} > \usepackage{tikz} > > \begin{document} > \begin{tikzpicture} > \foreach \x in {0,0.0111,...,1} { > \definecolor{currentcolor}{hsb}{\x, 1, 1} > \draw[draw=none, fill=currentcolor] > (-360*\x+88:2) -- (-360*\x+88:3.8) > -- (-360*\x+92:3.8) -- (-360*\x+92:2) -- cycle; > } > \draw [draw=none, fill=red] (90:1.5) circle (2cm); > \draw [draw=none, fill=green] (-30:1.5) circle (2cm); > \draw [draw=none, fill=blue] (210:1.5) circle (2cm); > \begin{scope} % red + green = yellow > \clip (90:1.5) circle(2cm); > \draw [draw=none, fill=yellow] (-30:1.5) circle (2cm); > \end{scope} % blue + red = purple > \begin{scope} > \clip (210:1.5) circle(2cm); > \draw [draw=none, fill=magenta] (90:1.5) circle (2cm); > \end{scope} > \begin{scope} % green + blue = cyan > \clip (-30:1.5) circle(2cm); > \draw [draw=none, fill=cyan] (210:1.5) circle (2cm); > \end{scope} > \begin{scope} % red + green + blue = white > \clip (90:1.5) circle(2cm); > \clip (210:1.5) circle(2cm); > \draw [draw=none, fill=white] (-30:1.5) circle (2cm); > \end{scope} > \draw (0, 0) circle (3.9cm); > %\foreach \x/\y in {0/270, 30/300, 60/330, 90/0, 120/30, 150/60, 180/90, 210/120, 240/150, 270/180, 300/210, 330/240} > % \draw (\x:3.8) -- (\x:4.0) (\x:4.4) node {$\y^\circ$}; > \foreach \x in {0, 30, ..., 330} > \draw (-\x+90:3.8) -- (-\x+90:4.0) (-\x+90:4.4) node {$\x^\circ$}; > \end{tikzpicture} > \end{document} > </code> > Nice illustration! For the record, PGF does support the CMY and CMYK color models. This means that you can write: \usepackage[cmyk]{xcolor} \usepackage[cmy]{xcolor} - Kjell Magne Fauske ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color modelThis is very nice, I agree.
But I was wondering, could you achieve something similar using a shading dictionary ? Yes, if you accept a linear or radial shading, I am sure. Does Pgf/Tikz allow other kinds of shading, as allowed by the PDF standard ? It would be nice to make the PDF engine do all the work, and it would certainly make for a smaller file size ? Kjell Magne Fauske wrote: > On Thu, Oct 23, 2008 at 4:40 PM, Henrik Skov Midtiby > <henrikmidtiby@...> wrote: > >>> You are right. A workaround is to set the target color model to rgb. >>> xcolor will then do the necessary conversions for you: >>> >> Great! Thanks for the workaround. >> >> Henrik >> >> PS: My code new looks like >> <code> >> \documentclass{article} >> \usepackage[rgb]{xcolor} >> \usepackage{tikz} >> >> \begin{document} >> \begin{tikzpicture} >> \foreach \x in {0,0.0111,...,1} { >> \definecolor{currentcolor}{hsb}{\x, 1, 1} >> \draw[draw=none, fill=currentcolor] >> (-360*\x+88:2) -- (-360*\x+88:3.8) >> -- (-360*\x+92:3.8) -- (-360*\x+92:2) -- cycle; >> } >> \draw [draw=none, fill=red] (90:1.5) circle (2cm); >> \draw [draw=none, fill=green] (-30:1.5) circle (2cm); >> \draw [draw=none, fill=blue] (210:1.5) circle (2cm); >> \begin{scope} % red + green = yellow >> \clip (90:1.5) circle(2cm); >> \draw [draw=none, fill=yellow] (-30:1.5) circle (2cm); >> \end{scope} % blue + red = purple >> \begin{scope} >> \clip (210:1.5) circle(2cm); >> \draw [draw=none, fill=magenta] (90:1.5) circle (2cm); >> \end{scope} >> \begin{scope} % green + blue = cyan >> \clip (-30:1.5) circle(2cm); >> \draw [draw=none, fill=cyan] (210:1.5) circle (2cm); >> \end{scope} >> \begin{scope} % red + green + blue = white >> \clip (90:1.5) circle(2cm); >> \clip (210:1.5) circle(2cm); >> \draw [draw=none, fill=white] (-30:1.5) circle (2cm); >> \end{scope} >> \draw (0, 0) circle (3.9cm); >> %\foreach \x/\y in {0/270, 30/300, 60/330, 90/0, 120/30, 150/60, 180/90, 210/120, 240/150, 270/180, 300/210, 330/240} >> % \draw (\x:3.8) -- (\x:4.0) (\x:4.4) node {$\y^\circ$}; >> \foreach \x in {0, 30, ..., 330} >> \draw (-\x+90:3.8) -- (-\x+90:4.0) (-\x+90:4.4) node {$\x^\circ$}; >> \end{tikzpicture} >> \end{document} >> </code> >> >> > > Nice illustration! > > For the record, PGF does support the CMY and CMYK color models. This > means that you can write: > > \usepackage[cmyk]{xcolor} > \usepackage[cmy]{xcolor} > > - Kjell Magne Fauske > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > pgf-users mailing list > pgf-users@... > https://lists.sourceforge.net/lists/listinfo/pgf-users > > > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color modelHi!
pgf does support the following shading types of the pgf standard: - axis shadings - radial shadings - functional shadings The last type of shading can, indeed, be used to let the renderer produce the color circle. However, someone would have to sit down and write and test the necessary shading specification (would take half an hour, I presume). If someone has it, please post it, we can put it in a lib, other people might like this. Best regards, Till Am 24.10.2008 um 10:12 schrieb Ken Starks: > This is very nice, I agree. > > But I was wondering, could you achieve something similar using a > shading > dictionary ? Yes, if you accept a linear or radial shading, I am > sure. Does > Pgf/Tikz allow other kinds of shading, as allowed by the PDF > standard ? It > would be nice to make the PDF engine do all the work, and it would > certainly > make for a smaller file size ? > > > > Kjell Magne Fauske wrote: >> On Thu, Oct 23, 2008 at 4:40 PM, Henrik Skov Midtiby >> <henrikmidtiby@...> wrote: >> >>>> You are right. A workaround is to set the target color model to >>>> rgb. >>>> xcolor will then do the necessary conversions for you: >>>> >>> Great! Thanks for the workaround. >>> >>> Henrik >>> >>> PS: My code new looks like >>> <code> >>> \documentclass{article} >>> \usepackage[rgb]{xcolor} >>> \usepackage{tikz} >>> >>> \begin{document} >>> \begin{tikzpicture} >>> \foreach \x in {0,0.0111,...,1} { >>> \definecolor{currentcolor}{hsb}{\x, 1, 1} >>> \draw[draw=none, fill=currentcolor] >>> (-360*\x+88:2) -- (-360*\x+88:3.8) >>> -- (-360*\x+92:3.8) -- (-360*\x+92:2) -- cycle; >>> } >>> \draw [draw=none, fill=red] (90:1.5) circle (2cm); >>> \draw [draw=none, fill=green] (-30:1.5) circle (2cm); >>> \draw [draw=none, fill=blue] (210:1.5) circle (2cm); >>> \begin{scope} % red + green = yellow >>> \clip (90:1.5) circle(2cm); >>> \draw [draw=none, fill=yellow] (-30:1.5) circle (2cm); >>> \end{scope} % blue + red = purple >>> \begin{scope} >>> \clip (210:1.5) circle(2cm); >>> \draw [draw=none, fill=magenta] (90:1.5) circle (2cm); >>> \end{scope} >>> \begin{scope} % green + blue = cyan >>> \clip (-30:1.5) circle(2cm); >>> \draw [draw=none, fill=cyan] (210:1.5) circle (2cm); >>> \end{scope} >>> \begin{scope} % red + green + blue = white >>> \clip (90:1.5) circle(2cm); >>> \clip (210:1.5) circle(2cm); >>> \draw [draw=none, fill=white] (-30:1.5) circle (2cm); >>> \end{scope} >>> \draw (0, 0) circle (3.9cm); >>> %\foreach \x/\y in {0/270, 30/300, 60/330, 90/0, 120/30, 150/60, >>> 180/90, 210/120, 240/150, 270/180, 300/210, 330/240} >>> % \draw (\x:3.8) -- (\x:4.0) (\x:4.4) node {$\y^\circ$}; >>> \foreach \x in {0, 30, ..., 330} >>> \draw (-\x+90:3.8) -- (-\x+90:4.0) (-\x+90:4.4) node {$\x^ >>> \circ$}; >>> \end{tikzpicture} >>> \end{document} >>> </code> >>> >>> >> >> Nice illustration! >> >> For the record, PGF does support the CMY and CMYK color models. This >> means that you can write: >> >> \usepackage[cmyk]{xcolor} >> \usepackage[cmy]{xcolor} >> >> - Kjell Magne Fauske >> >> ------------------------------------------------------------------------- >> This SF.Net email is sponsored by the Moblin Your Move Developer's >> challenge >> Build the coolest Linux based applications with Moblin SDK & win >> great prizes >> Grand prize is a trip for two to an Open Source event anywhere in >> the world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> _______________________________________________ >> pgf-users mailing list >> pgf-users@... >> https://lists.sourceforge.net/lists/listinfo/pgf-users >> >> >> > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > pgf-users mailing list > pgf-users@... > https://lists.sourceforge.net/lists/listinfo/pgf-users > -- Prof. Dr. Till Tantau <tantau@...> http://www.tcs.uni-luebeck.de ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color modelHello,
Here is a version of a HSV ring in which I have used a functional shading. The main guts of the thing contains code to turn three HSV values on the stack into three RGB values, which I hope will be useful elsewhere. I have tried to put in quite a bit of documentation, in terms of stack listings on nearly every line. Bye for now, Ken. %%% code starts %%%%%%%%%% \documentclass{article} \usepackage[rgb]{xcolor} \usepackage{colortbl} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \pgfdeclarefunctionalshading{HSVsweep} {\pgfpoint{-2cm}{-2cm}} {\pgfpoint{2cm}{2cm}} {} { % x y 2 copy % ... x y x y 2 copy 0 eq exch 0 eq and { pop pop 0.0 } % silently deal with error: return arbitrary heading of zero for origin {atan 360.0 div} % ... x y heading; heading being in the interval [0, 1.0] ifelse % because we will use it for 'Hue' dup 360 eq { pop 0.0 }{} ifelse % if heading is 360 degrees, make it zero instead 3 1 roll % ... heading x y dup mul % ... heading x y*y exch dup mul % ... heading y*y x*x add sqrt % ... heading radius_pt (distance from origin in points) 56 div % scale it means a radius of just under 2 cm dup 1.0 ge % BOOLEAN. ready to clamp to interval [0, 1.0] { pop 1.0 }{} ifelse % We shall use the scaled radius as 'Saturation' 2.5 mul 0.25 sub % now, Radius in [0.1, 0.5] --> Saturation in [0.0, 1.0]. Saturation varies between the two radii 1.0 % ... H S V ( with 'Value' set to literal constant of 1.0 ) false % TEST I [ S == 1.0 ] { % BLOCK A [ take stack to V V V ] achromatic case } { % BLOCK B take stack to V T Q P i % C version to use as model: % H' = H * 6 % i = floor(H') % f = H' - i % P = V * (1.0 - S) % Q = V * (1.0 - (S*f)) % T = V * (1.0 - (S * (1.0 - f))) 3 -1 roll 6.0 mul dup 4 1 roll % H' S V H' floor % H' S V i dup 5 1 roll % i H' S V i 3 index sub neg % i H' S V f 1.0 3 index sub % i H' S V f (1.0 - S ) 2 index mul % i H' S V f P 6 1 roll % P i H' S V f dup 3 index mul neg 1.0 add % P i H' S V f ( 1.0 - (f*S)) 2 index mul % P i H' S V f Q 7 1 roll % Q P i H' S V f neg 1.0 add % Q P i H' S V (1.0 - f) 2 index mul neg 1.0 add % Q P i H' S V (1.0 - S * (1.0 - f)) 1 index mul % Q P i H' S V T 7 2 roll % V T Q P i H' S pop pop % V T Q P i %%% % end of BLOCK B. The rest is just stack manipulation dup 0 eq % TEST II [ i == 0 ] { % BLOCK C [ take stack to V T P ] pop exch pop } { dup 1 eq % TEST III [ i == 1 ] { % BLOCK D [ take stack to Q V P ] pop exch 4 1 roll exch pop } { dup 2 eq % TEST IV [ i == 2 ] { % BLOCK E [ take stack to P V T ] pop 4 1 roll pop } { dup 3 eq % TEST V [ i == 3 ] { % BLOCK F [ take stack to P Q V ] pop exch 4 2 roll pop } { dup 4 eq % TEST VI [ i == 4 ] { % BLOCK G [ take stack to T P V ] pop exch pop 3 -1 roll } { % BLOCK H [ take stack to V P Q ] pop 3 1 roll exch pop } ifelse } ifelse % for V } ifelse % for IV } ifelse % for III } ifelse % for II % BLOCK I } ifelse % for I % BLOCK J % .. RGB at last } % \pgfuseshading{HSVsweep} \begin{tikzpicture} % The shape is the region between two circles, centered at the origin % Drawn in opposite directions to allow a non-zero fill to work. \def\radius{3.8cm} \def\radiusB{1.5cm} \def\cveclen{0.55228475*\radius} \def\cveclenB{0.55228475*\radiusB} \pgfpathmoveto{\pgfpoint{\radius}{0cm}}; \pgfpathcurveto {\pgfpoint{\radius}{\cveclen}}{\pgfpoint{\cveclen}{\radius}}{\pgfpoint{0cm}{\radius}}; \pgfpathcurveto {\pgfpoint{-\cveclen}{\radius}}{\pgfpoint{-\radius}{\cveclen}}{\pgfpoint{-\radius}{0cm}}; \pgfpathcurveto {\pgfpoint{-\radius}{-\cveclen}}{\pgfpoint{-\cveclen}{-\radius}}{\pgfpoint{0cm}{-\radius}}; \pgfpathcurveto {\pgfpoint{\cveclen}{-\radius}}{\pgfpoint{\radius}{-\cveclen}}{\pgfpoint{\radius}{0cm}}; \pgfpathmoveto{\pgfpoint{\radiusB}{0cm}}; \pgfpathcurveto {\pgfpoint{\radiusB}{-\cveclenB}}{\pgfpoint{\cveclenB}{-\radiusB}}{\pgfpoint{0cm}{-\radiusB}}; \pgfpathcurveto {\pgfpoint{-\cveclenB}{-\radiusB}}{\pgfpoint{-\radiusB}{-\cveclenB}}{\pgfpoint{-\radiusB}{0cm}}; \pgfpathcurveto {\pgfpoint{-\radiusB}{\cveclenB}}{\pgfpoint{-\cveclenB}{\radiusB}}{\pgfpoint{0cm}{\radiusB}}; \pgfpathcurveto {\pgfpoint{\cveclenB}{\radiusB}}{\pgfpoint{\radiusB}{\cveclenB}}{\pgfpoint{\radiusB}{0cm}}; \pgfclosepath; \pgfshadepath{HSVsweep}{0} \pgfusepath{stroke} \foreach \x in {0, 30, ..., 330} \draw (-\x+90:3.8) -- (-\x+90:4.0) (-\x+90:4.4) node {$\x^\circ$}; \end{tikzpicture} \end{document} See: James D FOLEY et al "Computer Graphics, Principals and Practice" 2nd edition ISBN 0-204-84840-6 Page 593. Figure 13.34 "Algorithm for converting from HSV to RGB color space" (This is C. I had to convert it to Postscript. Mostly lots of nasty stack manipulation) Till Tantau wrote: > Hi! > > > pgf does support the following shading types of the pgf standard: > > - axis shadings > - radial shadings > - functional shadings > > The last type of shading can, indeed, be used to let the renderer > produce the color circle. However, someone would have to sit down and > write and test the necessary shading specification (would take half an > hour, I presume). If someone has it, please post it, we can put it in > a lib, other people might like this. > > > Best regards, > Till > > > > Am 24.10.2008 um 10:12 schrieb Ken Starks: > >> This is very nice, I agree. >> >> But I was wondering, could you achieve something similar using a >> shading >> dictionary ? Yes, if you accept a linear or radial shading, I am >> sure. Does >> Pgf/Tikz allow other kinds of shading, as allowed by the PDF standard >> ? It >> would be nice to make the PDF engine do all the work, and it would >> certainly >> make for a smaller file size ? >> >> > > -- > Prof. Dr. Till Tantau <tantau@...> > http://www.tcs.uni-luebeck.de > > > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color modelSorry,
Copy and Paste made it not work. It seems the code got mucked up somewhere in the email software. I expect the long lines were chopped or something. Here is hoping it will work as an attached file. I've just sent it to myself as a private email, and it seemed OK. Can someone reply to tell me if it worked for them ? Ken Starks wrote: > Hello, > > Here is a version of a HSV ring in which I have used a functional shading. > > The main guts of the thing contains code to turn three HSV values on > the stack into three RGB values, which I hope will be useful elsewhere. > > I have tried to put in quite a bit of documentation, in terms of stack > listings on nearly every line. > > Bye for now, > > Ken. > > > Till Tantau wrote: > >> Hi! >> >> >> pgf does support the following shading types of the pgf standard: >> >> - axis shadings >> - radial shadings >> - functional shadings >> >> The last type of shading can, indeed, be used to let the renderer >> produce the color circle. However, someone would have to sit down and >> write and test the necessary shading specification (would take half an >> hour, I presume). If someone has it, please post it, we can put it in >> a lib, other people might like this. >> >> >> Best regards, >> Till >> >> >> >> Am 24.10.2008 um 10:12 schrieb Ken Starks: >> >> >>> This is very nice, I agree. >>> >>> But I was wondering, could you achieve something similar using a >>> shading >>> dictionary ? Yes, if you accept a linear or radial shading, I am >>> sure. Does >>> Pgf/Tikz allow other kinds of shading, as allowed by the PDF standard >>> ? It >>> would be nice to make the PDF engine do all the work, and it would >>> certainly >>> make for a smaller file size ? >>> >>> >>> > <snip> > >> -- >> Prof. Dr. Till Tantau <tantau@...> >> http://www.tcs.uni-luebeck.de >> >> >> >> > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > pgf-users mailing list > pgf-users@... > https://lists.sourceforge.net/lists/listinfo/pgf-users > > > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color modelLe 26 oct. 08 à 14:04, Ken Starks a écrit : > Sorry, > > Copy and Paste made it not work. > It seems the code got mucked up somewhere in the email software. I > expect the long lines were chopped or something. > > Here is hoping it will work as an attached file. I've just sent it to > myself as a private email, and it seemed OK. > > Can someone reply to tell me if it worked for them ? Hi, It's fine if I modify the lines that begin with \pgfpathmoveto { ...etc ...} with \pgfpathmoveto{..} after it's correct ! Best Regards Alain ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color modelThanks Alain,
It seems that the problem is indeed line-lengths. Here is a copy that should work without editing ( I hope) %%%%%%%%%%%% \documentclass{article} \usepackage[rgb]{xcolor} \usepackage{colortbl} \usepackage{tikz} \usetikzlibrary{calc} \newcommand{\pgp}{\pgfpoint} \begin{document} \pgfdeclarefunctionalshading{HSVsweep} {\pgp{-2cm}{-2cm}} {\pgp{2cm}{2cm}} {} { % x y 2 copy % ... x y x y 2 copy 0 eq exch 0 eq and { pop pop 0.0 } % silently deal with error: return % arbitrary heading of zero for origin {atan 360.0 div} % ... x y heading; heading being in %the interval [0, 1.0] ifelse % because we will use it for 'Hue' dup 360 eq { pop 0.0 }{} ifelse % if heading is 360 %degrees, make it zero instead 3 1 roll % ... heading x y dup mul % ... heading x y*y exch dup mul % ... heading y*y x*x add sqrt % ... heading ra_pt (distance from origin in points) 56 div % scale it means a ra of just under 2 cm dup 1.0 ge % BOOLEAN. ready to clamp to interval [0, 1.0] { pop 1.0 }{} ifelse % We shall use the scaled ra as 'Saturation' 2.5 mul 0.25 sub % now, Ra in [0.1, 0.5] --> Saturation % in [0.0, 1.0]. Saturation varies between the two radii 1.0 % ... H S V ( with 'Value' set to literal constant of 1.0 ) false % TEST I [ S == 1.0 ] { % BLOCK A [ take stack to V V V ] achromatic case } { % BLOCK B take stack to V T Q P i % C version to use as model: % H' = H * 6 % i = floor(H') % f = H' - i % P = V * (1.0 - S) % Q = V * (1.0 - (S*f)) % T = V * (1.0 - (S * (1.0 - f))) 3 -1 roll 6.0 mul dup 4 1 roll % H' S V H' floor % H' S V i dup 5 1 roll % i H' S V i 3 index sub neg % i H' S V f 1.0 3 index sub % i H' S V f (1.0 - S ) 2 index mul % i H' S V f P 6 1 roll % P i H' S V f dup 3 index mul neg 1.0 add % P i H' S V f ( 1.0 - (f*S)) 2 index mul % P i H' S V f Q 7 1 roll % Q P i H' S V f neg 1.0 add % Q P i H' S V (1.0 - f) 2 index mul neg 1.0 add % Q P i H' S V (1.0 - S * (1.0 - f)) 1 index mul % Q P i H' S V T 7 2 roll % V T Q P i H' S pop pop % V T Q P i %%% % end of BLOCK B. The rest is just stack manipulation dup 0 eq % TEST II [ i == 0 ] { % BLOCK C [ take stack to V T P ] pop exch pop } { dup 1 eq % TEST III [ i == 1 ] { % BLOCK D [ take stack to Q V P ] pop exch 4 1 roll exch pop } { dup 2 eq % TEST IV [ i == 2 ] { % BLOCK E [ take stack to P V T ] pop 4 1 roll pop } { dup 3 eq % TEST V [ i == 3 ] { % BLOCK F [ take stack to P Q V ] pop exch 4 2 roll pop } { dup 4 eq % TEST VI [ i == 4 ] { % BLOCK G [ take stack to T P V ] pop exch pop 3 -1 roll } { % BLOCK H [ take stack to V P Q ] pop 3 1 roll exch pop } ifelse } ifelse % for V } ifelse % for IV } ifelse % for III } ifelse % for II % BLOCK I } ifelse % for I % BLOCK J % .. RGB at last } % \pgfuseshading{HSVsweep} \begin{tikzpicture} % The shape is the region between two circles, centered % at the origin % Drawn in opposite directions to allow a non-zero % fill to work. \def\ra{3.8cm} \def\raB{1.5cm} \def\cv{0.55228475*\ra} \def\cvB{0.55228475*\raB} \pgfpathmoveto{\pgp{\ra}{0cm}}; \pgfpathcurveto {\pgp{\ra}{\cv}}{\pgp{\cv}{\ra}}{\pgp{0cm}{\ra}}; \pgfpathcurveto {\pgp{-\cv}{\ra}}{\pgp{-\ra}{\cv}}{\pgp{-\ra}{0cm}}; \pgfpathcurveto {\pgp{-\ra}{-\cv}}{\pgp{-\cv}{-\ra}}{\pgp{0cm}{-\ra}}; \pgfpathcurveto {\pgp{\cv}{-\ra}}{\pgp{\ra}{-\cv}}{\pgp{\ra}{0cm}}; \pgfpathmoveto{\pgp{\raB}{0cm}}; \pgfpathcurveto {\pgp{\raB}{-\cvB}}{\pgp{\cvB}{-\raB}}{\pgp{0cm}{-\raB}}; \pgfpathcurveto {\pgp{-\cvB}{-\raB}}{\pgp{-\raB}{-\cvB}}{\pgp{-\raB}{0cm}}; \pgfpathcurveto {\pgp{-\raB}{\cvB}}{\pgp{-\cvB}{\raB}}{\pgp{0cm}{\raB}}; \pgfpathcurveto {\pgp{\cvB}{\raB}}{\pgp{\raB}{\cvB}}{\pgp{\raB}{0cm}}; \pgfclosepath; \pgfshadepath{HSVsweep}{0} \pgfusepath{stroke} \foreach \x in {0, 30, ..., 330} \draw (-\x+90:3.8) -- (-\x+90:4.0) (-\x+90:4.4) node {$\x^\circ$}; \end{tikzpicture} \end{document} See: James D FOLEY et al "Computer Graphics, Principals and Practice" 2nd edition ISBN 0-204-84840-6 Page 593. Figure 13.34 "Algorithm for converting from HSV to RGB color space" (This is C. I had to convert it to Postscript. Mostly lots of nasty stack manipulation) %%%%%%%%%%%% Alain Matthes wrote: > > Le 26 oct. 08 à 14:04, Ken Starks a écrit : > >> Sorry, >> >> Copy and Paste made it not work. >> It seems the code got mucked up somewhere in the email software. I >> expect the long lines were chopped or something. >> >> Here is hoping it will work as an attached file. I've just sent it to >> myself as a private email, and it seemed OK. >> >> Can someone reply to tell me if it worked for them ? > > > Hi, > > It's fine if I modify the lines that begin with > > \pgfpathmoveto > > { ...etc ...} > > with \pgfpathmoveto{..} after it's correct ! > > Best Regards > > Alain > > > > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color modelOn Sun, Oct 26, 2008 at 3:35 PM, Ken Starks <ken@...> wrote:
> Here is a copy that should work without editing ( I hope) I'd like to add that Apples PDF viewer bugs on this shading, apparently because of the fact the numbers are not real values (thankfully the manual knew this). :) It's of course Apples fault, but it can be worked around, as the manual suggests too, by adding: % .. RGB at last cvr 3 1 roll cvr 3 1 roll cvr 3 1 roll At the end. Berteun ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: The hsb color modelBerteun Damman wrote:
> On Sun, Oct 26, 2008 at 3:35 PM, Ken Starks <ken@...> wrote: > >> Here is a copy that should work without editing ( I hope) >> > > I'd like to add that Apples PDF viewer bugs on this shading, > apparently because of the fact the numbers are not real values > (thankfully the manual knew this). :) It's of course Apples fault, but > it can be worked around, as the manual suggests too, by adding: > > % .. RGB at last > cvr 3 1 roll cvr 3 1 roll cvr 3 1 roll > > At the end. > > Berteun > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > pgf-users mailing list > pgf-users@... > https://lists.sourceforge.net/lists/listinfo/pgf-users > > > I was aware of this bug, but thought (mistakedly, it seems) that my final values were already real. That's why I kept putting 1.0 instead of 1 in so many places. Oh well, you live and learn. Thanks again and Goodbye, Ken ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
| Free embeddable forum powered by Nabble | Forum Help |