[cairo] Draw a single pixel or group of pixels

Gerdus van Zyl gerdusvanzyl at gmail.com
Thu Apr 10 13:40:27 PDT 2008


Sorry for mudling the issue. After looking at my code again the reason I
used 1.5 width and height is because x,y can be non-integer to enable smooth
sub-pixel animation. The 1.5 enables a full pixel to be visible at all
times, otherwise pixels seem to flicker as they move.

~Gerdus

On Thu, Apr 10, 2008 at 7:20 PM, Carl Worth <cworth at cworth.org> wrote:

> On Thu, 10 Apr 2008 18:13:23 +0200, "Gerdus van Zyl" wrote:
> > I use the following:
> > ctx.rectangle(p.x,p.y,1.5,1.5)
> > ctx.fill()
> >
> > the reason for the 0.5 larger is the little squares,sample point model
> > described in "How do I draw a sharp, single-pixel-wide line?" in
> > http://www.cairographics.org/FAQ/#sharp_lines
>
> Hi Gerdus,
>
> I think I really need to clarify that FAQ answer somehow. The correct
> code for drawing a single pixel, (assuming the default identity
> transformation matrix), is:
>
>        cairo_rectangle (cr, x, y, 1.0, 1.0);
>        cairo_fill (cr);
>
> with both x and y as integers.
>
> Please let me know what text on that page might have caused the
> misunderstanding so that I can fix it.
>
> Thanks,
>
> -Carl
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20080410/d3dc0f61/attachment.html 


More information about the cairo mailing list