flex绘制对象的不同渐变颜色

发布于 2024-12-10 11:33:26 字数 499 浏览 0 评论 0原文

我想要一个在 Flex 中具有三种不同颜色的矩形。我使用了 fill 和gradiententry 等 Spark 组件,但无法像这样并排获得三种颜色。

黑-红-黑的比例为0.2 0.8 0.2。我只能得到两种颜色,但不能得到这个比例。另外我想要矩形上的纯色而不是渐变。

<s:Rect id="rectangle1" height="100" width="300">
    <s:fill>
        <s:LinearGradient>
            <s:GradientEntry color="black" ratio="0.5"    alpha="1"/>
            <s:GradientEntry color="red"  ratio="0.5" alpha="1"/>
    </s:LinearGradient> 
    </s:fill>
</s:Rect>

I want to have a rectangle which has three different colors in flex. I used spark components like fill and gradiententry, but could not get three colors side by side like this.

black-red-black of ratio 0.2 0.8 0.2. I could get only two colors working but not this ratio. Also i want solid colors on rectangle and not gradient.

<s:Rect id="rectangle1" height="100" width="300">
    <s:fill>
        <s:LinearGradient>
            <s:GradientEntry color="black" ratio="0.5"    alpha="1"/>
            <s:GradientEntry color="red"  ratio="0.5" alpha="1"/>
    </s:LinearGradient> 
    </s:fill>
</s:Rect>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巷子口的你 2024-12-17 11:33:26

你不是说你想要3个矩形吗?您想要渐变,但随后声明您想要纯色(无渐变)。

你的意思是这样吗?

3 矩形

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               minWidth="955"
               minHeight="600">

    <s:Rect id="rectangle1"
            height="15"
            width="300">
        <s:fill>
            <s:SolidColor color="0x0" />
        </s:fill>
    </s:Rect>

    <s:Rect id="rectangle2"
            top="15"
            height="70"
            width="300">
        <s:fill>
            <s:SolidColor color="0xff0000" />
        </s:fill>
    </s:Rect>

    <s:Rect id="rectangle3"
            top="85"
            height="15"
            width="300">
        <s:fill>
            <s:SolidColor color="0x0" />
        </s:fill>
    </s:Rect>

</s:Application>

否则,您可以像这样实现您的目标:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               minWidth="955"
               minHeight="600">

    <s:Rect id="rectangle1"
            height="100"
            width="300">
        <s:fill>
            <s:LinearGradient rotation="90">
                <s:GradientEntry color="0x0" ratio="0" />
                <s:GradientEntry color="0x0" ratio=".2" />
                <s:GradientEntry color="0xff0000" ratio=".2" />
                <s:GradientEntry color="0xff0000" ratio=".8" />
                <s:GradientEntry color="0x0" ratio=".8" />
            </s:LinearGradient>
        </s:fill>
    </s:Rect>

</s:Application>

Aren't you saying you want 3-rectangles? You want a gradient, but then you state you want solid colors (no gradient).

You mean like this?

3 Rectangles

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               minWidth="955"
               minHeight="600">

    <s:Rect id="rectangle1"
            height="15"
            width="300">
        <s:fill>
            <s:SolidColor color="0x0" />
        </s:fill>
    </s:Rect>

    <s:Rect id="rectangle2"
            top="15"
            height="70"
            width="300">
        <s:fill>
            <s:SolidColor color="0xff0000" />
        </s:fill>
    </s:Rect>

    <s:Rect id="rectangle3"
            top="85"
            height="15"
            width="300">
        <s:fill>
            <s:SolidColor color="0x0" />
        </s:fill>
    </s:Rect>

</s:Application>

Otherwise, you can kind of accomplish your goal like this:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               minWidth="955"
               minHeight="600">

    <s:Rect id="rectangle1"
            height="100"
            width="300">
        <s:fill>
            <s:LinearGradient rotation="90">
                <s:GradientEntry color="0x0" ratio="0" />
                <s:GradientEntry color="0x0" ratio=".2" />
                <s:GradientEntry color="0xff0000" ratio=".2" />
                <s:GradientEntry color="0xff0000" ratio=".8" />
                <s:GradientEntry color="0x0" ratio=".8" />
            </s:LinearGradient>
        </s:fill>
    </s:Rect>

</s:Application>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文