Plot one pixel in blue on a canvas

Aravinda VK mail at aravindavk.in
Sun Dec 1 16:40:56 UTC 2024


On Friday, 29 November 2024 at 14:02:38 UTC, Alain De Vos wrote:
> I want to plot a pixel in blue at coordinates (100,100) on a 
> canvas of size (200,200)
> I think i can use the arsd module.
> But i have no idea what "dub add" comment I should use.
> What i should import
> How this demo program would look.
> Cfr,
> https://www.reddit.com/r/scala/comments/1h2g8a2/simple_graphics_api/
> https://www.reddit.com/r/fsharp/comments/1h2g7pv/simple_graphics_api/

You can use Chitra library. It is still under active development, 
working on adding support for text and curves. Refer this 
documentation to install the dependencies and add Chitra to your 
project. Chitra is based on Cairo Graphics for 2D graphics and 
PangoCairo for rendering texts.

https://github.com/aravindavk/chitra-d

Example for your use case,

```d
import chitra;

void main()
{
     auto ctx = new Chitra(200, 200);
     ctx.pixel(100, 100);
     ctx.saveAs("dot.png");
}
```

Or just run the file without installing it, like below.

Create a file `dot.d` with the following content.

```d
/+ dub.sdl:
  dependency "chitra" version="~>0.1.0"
+/

import chitra;

void main()
{
     auto ctx = new Chitra(200, 200);
     ctx.pixel(100, 100);
     ctx.saveAs("dot.png");
}
```

And run as `dub dot.d`

Let me know if this works for you. Thanks.


More information about the Digitalmars-d-learn mailing list