apache-flex Degrafa换色器

gmol1639  于 2022-11-01  发布在  Apache
关注(0)|答案(1)|浏览(262)
<degrafa:LinearGradientFill id="bluedream">
    <degrafa:GradientStop color="#6ab5d0"/>
    <degrafa:GradientStop color="#388aae"/>
</degrafa:LinearGradientFill>

<degrafa:GeometryComposition graphicsTarget="{[bgCanvas]}">
    <degrafa:RoundedRectangle id="color_preset" fill="{bluedream}"/>
</degrafa:GeometryComposition>

我有问题的degrafa代码,我已经定义了一套不同的梯度为color_preset。填充是动态变化时,用户选择不同的颜色在组合框。
我用fill="using_variable"替换了fill="{bluedream}",导致编译错误消息:'fill'的初始设定式:com.degrafa.core.IGraphicsFill类型的值不能用文本表示。
是否有解决方案将此代码用作颜色更改器?

ef1yzkbh

ef1yzkbh1#

示例中的fill属性指向ID为“bluedream”的LinearGradientFill。您可以用其他渐变(或纯色或其他填充)替换该填充,也可以更改渐变填充本身的颜色:

<degrafa:LinearGradientFill id="bluedream">
    <degrafa:GradientStop color="{your_combobox.selectedItem}"/>
    <degrafa:GradientStop color="{your_other_combobox.selectedItem}"/>
</degrafa:LinearGradientFill>

<degrafa:GeometryComposition graphicsTarget="{[bgCanvas]}">
     <degrafa:RoundedRectangle id="color_preset" fill="{bluedream}"/>
</degrafa:GeometryComposition>

我还没有运行这段代码,但它应该可以工作。我们的想法是用下拉列表的selectedItem(假设它是一个字符串)来改变GradientStop的颜色。这个例子做了非常类似的事情,但是使用了一个颜色选择器而不是下拉列表:http://degrafa.org/source/CS4IconPreviewer/CS4IconPreviewer.html

相关问题