Dmitry Avtonomov
Dmitry Avtonomov

Reputation: 9519

perl: tk: a way/widget that allows pixel level control over the output

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.

Upvotes: 0

Views: 526

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137717

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.

Upvotes: 1

Related Questions