{"id":19665013,"url":"https://github.com/hendrixfan/triangle","last_synced_at":"2025-04-05T22:10:06.249Z","repository":{"id":59158050,"uuid":"238410877","full_name":"hendrixfan/triangle","owner":"hendrixfan","description":"Dynamically generate beautiful triangle background patterns using delaunay triangulation","archived":false,"fork":false,"pushed_at":"2025-02-22T15:52:10.000Z","size":41,"stargazers_count":48,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T21:09:03.666Z","etag":null,"topics":["hacktoberfest","pattern","ruby","triangle","visualization"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/hendrixfan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2020-02-05T09:19:03.000Z","updated_at":"2025-02-22T15:52:08.000Z","dependencies_parsed_at":"2025-01-20T05:37:18.769Z","dependency_job_id":null,"html_url":"https://github.com/hendrixfan/triangle","commit_stats":{"total_commits":12,"total_committers":4,"mean_commits":3.0,"dds":0.6666666666666667,"last_synced_commit":"59c718c4ae4203895f55c6be1e399b8a4efe6c48"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hendrixfan%2Ftriangle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hendrixfan%2Ftriangle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hendrixfan%2Ftriangle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hendrixfan%2Ftriangle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hendrixfan","download_url":"https://codeload.github.com/hendrixfan/triangle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406111,"owners_count":20933806,"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":["hacktoberfest","pattern","ruby","triangle","visualization"],"created_at":"2024-11-11T16:20:03.137Z","updated_at":"2025-04-05T22:10:06.213Z","avatar_url":"https://github.com/hendrixfan.png","language":"Ruby","readme":"![Ruby](https://github.com/hendrixfan/triangle/workflows/Ruby/badge.svg)\n[![Gem Version](https://badge.fury.io/rb/triangle_pattern.svg)](https://badge.fury.io/rb/triangle_pattern)\n\n\n\u003cp align=\"center\"\u003e\n \u003cimg src=\"https://user-images.githubusercontent.com/19203626/75708200-4899d380-5cb8-11ea-9d3b-6dc83360c7bf.png\" alt=\"TrianglePattern Logo\"/\u003e\n\u003c/p\u003e\n\nWith this gem you can generate SVG background-images for your project. It uses the [Delaunay Triangulation](https://www.mathworks.com/help/matlab/math/delaunay-triangulation.html) to generate a mesh of triangles. The triangles are also colored in a gradient given any set of colors.\n\n| | |\n|:-------------------------:|:-------------------------:|\n|\u003cimg width=\"1604\" alt=\"screen shot 2017-08-07 at 12 18 15 pm\" src=\"https://user-images.githubusercontent.com/19203626/75802209-a7c11c00-5d7c-11ea-9b89-6ccc3a0c37a4.png\"\u003e  |  \u003cimg width=\"1604\" alt=\"screen shot 2017-08-07 at 12 18 15 pm\" src=\"https://user-images.githubusercontent.com/19203626/75802265-bf98a000-5d7c-11ea-933f-750419ceb4c2.png\"\u003e|\u003cimg width=\"1604\" alt=\"screen shot 2017-08-07 at 12 18 15 pm\" src=\"https://user-images.githubusercontent.com/19203626/75802434-f8387980-5d7c-11ea-872d-1aa4b679bb71.png\"\u003e |\n|\u003cimg width=\"1604\" alt=\"screen shot 2017-08-07 at 12 18 15 pm\" src=\"https://user-images.githubusercontent.com/19203626/75802471-09818600-5d7d-11ea-974d-2d19c8fd3979.png\"\u003e  |  \u003cimg width=\"1604\" alt=\"screen shot 2017-08-07 at 12 18 15 pm\" src=\"https://user-images.githubusercontent.com/19203626/75802747-86146480-5d7d-11ea-96a7-0a616f6bb994.png\"\u003e |\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'triangle_pattern'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install triangle_pattern\n\n## Usage\n\nTo create a pattern use:\n```ruby\nrequire 'triangle_pattern'\n\npattern = TrianglePattern.generate\n```\n\nwith specific width and height:\n```ruby\npattern = TrianglePattern.generate(width: 900, height: 500)\n```\n\nwith a specific set of colors:\n```ruby\npattern = TrianglePattern.generate(colors: [\"#edf8fb\", \"#b2e2e2\", \"#66c2a4\", \"#2ca25f\", \"#006d2c\"])\n```\n\n![image](https://user-images.githubusercontent.com/19203626/75806052-43558b00-5d83-11ea-8ae0-5f76d59127ed.png)\n\nget the pattern in svg:\n```ruby\nputs pattern.to_svg\n# =\u003e \u003csvg xmlns=\"http://www.w3.org/2000/svg\" ...\n```\nget the Base64 encoded string:\n```ruby\nputs pattern.to_base64\n# =\u003e PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC...\n```\n## Options\n\nYou can pass several options to `TrianglePattern.generate`\n\n### width\nInteger, defaults to 900. Width in pixels of the pattern to generate.\n\n### height\nInteger, defaults to 500. Height in pixels of the pattern to generate.\n\n### cell_size\nInteger, defaults to 75. Size of the mesh used to generate triangles. Larger values will result in coarser patterns, smaller values will result in finer patterns.\n\n### variance\nDecimal value between 0 and 1, defaults to 0.75. Amount of randomness used when generating triangles.\n\n### seed\nInteger, defaults to 135. Is used to seed the random generator which generates the points for the mesh\n\n### colors\n\nArray, defaults to `[\"#ffffe5\",\"#f7fcb9\",\"#d9f0a3\",\"#addd8e\",\"#78c679\",\"#41ab5d\",\"#238443\",\"#006837\",\"#004529\"]`. Defines the colors used in the pattern. TrianglePattern interpolates between the given colors to generate a smooth gradient. You can get colors by using the [Chroma.js Color Palette Helper](https://gka.github.io/palettes/#/9|s|00429d,96ffea,ffffe0|ffffe0,ff005e,93003a|1|1) for example.\n\n## Rake\n\n```ruby\nrequire 'triangle_pattern/triangle_task'\n\nTrianglePattern::TriangleTask.new(\n      name: 'generate',\n      description: '', data: {\n        'fixtures/BuGn.svg' =\u003e { colors: [\"#edf8fb\", \"#b2e2e2\", \"#66c2a4\", \"#2ca25f\", \"#006d2c\"], width: 400, height: 400, seed: 80 },\n        'fixtures/GnBu.svg' =\u003e { colors: [\"#edf8fb\", \"#b3cde3\", \"#8c96c6\", \"#8856a7\", \"#810f7c\"], width: 400, height: 400, seed: 90 },\n        'fixtures/OrRd.svg' =\u003e { colors: [\"#fef0d9\", \"#fdcc8a\", \"#fc8d59\", \"#e34a33\", \"#b30000\"], width: 400, height: 400, seed: 100 },\n        'fixtures/BrBG.svg' =\u003e { colors: [\"#a6611a\", \"#dfc27d\", \"#f5f5f5\", \"#80cdc1\", \"#018571\"], width: 400, height: 400, seed: 110 },\n      }\n    )\n  end\n```\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/hendrixfan/triangle.\n\n## They are talking about it\n\n- [Rawsec - Generate background pattern in Ruby](https://rawsec.ml/en/generate-background-pattern-in-ruby/)\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhendrixfan%2Ftriangle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhendrixfan%2Ftriangle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhendrixfan%2Ftriangle/lists"}