Set color to a single point in Cairo
Luis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Dec 22 04:17:36 PST 2015
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.
I did something similar here :
https://github.com/Zardoz89/DEDCPU-16/blob/master/src/lem1802_fontview.d#L287
I need to clean these code...
More information about the Digitalmars-d-learn
mailing list