diff options
author | emile <hanemile@protonmail.com> | 2018-10-08 16:07:16 +0200 |
---|---|---|
committer | emile <hanemile@protonmail.com> | 2018-10-08 16:07:16 +0200 |
commit | c22f1d74b7d555c5eaa1dfaf6c357e7853ca7946 (patch) | |
tree | 0b7763e34a8258a8121335bf4d35ef08e9ccd726 | |
parent | 52ad311fb481357dad9bfd1386630be10122b215 (diff) |
Drawing stuff, this is a PoC.
-rw-r--r-- | draw/draw.go | 34 | ||||
-rw-r--r-- | main.go | 9 |
2 files changed, 37 insertions, 6 deletions
diff --git a/draw/draw.go b/draw/draw.go new file mode 100644 index 0000000..9ee1bd7 --- /dev/null +++ b/draw/draw.go @@ -0,0 +1,34 @@ +package draw + +import ( + "../structs" + "github.com/fogleman/gg" +) + +// initializePlot generates a new plot and returns the plot context +func initializePlot() *gg.Context { + + // Define the image size + const image_width = 8192 + const image_height = 8192 + + // Initialize the new context + dc := gg.NewContext(image_width, image_height) + + // Set the background black + dc.SetRGB(0, 0, 0) + dc.Clear() + + // Set the coordinate midpoint to the middle of the image + dc.Translate(image_width/2, image_height/2) + + return dc +} + +func Slice(slice []structs.Star, path string) { + dc := initializePlot() + dc.SetRGB(1, 1, 1) + dc.DrawCircle(0, 0, 100) + dc.Stroke() + dc.SavePNG(path) +} diff --git a/main.go b/main.go index b6c0aeb..454abe5 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,9 @@ package main import ( + "./draw" "./forces" "./structs" - "fmt" ) func main() { @@ -14,9 +14,6 @@ func main() { {structs.Coord{X: 100, Y: 500}, structs.Force{0, 0}, 1000}, } - // Print the starsSlice - fmt.Println(starsSlice) - - // Calculate the forces acting inbetween all the stars in the starsSlice slice and star nr 0 in the starsSlice slice - fmt.Println(forces.CalcAllForces(starsSlice)) + forces.CalcAllForces(starsSlice) + draw.Slice(starsSlice, "out.png") } |