perl:tk:一种允许对输出进行像素级控制的方法/小部件
我想要像画布这样的东西,但是除了可以在画布上绘制的所有提供的几何形状之外,我还可以轻松地操纵像素。
是否可以将 GD::Image 之类的东西嵌入到画布中?那么我也许可以使图像透明并在其中设置一些像素(GD::Image->setPixel())将其定位在画布上?
ps:好吧,这不一定是 perl,因为大多数脚本(而不仅仅是)语言的所有库似乎都有绑定。
I want something like a canvas, but where i'd be able to manipulate pixels easily in addition to all the provided geometries, that can be drawn on canvas.
Is it possible to embed something like GD::Image into a canvas? So then I maybe could make the image transparent and set some pixels in it (GD::Image->setPixel()) positioning it over the canvas?
ps: well, that doesn't necessarily have to be perl, as there seem to be bindings for all the libs for most scripting (and not only) languages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Tk 的画布并非旨在提供像素级控制,但您可以通过放入图像项并操作其中的像素来实现。我不确定 GD::Image,但我知道你可以使用支持透明度的 Tk 照片图像来做到这一点,并且默认情况下已经透明很长时间了。
使用图像进行此操作的另一个优点是,它们可以在项目列表中重新堆叠、隐藏、删除、添加回等等。这为您提供了很大的空间,如果您只是绘制原始图像,这些事情会有点尴尬。
Tk's canvas isn't designed to provide pixel-level control, but you can do it by putting an image item in and manipulating the pixels in that. I'm not sure about the GD::Image, but I know you can do this with the Tk photo image which supports transparency, and has been transparent by default for quite a long time now.
The other advantage of doing it with images is that they can be restacked within the list of items, hidden, removed, added back in, etc. This gives you a lot of scope for things which would be moderately awkward if you just drew raw.