fogleman / gg

Go Graphics - 2D rendering in Go with a simple API.
https://godoc.org/github.com/fogleman/gg
MIT License
4.46k stars 359 forks source link

graphics library #199

Closed applicativesystem closed 2 months ago

applicativesystem commented 2 months ago

Hall Michael, thank you for developing this library and i am writing a machine and deep learning code and i want to use this in Golang. My code is given below and the problem that i am having is that there is too much space between the images draw and the second one is that is there a way that i can assign different colours to the different fields such as line can have different color, Rectangle can have different color, circle can have different colour. Thank you for the help and replying to this question.

package main

/*

Author Gaurav Sablok
Universitat Potsdam
Date 2024-9-13

graphical image capturing and versioning for machine an deep learning.

*/

import (
        "github.com/fogleman/gg"
)

func main() {
        const W = 1024
        const H = 1024
        line := gg.NewContext(W, H)
        line.SetLineWidth(20)
        ellipseS := []int{1, 500}
        ellipseE := []int{500, 800}
        circleS := []int{100, 200}
        circleE := []int{600, 700}

        for i := range ellipseS {

                line.SetRGBA(3.0, 48.0, 56.0, 1.0)
                line.DrawLine(1, 0, 1000, 0)
                line.StrokePreserve()
                line.FillPreserve()
                line.ClosePath()
                line.DrawRoundedRectangle(
                        float64(ellipseS[i]),
                        float64(ellipseE[i]),
                        float64(ellipseE[i])-float64(ellipseS[i]),
                        10.0, 10.0,
                )
                line.SetRGBA(3.0, 58.0, 77.0, 1.0)
                line.StrokePreserve()
                line.FillPreserve()
                line.DrawCircle(float64(circleS[i]), float64(circleE[i]), 10.0)
                line.Stroke()
                line.Fill()
                line.SavePNG("line.png")
        }
}
applicativesystem commented 2 months ago

Thank you and i have decided to use the 2D image library having no response. Thank you for this library.