您可以使用具有偏移量的 VisualBrush 进行渲染吗?
我有一个 64x64 图像,我将其用作 VisaulBrush 的源,并将其平铺在控件的背景上。但是,基于一些运行时逻辑,我想更改视觉画笔的起源。不是图块大小,而是“左上角”(如果您愿意的话)所在的位置。换句话说,不要将其视为图块本身的偏移,而是控件上图块开始位置的偏移。
然而,除了通过使用原始图像手动渲染为相同大小的第二个图像(使用从特定负偏移量开始的 2x2 图案(从而将该 2x2 裁剪为图块的大小))来伪造它之外,然后使用该图像作为实际瓷砖刷的来源,不知道我还能如何实现这一点。我很惊讶我没有看到任何类型的 TileOffset 或类似的东西。可能最终会推出我自己的画笔子类,它正是这样做的。
除非其他人知道更简单的方法来做到这一点......:)
I've got a 64x64 image that I'm using as the source of a VisaulBrush which I tile over the background of a control. However, based on some run-time logic, I want to change the origin of the visual brush. Not the tile size, just where the 'upper left' if you will is. In other words, think of it not as an offset into the tile itself, but rather an offset on where on the control the tiling begins.
However, asides from faking it by using the original image to manually render into a second image of the same size using a 2x2 pattern that starts at a specific negative offset (thus clipping that 2x2 to the size of the tile), then using that image as the source for the actual tile brush, not sure how else I can achieve this. I'm surprised I haven't just seen any sort of TileOffset or something similar. May end up rolling my own subclass of the brush that does exactly that.
Unless someone else knows an easier way to do this... :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以及此处所述 TileBrushs Viewport财产:
您可以轻松调整 ViewPort 的前两个参数以偏移图块。例如:
如果这是您的基础,并且您想在 x 方向上偏移 5px,那么您可以这样做:
因为
TileBrush
是ImageBrush
的基础,就像VisualBrush
一样code> 这同样适用于VisualBrush
。well as it states here TileBrushs Viewport Property:
you can easily adjust the first two parameters of the ViewPort to offset the tile. eg:
if that was your base and you want to offset this 5px in x direction you do:
As
TileBrush
is a base forImageBrush
just as forVisualBrush
this applies equally toVisualBrush
.