On Sunday, 20 December 2015 at 11:16:06 UTC, TheDGuy wrote:
On Sunday, 20 December 2015 at 01:17:50 UTC, Basile B. wrote:
On Saturday, 19 December 2015 at 14:16:23 UTC, TheDGuy wrote:
is it possible to set the color of a single pixel with Cairo?

Not like you would do with a classic canvas (2d grid), because colors are applied with `cairo_fill()` and `cairo_stroke()` on a particular path.

but you can define a path that represents a single pixel and fill it:

```
cairo_rectangle (cr, x, y, 1, 1); // 1 pix rectangle
cairo_set_source_rgba (cr, 0, 0, 0, 1); // color
cairo_fill (cr); // fill the rectangle with source rgba

```

However cairo is node made to be used like this. The workflow is usually more based on stacked layers (1 layer = 1 path) with different filling, different transparency.

Thanks for your answer,

but a bit disappointing that cairo doesn't offer a real "setPixel" function :(

Vectorial graphics are like that, they are at a higher level than, for, example, open GL. My experience with such libraries is a bit dusty (for example I made this when I was younger: http://4.bp.blogspot.com/-cmzQAHlaE50/TxcG3vEAA9I/AAAAAAAAQS0/qFxVLeo1JGU/s1600/GrainPlot%2Bv.2.4.jpg, here it plots some variable shape segments defined by x³-ax²+ax) but I clearly remember that you **never** need to draw a single pixel. A point is either part of the fill or of the border, I mean **always**.

However not that internaly cairo uses "pixman" but IDK if you can access it directly.
(see http://www.pixman.org/)

Reply via email to