我已经做了一个梯度,我很喜欢在表达式混合,我正在努力解决,如果我可以使梯度曲线在一个角落,给我一个圆形的边界效果梯度。
问题是我不能使用正常的边界,因为梯度不一致。
我提出了以下建议,这将有助于证明我的想法:
rounded corner with gradient http://img232.imageshack.us/img232/9899/roundedcornerrg0.th.jpg

<Grid x:Name="grid" >
    <Border
        BorderThickness="0,0,40,40"
        CornerRadius="0,0,40,0"
        Padding="2" Height="60" VerticalAlignment="Bottom" Width="65" HorizontalAlignment="Right" >
        <Border.BorderBrush>
            <RadialGradientBrush>
                <RadialGradientBrush.RelativeTransform>
                    <TransformGroup>
                        <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2.058" ScaleY="2.177"/>
                        <SkewTransform AngleX="0" AngleY="0" CenterX="0.5" CenterY="0.5"/>
                        <RotateTransform Angle="-119.481" CenterX="0.5" CenterY="0.5"/>
                        <TranslateTransform X="0.209" Y="0.52"/>
                    </TransformGroup>
                </RadialGradientBrush.RelativeTransform>
                <GradientStop Color="#FF000000" Offset="0"/>
                <GradientStop Color="#000A0A0A" Offset="1"/>
                <GradientStop Color="#6B050505" Offset="0.829"/>
                <GradientStop Color="#BB020202" Offset="0.763"/>
            </RadialGradientBrush>
        </Border.BorderBrush>
    </Border>
    <Rectangle VerticalAlignment="Stretch" Height="100" Width="40" HorizontalAlignment="Right" Margin="0,0,0,60" StrokeThickness="0" Panel.ZIndex="0">
        <Rectangle.Fill>
            <LinearGradientBrush EndPoint="-0.025,0.5" StartPoint="1,0.5">
                <GradientStop Color="#FF000000" Offset="0"/>
                <GradientStop Color="#000A0A0A" Offset="1"/>
                <GradientStop Color="#6B050505" Offset="0.829"/>
                <GradientStop Color="#BB020202" Offset="0.763"/>
            </LinearGradientBrush>
        </Rectangle.Fill>
    </Rectangle>
    <Rectangle VerticalAlignment="Bottom" Height="40" Width="100" HorizontalAlignment="Stretch" Margin="0,0,65,0">
        <Rectangle.Fill>
            <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                <GradientStop Color="#FF000000" Offset="0"/>
                <GradientStop Color="#000A0A0A" Offset="1"/>
                <GradientStop Color="#6B050505" Offset="0.829"/>
                <GradientStop Color="#BB020202" Offset="0.763"/>
            </LinearGradientBrush>
        </Rectangle.Fill>
    </Rectangle>
</Grid>

有没有办法像我想的那样在拐角处弯曲梯度?我在网上看到一个建议,把边界相互嵌套,但这对我也没有好处,因为梯度让生活变得困难。

最佳答案

你可能想看看Charles Petzolds article on Graphical Paths with Gradient Colors里面他讨论了一个和你类似的问题。

10-05 19:46