1
<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 定义了一组不同的渐变,当用户在组合框中选择不同的颜色时动态变化。

我替换fill="{bluedream}"fill="using_variable"并导致错误编译消息:“填充”的初始化程序:类型的值com.degrafa.core.IGraphicsFill无法在文本中表示。

有没有办法将此代码用作换色器?

4

1 回答 1

0

您示例中的填充属性指向 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

于 2008-12-28T04:48:30.530 回答