Flex 4 色轮组件的圆形路径渐变描边
我正在尝试在 Flex 4 中创建一个色轮组件,它允许我表示 RGB 和 HSL 数据。我这样做是用一个圆形色轮代表我可以使用的各种色调,并在其中心使用一个矩形渐变来代表亮度和饱和度场
目前我已经代表了对象,但我无法确定填充它们的最佳方式在中心正方形中创建所需的渐变没有问题,但我无法让外环构建圆形渐变。看起来 flex 中唯一的两个原生渐变是线性渐变和径向渐变,但我需要渐变线性地遵循椭圆周围的路径。我怎样才能使这成为可能?
这是我迄今为止所做的尝试:
<s:Group>
<s:Ellipse x="7" y="7" width="136" height="136">
<s:stroke>
<s:LinearGradientStroke weight="14">
<s:GradientEntry ratio="0" color="0xFF0000"/>
<s:GradientEntry ratio="0.1647" color="0xFFFF00"/>
<s:GradientEntry ratio="0.3294" color="0x00FF00"/>
<s:GradientEntry ratio="0.4941" color="0x00FFFF"/>
<s:GradientEntry ratio="0.6588" color="0x0000FF"/>
<s:GradientEntry ratio="0.3529" color="0xFF00FF"/>
<s:GradientEntry ratio="1" color="0xFF0000"/>
</s:LinearGradientStroke>
</s:stroke>
</s:Ellipse>
<s:Rect x="32" y="32" width="86" height="86">
<s:fill>
<s:SolidColor/>
</s:fill>
</s:Rect>
</s:Group>
颜色及其比例正确地定位了我从左到右所需的渐变,但最终结果如下:
http://imageshack.us/photo/my-images/10/flexo.png/
我希望图像像这样出现这个:(截图来自 Paint Shop Pro 8)
http://imageshack.us/photo/my -images/687/psph.png/
(抱歉链接,但我还没有 10 个代表,所以我无法直接在帖子中发布图像)
(不,我还没有构建矩形渐变然而,因为它的颜色是基于外环的......我还不担心矩形)
I'm attempting to create a color wheel component in Flex 4 that will allow me to represent RGB and HSL data. I'm doing so with a circular color wheel representing the various hues available to me and a rectangular gradient in the center of that which will represent the lightness and saturation fields
Currently I have the objects represented but I cannot determine the best way to fill them in. I have no problem creating the gradient necessary in the center square, but I cannot get the outer ring to build a -circular- gradient. It seems the only two native gradients in flex are linear and radial, but I need the gradient to linearly follow the path around the ellipse. How would I make this possible?
Here's the attempt I've made thus far:
<s:Group>
<s:Ellipse x="7" y="7" width="136" height="136">
<s:stroke>
<s:LinearGradientStroke weight="14">
<s:GradientEntry ratio="0" color="0xFF0000"/>
<s:GradientEntry ratio="0.1647" color="0xFFFF00"/>
<s:GradientEntry ratio="0.3294" color="0x00FF00"/>
<s:GradientEntry ratio="0.4941" color="0x00FFFF"/>
<s:GradientEntry ratio="0.6588" color="0x0000FF"/>
<s:GradientEntry ratio="0.3529" color="0xFF00FF"/>
<s:GradientEntry ratio="1" color="0xFF0000"/>
</s:LinearGradientStroke>
</s:stroke>
</s:Ellipse>
<s:Rect x="32" y="32" width="86" height="86">
<s:fill>
<s:SolidColor/>
</s:fill>
</s:Rect>
</s:Group>
The colors and their ratios properly position the gradient I need from left to right but the end result comes up as such:
http://imageshack.us/photo/my-images/10/flexo.png/
I would like the image to come up like this: (screenshot from paint shop pro 8)
http://imageshack.us/photo/my-images/687/psph.png/
(sorry for the links, but I don't have 10 rep yet so I can't post the images straight in the post)
(no, I haven't built the rectangle gradient yet, as it's colors are based off of the outer ring...I'm not worried about the rectangle just yet)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于弄清楚了
首先,我利用了本教程中提到的 BoostWorthy.com 的 Ryan Taylor 的代码:
http://www.boostworthy.com/blog/?p=200
麻烦在本教程中,颜色范围没有获得我的色调色轮可用的所有可能的色调,因为他使用正弦波来计算角度颜色。如果您查看有关色调的维基百科文章,您会发现色谱不是正弦波,而是红绿和蓝色的简单混合。下面的图表直观地解释了我所说的内容:
http:// /en.wikipedia.org/wiki/File:HSV-RGB-comparison.svg
如果您使用正弦波,则波仅每 60 度一次达到最大值......当颜色值的斜率需要在每 60 度期间保持恒定(即在一个时期内,每种颜色在该时期内的最大值为 255,最小值为 0)。
这是在教程的帖子中提出的,作为他的问题代码,但没有人发布其解决方案...这是实际的解决方案:
I got it figured out finally
First, I utilized the code from Ryan Taylor of BoostWorthy.com that was brought up in this tutorial:
http://www.boostworthy.com/blog/?p=200
The trouble with this tutorial is that the color ranges do not get all of the possible hues available for my hue color wheel since he is using sine waves to calculate the angular color. If you review the wikipedia article for Hue you can see that the color spectrum is not a sine wave but rather a simple blend of red green and blue. Here is the graph that visually explains what I'm talking about:
http://en.wikipedia.org/wiki/File:HSV-RGB-comparison.svg
If you use sine waves instead the waves only peak at their maximum value once every 60 degrees...when the color value's slope needs to be constant during every 60 degrees (i.e. during one period each color will have a maximum value of 255 or a minimum value of 0 for the duration of that period)
This was brought up in the tutorial's posts as an issue with his code, but no one posted the resolution for it...Here's the actual resolution: