{"id":37187718,"url":"https://github.com/ajagnic/gogenart","last_synced_at":"2026-01-14T21:49:49.747Z","repository":{"id":53302263,"uuid":"339581363","full_name":"ajagnic/gogenart","owner":"ajagnic","description":"A command-line tool for generating unique images.","archived":false,"fork":false,"pushed_at":"2021-03-31T19:15:43.000Z","size":534,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-08-19T10:39:21.178Z","etag":null,"topics":["cli","generative-art","go","golang","image-processing"],"latest_commit_sha":null,"homepage":"","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/ajagnic.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}},"created_at":"2021-02-17T01:37:48.000Z","updated_at":"2023-02-16T00:31:20.000Z","dependencies_parsed_at":"2022-09-26T21:30:38.439Z","dependency_job_id":null,"html_url":"https://github.com/ajagnic/gogenart","commit_stats":null,"previous_names":["ajagnic/go-generative-art"],"tags_count":4,"template":null,"template_full_name":null,"purl":"pkg:github/ajagnic/gogenart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajagnic%2Fgogenart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajagnic%2Fgogenart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajagnic%2Fgogenart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajagnic%2Fgogenart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajagnic","download_url":"https://codeload.github.com/ajagnic/gogenart/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajagnic%2Fgogenart/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28436212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T21:32:52.117Z","status":"ssl_error","status_checked_at":"2026-01-14T21:32:33.442Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cli","generative-art","go","golang","image-processing"],"created_at":"2026-01-14T21:49:49.028Z","updated_at":"2026-01-14T21:49:49.743Z","avatar_url":"https://github.com/ajagnic.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Generative Art in Go\n\n\u003cp align=\"center\" width=\"100%\"\u003e\n\u003cimg width=\"31%\" src=\"examples/abstract.jpeg\"\u003e\n\u003cimg width=\"31%\" src=\"examples/woman.jpeg\"\u003e\n\u003cimg width=\"31%\" src=\"examples/lines.jpeg\"\u003e\n\u003c/p\u003e\n\nMy take on the work presented in [preslavrachev/generative-art-in-go](https://github.com/preslavrachev/generative-art-in-go).\nThis project differs from Preslav's by a couple of things:\n- *gogenart* is firstly structured as a command line tool, although the _sketch_ package can be imported\n- The drawing algorithm implements pixel luminance as a scaling factor. This essentially uses the origin image as a 'heatmap' of sorts, in which larger polygons will be drawn where pixels are brighter\n\n## Libraries\n- [fogleman/gg](https://github.com/fogleman/gg)\n\n## Usage\n```\nUsage of ./gogenart:\n  -color uint\n        percent chance to randomize polygon color\n  -fill uint\n        percent chance to fill polygon (default 100)\n  -grey\n        convert to greyscale\n  -height uint\n        desired height of image\n  -i int\n        number of iterations (default 10000)\n  -invert\n        invert luminance scaling\n  -max uint\n        maximum number of polygon sides (default 5)\n  -min uint\n        minimum number of polygon sides (default 3)\n  -o string\n        file to use as output\n  -s float\n        polygon size (percentage of width) (default 0.1)\n  -shake float\n        amount to randomize pixel positions\n  -spin uint\n        max degrees to rotate pixel positions\n  -width uint\n        desired width of image\n```\n\n```bash\n# All of the following are equivalent:\n$ cat example.jpeg | gogenart \u003e result.jpeg\n\n$ gogenart example.jpeg \u003e result.jpeg\n\n$ gogenart -o=result.jpeg example.jpeg\n```\n\n```bash\n# Both JPEG and PNG files can be used.\n$ gogenart example.png \u003e result.png\n\n# Format can be converted if using the -o flag.\n$ gogenart -o=result.png example.jpeg\n```\n\n## The Drawing Algorithm\n```go\n// A random pixel is selected,\n// its luminance is used to scale a polygon,\n// and the polygon is drawn with the color of that pixel.\nrx := rand.Float64() * s.width\nry := rand.Float64() * s.height\n...\nl := luminance(r, g, b)\nstroke := s.stroke * l\n...\ns.dc.SetRGBA255(r, g, b, rand.Intn(256))\ns.dc.DrawRegularPolygon(sides, x, y, stroke, rand.Float64())\n...\n```\n\n## Examples\nDepending on the parameters used and their values, one can achieve a wide range of effects.\n\nHere we keep most of the resolution of the original image, due to the high iteration and small polygon size.\n\n\u003cp align=\"center\" width=\"100%\"\u003e\n\u003cimg width=\"32%\" src=\"examples/crane-original.jpg\"\u003e\n\u003cimg width=\"32%\" src=\"examples/crane.jpeg\"\u003e\n\u003c/p\u003e\n\n```bash\n$ ./gogenart -i=250000 -s=0.03 -fill=10 -shake=0.01 -grey \\\n-o=examples/crane.jpeg \\\nexamples/crane-original.jpg\n```\n\nWith low iteration and large polygons, a lot of shake, and completely random color, we can create an entirely original image. \n\n\u003cp align=\"center\" width=\"100%\"\u003e\n\u003cimg width=\"32%\" src=\"examples/rose-original.jpg\"\u003e\n\u003cimg width=\"32%\" src=\"examples/rose.jpeg\"\u003e\n\u003c/p\u003e\n\n```bash\n$ ./gogenart -i=2000 -s=0.2 -min=2 -max=3 -shake=0.2 -fill=50 -color=100 \\\n-o=examples/rose.jpeg \\\nexamples/rose-original.jpg\n```\n\n## Using the sketch package\n```go\nf, _ := os.Open(\"example.jpeg\")\n\nimg, enc := sketch.Source(f) // decode image from io.Reader\n\nconfig := sketch.Params{\n      Iterations:         10000,\n      PolygonSidesMin:    3,\n      PolygonSidesMax:    5,\n      PolygonFillChance:  1.0,\n      PolygonColorChance: 0.0,\n      PolygonSizeRatio:   0.1,\n      PixelShake:         0.0,\n      PixelSpin:          0,\n      NewWidth:           0.0,\n      NewHeight:          0.0,\n      Greyscale:          false,\n      InvertScaling:      false,\n}\n\ngenart := sketch.NewSketch(img, config).Draw()\n\nout, _ := os.Create(\"result.jpeg\")\n\nsketch.Encode(out, genart, enc) // encode and write to io.Writer\n```\n\nTo programmatically change parameters, you can iteratively call *DrawOnce()*\n```go\n...\ncanvas := sketch.NewSketch(img, sketch.Params{\n      PolygonSidesMin: 3,\n      PolygonSizeRatio: 0.1,\n})\n\nfor i := 0; i \u003c 10000; i++ {\n      if i \u003e 5000 {\n            canvas.Source = img2\n      }\n      canvas.Stroke -= 0.01\n      canvas.DrawOnce()\n}\n\ngenart := canvas.Image()\nsketch.Encode(out, genart, \"png\")\n```\n\nYou can implement your own drawing algorithm by using *DrawAt()*\n```go\n...\nstroke := 100.0\nrotate := 50.0\nsides := 4\nr, g, b, a := 255, 255, 255, 255\n\nfor i := 0; i \u003c 100; i++ {\n      x, y := canvas.Pixel()\n      canvas.DrawAt(x, y, stroke, rotate, sides, r, g, b, a)\n}\n...\n```\n\n# Authors\nAdrian Agnic [ [Github](https://github.com/ajagnic) ]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajagnic%2Fgogenart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajagnic%2Fgogenart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajagnic%2Fgogenart/lists"}