Degrafa color switch

<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>

      

I have a problem with degrafa code where I have defined a set of different gradients for color_preset.fill to be dynamically changing when the user selects a different color in the combo box.

I replaced fill="{bluedream}"

with fill="using_variable"

and resulted in an error message: Initializer for 'fill': values โ€‹โ€‹of type com.degrafa.core.IGraphicsFill

cannot be represented in text.

Is there a solution to use this code as a color changer?

+1


source to share


1 answer


The fill property in your example points to a LinearGradientFill with the id "bluedream". You can replace the fill with a different gradient (or a solid or different fill), or change the colors of the gradient fill itself:

<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>

      



I haven't run this code, but it should work. The idea is to change the color of the GradientStop with the selectedItem dropdown (assuming it's a string). This example does something very similar, but with a color picker instead of a dropdown: http://degrafa.org/source/CS4IconPreviewer/CS4IconPreviewer.html

0


source







All Articles