{"id":13713659,"url":"https://github.com/esimov/gospline","last_synced_at":"2025-10-08T14:50:25.292Z","repository":{"id":91223605,"uuid":"78622939","full_name":"esimov/gospline","owner":"esimov","description":"Implementing b-spline curves in Go","archived":false,"fork":false,"pushed_at":"2020-12-14T10:31:24.000Z","size":356,"stargazers_count":40,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T09:01:58.896Z","etag":null,"topics":["curves","go","spline","svg"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/esimov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-11T09:22:59.000Z","updated_at":"2025-03-11T02:12:14.000Z","dependencies_parsed_at":"2023-03-20T18:17:53.859Z","dependency_job_id":null,"html_url":"https://github.com/esimov/gospline","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/esimov/gospline","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fgospline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fgospline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fgospline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fgospline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/esimov","download_url":"https://codeload.github.com/esimov/gospline/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fgospline/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265436660,"owners_count":23765002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curves","go","spline","svg"],"created_at":"2024-08-02T23:01:41.537Z","updated_at":"2025-10-08T14:50:20.247Z","avatar_url":"https://github.com/esimov.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# gospline\nGospline is little Go library for transforming straight lines into curves.\n\nThe library is written in a modular way which means that it can be plugged in into different rendering methods. The examples provided below renders the resulted curves into image and svg, but since it has been developed using Go's philosophy of inheritance over encapsulation, it should supports other types of outputs until they implements the \u003ca href=\"https://golang.org/pkg/io/#Writer\"\u003eio.Writer\u003c/a\u003e interface.\n\nTo render the output as image, the library implements the \u003ca href=\"https://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm\"\u003eXiaolin Wu\u003c/a\u003e antialiasing method, if the provided parameter is true, otherwise it implements the \u003ca href=\"https://en.wikipedia.org/wiki/Bresenham's_line_algorithm\"\u003eBresenham\u003c/a\u003e line algorithm. This means the library is not using the default Go \u003ca href=\"https://github.com/golang/freetype/\"\u003egithub.com/golang/freetype/raster\u003c/a\u003e package for rendering.\n\n```go\nfunc (img *Canvas) DrawLine(x1, y1, x2, y2 float64, col color.Color, antialiased bool) *Canvas {\n\tif antialiased {\n\t\txiaolinWuLine(img, x1, y1, x2, y2, col.(color.NRGBA))\n\t} else {\n\t\tbresenhamLine(img, x1, y1, x2, y2, col.(color.NRGBA))\n\t}\n\treturn img\n}\n```\n\n## Installation\n```bash\n$ go get -u -f github.com/esimov/gospline\n```\n\n## Examples\nSome test files have been included into the \u003cstrong\u003eexample\u003c/strong\u003e directory. To run them type:\n`go run examples/draw.go` for example.\n\nThis is how you initialize the base method:\n\n```go\nspline := NewBSpline(points, 3, false)\nspline.Init()\n```\n...where the 2nd paramether means the degree of curvature. \n\nBelow is an example to render the spline as svg in the web browser.\n\n```go\nsvg := \u0026spline.SVG{\n  Width: width,\n  Height: height,\n  Title: \"BSpline\",\n  Lines: []spline.Line{},\n  Color: color.NRGBA{R:255,G:0,B:0,A:255},\n  Description: \"Convert straight lines to curves\",\n  StrokeWidth: 2,\n  StrokeLineCap: \"round\", //butt, round, square\n}\n\nhandler := func(w http.ResponseWriter, r *http.Request) {\n  w.Header().Set(\"Content-Type\", \"image/svg+xml\")\n  svg.Draw(w, points, false)\n}\nhttp.HandleFunc(\"/\", handler)\nhttp.ListenAndServe(\"localhost:8000\", nil)\n```\nand the corresponding method to render the output into an image.\n\n```go\nraster := \u0026spline.Image{\n  Width : width,\n  Height : height,\n  Color : color.NRGBA{R:255,G:0,B:0,A:255},\n}\noutput, _ := os.Create(\"./samples/curve.png\")\ndefer output.Close()\nraster.Draw(output, points, true)\n```\n\nYou can even use the debug option to show the original lines.\n\n```go\n// Draw original line\nif debug {\n  for i:=0; i \u003c len(points)-1; i++ {\n    raster = canvas.DrawLine(points[i][0], points[i][1], points[i+1][0], points[i+1][1], color.NRGBA{R:155,G:155,B:155,A:70 }, false)\n  }\n}\n```\nThis will produce an image like this with antialiasing mode set to true.\n\u003cimg alt=\"BSPline\" title=\"BSpline\" src=\"https://raw.githubusercontent.com/esimov/gospline/master/samples/curve.png\"/\u003e\n\n## License\n\nThis software is distributed under the MIT license found in the LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesimov%2Fgospline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fesimov%2Fgospline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesimov%2Fgospline/lists"}