重新绘制时放大杂乱开罗纹理
我正在使用 python-clutter 1.0
我的问题以挑战的形式
编写代码以允许通过按一个键放大到 CairoTexture actor,分步进行,以便在每个 actor 上都可以重新绘制(由 cairo),以便图像保持高分辨率,但仍按预期缩放,无需重新调整演员的大小。
想想像 Inkscape 这样的东西以及如何放大矢量;矢量如何在任何放大倍数下保持干净。将一条路径(比如一堆 cairo line_to
命令)放到 CairoTexture actor 上,然后允许相同的技巧发生。
更多细节
我的目标是一个使用演员组的小型 SVG 编辑器。每个演员都致力于一条道路。我使用 SomeGroup.set_depth(z)
进行“缩放”,然后使 z 变大/变小。到目前为止一切都很好。然而,演员距离摄像机越近,纹理拉伸得越多,以适应他们新的外观尺寸。
我似乎无法找到一种方法让混乱同时做到这两点:
- 将演员的实际尺寸保持静态(即它开始时的样子)。
- 将其底层表面换成更大的表面(放大时),然后我可以重新-将路径绘制到(并使用开罗矩阵来执行上下文的缩放。)
如果我使用 set_size
或 set_surface_size
,演员会变得更大 这不是有意的。我只希望它的表面(底层数据)变得更大。
(我不确定这个术语,也许是 mipmapping?)
换句话说:多边形越来越大,增加其纹理数组的大小,以便它可以映射到更大的多边形。
我什至尝试通过保留第二个表面(使用 pycairo)将其重新创建为演员的表观尺寸(get_transformed_size
),然后使用 clutter 的 set_from_rgb_data 来绕过混乱。
并将其指向我的第二个表面,强制重新调整表面的大小,但不调整演员的尺寸。
这样做的问题是:a) 杂乱忽略了新的尺寸,只绘制到旧的宽度/高度;b) RGBA 与 ARGB32 的情况会导致颜色崩溃。
我对任何替代想法持开放态度,我希望我站在树林里错过所有的树木!
\d
I am using python-clutter 1.0
My question in the form of a challenge
Write code to allow zooming up to a CairoTexture actor, by pressing a key, in steps such that at each the actor can be re-drawn (by cairo) so that the image remains high-res but still scales as expected, without re-sizing the actor.
Think of something like Inkscape and how you can zoom into the vectors; how the vectors remain clean at any magnification. Put a path (bunch of cairo line_to
commands, say) onto an CairoTexture actor and then allow the same trick to happen.
More detail
I am aiming at a small SVG editor which uses groups of actors. Each actor is devoted to one path. I 'zoom' by using SomeGroup.set_depth(z)
and then make z bigger/smaller. All fine so far. However, the closer the actor(s) get to the camera, the more the texture is stretched to fit their new apparent size.
I can't seem to find a way to get Clutter to do both:
- Leave the actor's actual size static (i.e. what it started as.)
- Swap-out its underlying surface for larger ones (on zooming in) that I can then re-draw the path onto (and use a cairo matrix to perform the scaling of the context.)
If I use set_size
or set_surface_size
, the actor gets larger which is not intended. I only want it's surface (underlying data) to get larger.
(I'm not sure of the terminology for this, mipmapping perhaps? )
Put another way: a polygon is getting larger, increase the size of its texture array so that it can map onto the larger polygon.
I have even tried an end-run around clutter by keeping a second surface (using pycairo) that I re-create to the apparent size of the actor (get_transformed_size
) and then I use clutter's set_from_rgb_data
and point it at my second surface, forcing a re-size of the surface but not of the actor's dimensions.
The problem with this is that a)clutter ignores the new size and only draws into the old width/height and b)the RGBA vs ARGB32 thing kind of causes a colour meltdown.
I'm open to any alternative ideas, I hope I'm standing in the woods missing all the trees!
\d
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,尽管我进行了所有测试和修改,但它一直就在我眼皮子底下。
感谢 Neil 在杂乱项目列表中的贡献,以下是独家新闻:
很高兴把这个小谜团搁置一旁。谢谢杂乱清单!
\d
Well, despite all my tests and hacks, it was right under my nose all along.
Thanks to Neil on the clutter-project list, here's the scoop:
Nice to put this little mystery to bed. Thanks clutter list!
\d