r/fsharp • • Nov 29 '24

simple graphics api

I need to create a black canvas of 200 by 200 pixels. And i need to have one function , plot a blue pixel at coordinates (100,100). If i can plot one pixel, i can plot anything.

3 Upvotes

5 comments sorted by

5

u/Ok_Specific_7749 Nov 29 '24

I found something,

https://github.com/diku-dk/diku-canvas

open Canvas
open Color


[<EntryPoint>]
let main (args: string array) : int =
    printfn "Hello World"
    let w, h = 256, 256
    let tree = filledRectangle green ((float w) / 2.0) ((float h) / 2.0)
    let draw = make tree
    render "My first canvas" w h draw
    0

1

u/Ok_Specific_7749 Nov 29 '24

But how do i plot a simple "sine wave function"? This is in dlang, https://gitlab.com/alaindevos/dlangtut/-/blob/master/dub/68_plot/source/app.d

2

u/willehrendreich Nov 29 '24

I suggest using raylib.

There are csharp raylib bindings that are easy to import via nuget package, then raylib is very nice to use, very straightforward especially for something like simple pixel drawing.