Thread overview
Plot one pixel in blue on a canvas
Nov 29
Sergey
5 days ago
Aravinda VK
5 days ago
Aravinda VK
November 29

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/

November 29

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)

Check this lib from p0nce maybe https://code.dlang.org/packages/canvasity.
So steps should be like:

dub init
dub add canvasity

Couple of demos are presented in the description.

November 29

On Friday, 29 November 2024 at 15:01:12 UTC, Sergey wrote:

>

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)

Check this lib from p0nce maybe https://code.dlang.org/packages/canvasity.
So steps should be like:

dub init
dub add canvasity

Couple of demos are presented in the description.

Can i how the image on screen while i draw ?

5 days ago

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,

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.

/+ 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.

5 days ago

On Sunday, 1 December 2024 at 16:40:56 UTC, Aravinda VK wrote:

>

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,

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.

/+ 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.

Missed adding color in the above example (Also added the alternate syntax using with statement).

import chitra;

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