How to make correct shading with hsb color model?

I want to use hsb color model to shading.

First rectangle shows a shading using rgb color model.

Second rectangle shows a shading using hsb color model. But I don't understand why I don't obtain the same shading that with my third rectangle.

\documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}   % create some hsb colors   \colorlet{redhsb}[hsb]{red}%   \colorlet{bluehsb}[hsb]{blue}%   \colorlet{greenhsb}[hsb]{green}%    % first shading with rgb color model   \fill[left color=red,right color=blue] (0,1) rectangle (2,0);    % second shading with hsb color model   \fill[left color=redhsb,right color=bluehsb] (0,0) rectangle (2,-1);    % third shading with hsb color model   \fill[left color=redhsb,right color=greenhsb] (0,-1) rectangle (1,-2);   \fill[left color=greenhsb,right color=bluehsb] (1,-1) rectangle (2,-2); \end{tikzpicture} \end{document} 

How to make correct shading with hsb color model?

Edit: In fact, TikZ calculates the middle color (using color model of the left color). Then, it converts all three colors to rgb model and make shading...

I add a fourth rectangle:

% fourth shading with rgb color model \fill[left color=red,right color=green] (0,-2) rectangle ++(1,-1); \fill[left color=green,right color=blue] (1,-2) rectangle ++(1,-1); 

How to make correct shading with hsb color model?

So, my question is: Can TikZ do real hsb (HSV) shading?

Replay

The following happens when you do \fill[left color=redhsb,right color=bluehsb] (0,0) rectangle (2,-1);

As you see above, the color space is set to DeviceRGB. Indeed I think that PDF doesn't support HSL (though I haven't checked to PDF documentation).

As far as I understand, the only way to get HSL interpolation is to write a PostScript shader that does the interpolation and then converts the result to RGB.

Category: tikz pgf Time: 2012-06-09 Views: 4
Tags: color tikz pgf

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.135 (s). 12 q(s)