WPF 中的图案画笔

发布于 2024-10-10 00:33:10 字数 296 浏览 0 评论 0 原文

我正在努力创建各种画笔来填充各种形状或作为背景。以下是我正在努力创建的一些模式:

  1. <<<<>>>>
  2. <|<|<|<|>|>|>|>
  3. ////////
  4. \\\\
  5. ||||||||

我已经能够创建 \\\、////// 和 ||||||具有线性渐变,但前两个给我带来了问题。顺便说一句,第二个是三角形。

任何建议或帮助将不胜感激。

I am struggling with creating various brushes to fill in various shapes or as a background. Here are some patterns I am struggling with creating:

  1. <<<<>>>>
  2. <|<|<|<|>|>|>|>
  3. ////////
  4. \\\\
  5. ||||||||

I've been able to create the \\\, //////, and |||||| with a linear gradient, but the first two are causing me issues. BTW, the second one is a triangle.

Any suggestions or help would be greatly appreciated.

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

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

发布评论

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

评论(2

我不是你的备胎 2024-10-17 00:33:10

您需要使用 TileBrush。使用 Drawing 或图像定义一个图块的图案,并使用 DrawingBrushImageBrush 重复它。关于这个主题的文档非常广泛,这些示例应该可以给您一些想法

You need to use a TileBrush. Define the pattern of one tile with a Drawing or an image, and repeat it with a DrawingBrush or ImageBrush. The documentation is quite extensive on this subject, the examples should give you some ideas

凡尘雨 2024-10-17 00:33:10

您可以使用绘图画笔创建复合渐变。例如,下面是一个菱形渐变,您可以将其粘贴到窗口中进行测试:

<Window.Background>
    <DrawingBrush>
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup.Children>
                    <GeometryDrawing>
                        <GeometryDrawing.Geometry>
                            <RectangleGeometry Rect="0,0,100,100"/>
                        </GeometryDrawing.Geometry>
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                                <GradientStop Offset="0.0" Color="Black" />
                                <GradientStop Offset="1.0" Color="White" />
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                    <GeometryDrawing>
                        <GeometryDrawing.Geometry>
                            <RectangleGeometry Rect="100,0,100,100"/>
                        </GeometryDrawing.Geometry>
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="1,0" EndPoint="0,1">
                                <GradientStop Offset="0.0" Color="Black" />
                                <GradientStop Offset="1.0" Color="White" />
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                    <GeometryDrawing>
                        <GeometryDrawing.Geometry>
                            <RectangleGeometry Rect="0,100,100,100"/>
                        </GeometryDrawing.Geometry>
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="0,1" EndPoint="1,0">
                                <GradientStop Offset="0.0" Color="Black" />
                                <GradientStop Offset="1.0" Color="White" />
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                    <GeometryDrawing>
                        <GeometryDrawing.Geometry>
                            <RectangleGeometry Rect="100,100,100,100"/>
                        </GeometryDrawing.Geometry>
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="1,1" EndPoint="0,0">
                                <GradientStop Offset="0.0" Color="Black" />
                                <GradientStop Offset="1.0" Color="White" />
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                </DrawingGroup.Children>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>
</Window.Background>

ASCII 图形的表现力不够,但也许这就是您的意思

You can create composite gradients using a drawing brush. For example, here is a diamond gradient that you can paste into a window for testing:

<Window.Background>
    <DrawingBrush>
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup.Children>
                    <GeometryDrawing>
                        <GeometryDrawing.Geometry>
                            <RectangleGeometry Rect="0,0,100,100"/>
                        </GeometryDrawing.Geometry>
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                                <GradientStop Offset="0.0" Color="Black" />
                                <GradientStop Offset="1.0" Color="White" />
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                    <GeometryDrawing>
                        <GeometryDrawing.Geometry>
                            <RectangleGeometry Rect="100,0,100,100"/>
                        </GeometryDrawing.Geometry>
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="1,0" EndPoint="0,1">
                                <GradientStop Offset="0.0" Color="Black" />
                                <GradientStop Offset="1.0" Color="White" />
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                    <GeometryDrawing>
                        <GeometryDrawing.Geometry>
                            <RectangleGeometry Rect="0,100,100,100"/>
                        </GeometryDrawing.Geometry>
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="0,1" EndPoint="1,0">
                                <GradientStop Offset="0.0" Color="Black" />
                                <GradientStop Offset="1.0" Color="White" />
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                    <GeometryDrawing>
                        <GeometryDrawing.Geometry>
                            <RectangleGeometry Rect="100,100,100,100"/>
                        </GeometryDrawing.Geometry>
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="1,1" EndPoint="0,0">
                                <GradientStop Offset="0.0" Color="Black" />
                                <GradientStop Offset="1.0" Color="White" />
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                </DrawingGroup.Children>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>
</Window.Background>

ASCII graphics aren't expressive enough but maybe this is what you meant by <<<>>>:

alt text

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