Re: How to draw a single pixel in a Canvas

From: Erick Gallesio <>
Date: Wed, 24 Feb 1999 19:06:23 +0100 (CET)

Hi Paolo,

> What's the simplest--and possibly most efficient--way of drawing a _single_
> pixel in a Canvas widget? The only one I can think of is to draw a 1 pixel
> wide rectangle item.

The simplest and not too efficient way to draw a single pixel is to
use a line of length 1 pixel. This is not too efficient because this
line has all the attributes of a full featured items (i.e. you can
add bindings or tags to it). However I have already used it for
plotting several hundreds of points, without too much problems
(excepts for prints which lead to huge ps files). I'm not sure that it
is realist to envision several thousands of points. How musch points do

In the Tk distrib there is (was ?) some code for making lines on a
widget. This code was in #ifdef which wer not active by default. If
you have a lot of points to draw, I could have a look to see if it is
a practicable solution.

Another probable solution consists to allocate an image and make draw
you points in it. I'm not sure that it is simple but if I remember
someone has already tried this solution (I don't remember if it produces

                -- Erick
Received on Wed Feb 24 1999 - 22:32:44 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST