triangle_pattern 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 96fd484f7fd4e2589068cdee50e3698ae10eb0986fa2cbfa0e2fae7973e02ac4
4
+ data.tar.gz: 0c204a64d865e13a462e305cbbca813a17b74e67730fe7b5a77b8bb70ce4e389
5
+ SHA512:
6
+ metadata.gz: 002340d23b32f19e39792ca3d990595813494367566e4ddfa59841114816b9768ec05b487db36bda37db605604fc8ab0805ce19ef2239e822e5054f8ad7bb522
7
+ data.tar.gz: 75aff0898277ec620209725d6a63ed0185c8a1cedddebba8f61ac428b2b59493be650159b8983fda0d3ff5a12bc72f40c45db38264b95f87a085008d008a642e
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.5
7
+ before_install: gem install bundler -v 2.0.2
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in triangle.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'rake', '< 14.0'
8
+ gem 'rspec'
9
+ end
10
+
11
+ gem "delaunator", "~> 0.1.0"
12
+
13
+ gem "gradient"
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ triangle_pattern (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ color (1.8)
11
+ delaunator (0.1.0)
12
+ diff-lcs (1.3)
13
+ gradient (0.5.1)
14
+ color (~> 1.8)
15
+ nokogiri (~> 1.6)
16
+ method_source (0.9.2)
17
+ mini_portile2 (2.4.0)
18
+ nokogiri (1.10.8)
19
+ mini_portile2 (~> 2.4.0)
20
+ pry (0.12.2)
21
+ coderay (~> 1.1.0)
22
+ method_source (~> 0.9.0)
23
+ rake (13.0.1)
24
+ rspec (3.9.0)
25
+ rspec-core (~> 3.9.0)
26
+ rspec-expectations (~> 3.9.0)
27
+ rspec-mocks (~> 3.9.0)
28
+ rspec-core (3.9.0)
29
+ rspec-support (~> 3.9.0)
30
+ rspec-expectations (3.9.0)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-mocks (3.9.0)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.9.0)
36
+ rspec-support (3.9.0)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ bundler (~> 2.0)
43
+ delaunator (~> 0.1.0)
44
+ gradient
45
+ pry
46
+ rake (< 14.0)
47
+ rspec
48
+ triangle_pattern!
49
+
50
+ BUNDLED WITH
51
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Wolfgang Wohanka
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,111 @@
1
+ [![Gem Version](https://badge.fury.io/rb/triangle_pattern.svg)](https://badge.fury.io/rb/triangle_pattern)
2
+
3
+ <p align="center">
4
+ <img src="https://user-images.githubusercontent.com/19203626/75708200-4899d380-5cb8-11ea-9d3b-6dc83360c7bf.png" alt="TrianglePattern Logo"/>
5
+ </p>
6
+
7
+ With this gem you can generate placeholder images (e.g. Backgrounds, Profile Pics etc.) for your project. It uses the Delaunay triangulation to generate a mesh of triangles.
8
+
9
+ | | |
10
+ |:-------------------------:|:-------------------------:|
11
+ |<img 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"> | <img 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">|<img 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"> |
12
+ |<img 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"> | <img 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"> |
13
+
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'triangle_pattern'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install triangle_pattern
30
+
31
+ ## Usage
32
+
33
+ To create a pattern use:
34
+ ```ruby
35
+ pattern = TrianglePattern.generate
36
+ ```
37
+
38
+ with specific width and height:
39
+ ```ruby
40
+ pattern = TrianglePattern.generate(width: 900, height: 500)
41
+ ```
42
+
43
+ with a specific set of colors:
44
+ ```ruby
45
+ pattern = TrianglePattern.generate(colors: ["#edf8fb", "#b2e2e2", "#66c2a4", "#2ca25f", "#006d2c"])
46
+ ```
47
+
48
+ ![image](https://user-images.githubusercontent.com/19203626/75806052-43558b00-5d83-11ea-8ae0-5f76d59127ed.png)
49
+
50
+ get the pattern in svg:
51
+ ```ruby
52
+ puts pattern.to_svg
53
+ # => <svg xmlns="http://www.w3.org/2000/svg" ...
54
+ ```
55
+ get the Base64 encoded string:
56
+ ```ruby
57
+ puts pattern.to_base64
58
+ # => PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC...
59
+ ```
60
+ ## Options
61
+
62
+ You can pass several options to `TrianglePattern.generate`
63
+
64
+ ### width
65
+ Integer, defaults to 900. Width in pixels of the pattern to generate.
66
+
67
+ ### height
68
+ Integer, defaults to 500. Height in pixels of the pattern to generate.
69
+
70
+ ### cell_size
71
+ Integer, 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.
72
+
73
+ ### variance
74
+ Decimal value between 0 and 1, defaults to 0.75. Amount of randomness used when generating triangles.
75
+
76
+ ### seed
77
+ Integer, defaults to 135. Is used to seed the random generator which generates the points for the mesh
78
+
79
+ ### colors
80
+
81
+ Array, defaults to `["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"]`. Defines the colors uses in the pattern. TrianglePattern interpolates between the given colors to generate a gradient.
82
+
83
+ ## Rake
84
+
85
+ ```ruby
86
+ require 'triangle_pattern/triangle_task'
87
+
88
+ TrianglePattern::TriangleTask.new(
89
+ name: 'generate',
90
+ description: '', data: {
91
+ 'fixtures/BuGn.svg' => { colors: ["#edf8fb", "#b2e2e2", "#66c2a4", "#2ca25f", "#006d2c"], width: 400, height: 400, seed: 80 },
92
+ 'fixtures/GnBu.svg' => { colors: ["#edf8fb", "#b3cde3", "#8c96c6", "#8856a7", "#810f7c"], width: 400, height: 400, seed: 90 },
93
+ 'fixtures/OrRd.svg' => { colors: ["#fef0d9", "#fdcc8a", "#fc8d59", "#e34a33", "#b30000"], width: 400, height: 400, seed: 100 },
94
+ 'fixtures/BrBG.svg' => { colors: ["#a6611a", "#dfc27d", "#f5f5f5", "#80cdc1", "#018571"], width: 400, height: 400, seed: 110 },
95
+ }
96
+ )
97
+ end
98
+ ```
99
+ ## Development
100
+
101
+ After 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.
102
+
103
+ To 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).
104
+
105
+ ## Contributing
106
+
107
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/triangle.
108
+
109
+ ## License
110
+
111
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ module TempFixForRakeLastComment
5
+ def last_comment
6
+ last_description
7
+ end
8
+ end
9
+ Rake::Application.send :include, TempFixForRakeLastComment
10
+ RSpec::Core::RakeTask.new(:spec)
11
+
12
+ task :default => :spec
13
+
14
+ unless ENV.key?('CI')
15
+ require 'triangle_pattern/triangle_task'
16
+
17
+ namespace :fixtures do
18
+ TrianglePattern::TriangleTask.new(
19
+ name: 'generate', description: '', data: {
20
+ 'fixtures/BuGn.svg' => { colors: ["#edf8fb", "#b2e2e2", "#66c2a4", "#2ca25f", "#006d2c"], width: 400, height: 400, seed: 80 },
21
+ 'fixtures/GnBu.svg' => { colors: ["#edf8fb", "#b3cde3", "#8c96c6", "#8856a7", "#810f7c"], width: 400, height: 400, seed: 90 },
22
+ 'fixtures/OrRd.svg' => { colors: ["#fef0d9", "#fdcc8a", "#fc8d59", "#e34a33", "#b30000"], width: 400, height: 400, seed: 100 },
23
+ 'fixtures/BrBG.svg' => { colors: ["#a6611a", "#dfc27d", "#f5f5f5", "#80cdc1", "#018571"], width: 400, height: 400, seed: 110 },
24
+ }
25
+ )
26
+ end
27
+ end
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "triangle_pattern"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+ require "pry"
13
+ Pry.start
14
+
15
+ require "irb"
16
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/fixtures/BrBG.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="400" height="400"><path d="M 177 129 L 147 78 L 146 114 Z" stroke="#ede3cb" fill="#ede3cb" /><path d="M 177 129 L 222 35 L 147 78 Z" stroke="#dad6b2" fill="#dad6b2" /><path d="M 148 200 L 220 175 L 177 129 Z" stroke="#dfeeeb" fill="#dfeeeb" /><path d="M 177 129 L 269 124 L 222 35 Z" stroke="#bed1b1" fill="#bed1b1" /><path d="M 220 175 L 269 124 L 177 129 Z" stroke="#c5e0d4" fill="#c5e0d4" /><path d="M 146 114 L 148 200 L 177 129 Z" stroke="#f3f0e9" fill="#f3f0e9" /><path d="M 269 124 L 274 43 L 222 35 Z" stroke="#a5bc93" fill="#a5bc93" /><path d="M 208 -43 L 98 -2 L 222 35 Z" stroke="#c2a782" fill="#c2a782" /><path d="M 222 35 L 98 -2 L 147 78 Z" stroke="#dac09b" fill="#dac09b" /><path d="M 147 78 L 34 111 L 146 114 Z" stroke="#e6d2a3" fill="#e6d2a3" /><path d="M 146 114 L 45 213 L 148 200 Z" stroke="#e3e2cd" fill="#e3e2cd" /><path d="M 25 56 L 34 111 L 147 78 Z" stroke="#dbbc77" fill="#dbbc77" /><path d="M 290 -10 L 208 -43 L 222 35 Z" stroke="#93976e" fill="#93976e" /><path d="M 211 276 L 261 221 L 220 175 Z" stroke="#93d3c9" fill="#93d3c9" /><path d="M 220 175 L 261 221 L 269 124 Z" stroke="#addbd4" fill="#addbd4" /><path d="M 98 -2 L 25 56 L 147 78 Z" stroke="#d4af6e" fill="#d4af6e" /><path d="M 367 76 L 290 -10 L 274 43 Z" stroke="#849d72" fill="#849d72" /><path d="M 274 43 L 290 -10 L 222 35 Z" stroke="#92a076" fill="#92a076" /><path d="M 367 76 L 274 43 L 269 124 Z" stroke="#97ba90" fill="#97ba90" /><path d="M -34 174 L 45 213 L 34 111 Z" stroke="#ceb38f" fill="#ceb38f" /><path d="M 34 111 L 45 213 L 146 114 Z" stroke="#e6d4ab" fill="#e6d4ab" /><path d="M 148 200 L 211 276 L 220 175 Z" stroke="#b3dfd8" fill="#b3dfd8" /><path d="M 208 -43 L 142 -74 L 98 -2 Z" stroke="#cca880" fill="#cca880" /><path d="M 98 -2 L 32 -13 L 25 56 Z" stroke="#bd8942" fill="#bd8942" /><path d="M 195 -124 L 142 -74 L 208 -43 Z" stroke="#bea680" fill="#bea680" /><path d="M 335 201 L 344 143 L 269 124 Z" stroke="#9ccfc5" fill="#9ccfc5" /><path d="M 44 -91 L 32 -13 L 98 -2 Z" stroke="#bb843e" fill="#bb843e" /><path d="M 125 298 L 211 276 L 148 200 Z" stroke="#b2ddd6" fill="#b2ddd6" /><path d="M 261 221 L 335 201 L 269 124 Z" stroke="#97d1c8" fill="#97d1c8" /><path d="M 290 -10 L 261 -72 L 208 -43 Z" stroke="#8e946a" fill="#8e946a" /><path d="M 280 262 L 335 201 L 261 221 Z" stroke="#74c4b8" fill="#74c4b8" /><path d="M 25 56 L -19 121 L 34 111 Z" stroke="#c99f60" fill="#c99f60" /><path d="M -35 66 L -19 121 L 25 56 Z" stroke="#c3924c" fill="#c3924c" /><path d="M 344 143 L 367 76 L 269 124 Z" stroke="#92bfa3" fill="#92bfa3" /><path d="M 290 -10 L 341 -40 L 261 -72 Z" stroke="#7c8a5f" fill="#7c8a5f" /><path d="M 402 137 L 367 76 L 344 143 Z" stroke="#81b69b" fill="#81b69b" /><path d="M 211 276 L 280 262 L 261 221 Z" stroke="#77c8bb" fill="#77c8bb" /><path d="M 45 213 L 125 298 L 148 200 Z" stroke="#b5d1b3" fill="#b5d1b3" /><path d="M 211 276 L 256 332 L 280 262 Z" stroke="#69c0b2" fill="#69c0b2" /><path d="M 32 -13 L -35 66 L 25 56 Z" stroke="#b67b35" fill="#b67b35" /><path d="M 367 76 L 341 -40 L 290 -10 Z" stroke="#71875c" fill="#71875c" /><path d="M -19 121 L -34 174 L 34 111 Z" stroke="#caa375" fill="#caa375" /><path d="M 45 213 L 67 298 L 125 298 Z" stroke="#a3c097" fill="#a3c097" /><path d="M -74 133 L -34 174 L -19 121 Z" stroke="#cba57a" fill="#cba57a" /><path d="M 366 -127 L 195 -124 L 261 -72 Z" stroke="#868f65" fill="#868f65" /><path d="M 261 -72 L 195 -124 L 208 -43 Z" stroke="#a19c74" fill="#a19c74" /><path d="M 142 -74 L 44 -91 L 98 -2 Z" stroke="#c59657" fill="#c59657" /><path d="M 35 323 L 67 298 L 45 213 Z" stroke="#95ac82" fill="#95ac82" /><path d="M 195 -124 L 44 -91 L 142 -74 Z" stroke="#c9a06f" fill="#c9a06f" /><path d="M 32 -13 L -48 -30 L -35 66 Z" stroke="#a9661f" fill="#a9661f" /><path d="M 425 189 L 402 137 L 335 201 Z" stroke="#75bcb1" fill="#75bcb1" /><path d="M 335 201 L 402 137 L 344 143 Z" stroke="#8ac6bd" fill="#8ac6bd" /><path d="M 367 76 L 436 -15 L 341 -40 Z" stroke="#5d7b4e" fill="#5d7b4e" /><path d="M 175 362 L 256 332 L 211 276 Z" stroke="#72c1b5" fill="#72c1b5" /><path d="M 280 262 L 371 249 L 335 201 Z" stroke="#5fbaac" fill="#5fbaac" /><path d="M 175 362 L 211 276 L 125 298 Z" stroke="#96cec6" fill="#96cec6" /><path d="M 362 364 L 371 249 L 280 262 Z" stroke="#45ab9c" fill="#45ab9c" /><path d="M -35 66 L -74 133 L -19 121 Z" stroke="#c69a5f" fill="#c69a5f" /><path d="M -48 295 L 35 323 L 45 213 Z" stroke="#88956b" fill="#88956b" /><path d="M -89 61 L -74 133 L -35 66 Z" stroke="#c39451" fill="#c39451" /><path d="M 44 -91 L -48 -30 L 32 -13 Z" stroke="#a96720" fill="#a96720" /><path d="M -48 -30 L -89 61 L -35 66 Z" stroke="#b2752e" fill="#b2752e" /><path d="M 67 298 L 141 360 L 125 298 Z" stroke="#95c0a3" fill="#95c0a3" /><path d="M 141 360 L 175 362 L 125 298 Z" stroke="#91c6b8" fill="#91c6b8" /><path d="M 67 298 L 35 323 L 141 360 Z" stroke="#8db48a" fill="#8db48a" /><path d="M -48 295 L 45 213 L -34 174 Z" stroke="#9c9a72" fill="#9c9a72" /><path d="M 402 137 L 437 61 L 367 76 Z" stroke="#72a780" fill="#72a780" /><path d="M 425 189 L 437 61 L 402 137 Z" stroke="#77b39c" fill="#77b39c" /><path d="M 371 249 L 425 189 L 335 201 Z" stroke="#5db5a8" fill="#5db5a8" /><path d="M -89 61 L -99 177 L -74 133 Z" stroke="#c99f6c" fill="#c99f6c" /><path d="M -74 133 L -99 177 L -34 174 Z" stroke="#cdab87" fill="#cdab87" /><path d="M 437 61 L 436 -15 L 367 76 Z" stroke="#628c5f" fill="#628c5f" /><path d="M 341 -40 L 366 -127 L 261 -72 Z" stroke="#728459" fill="#728459" /><path d="M 410 -90 L 366 -127 L 341 -40 Z" stroke="#5e794c" fill="#5e794c" /><path d="M -48 -30 L -106 -18 L -89 61 Z" stroke="#a8641d" fill="#a8641d" /><path d="M 44 -91 L -51 -96 L -48 -30 Z" stroke="#a6611a" fill="#a6611a" /><path d="M 195 -124 L -51 -96 L 44 -91 Z" stroke="#bc8741" fill="#bc8741" /><path d="M -106 264 L -48 295 L -34 174 Z" stroke="#91966c" fill="#91966c" /><path d="M 120 445 L 175 362 L 141 360 Z" stroke="#7dbbab" fill="#7dbbab" /><path d="M 436 -15 L 410 -90 L 341 -40 Z" stroke="#557447" fill="#557447" /><path d="M -121 -91 L -106 -18 L -48 -30 Z" stroke="#a6611a" fill="#a6611a" /><path d="M -89 61 L -106 -18 L -99 177 Z" stroke="#c08d47" fill="#c08d47" /><path d="M 120 445 L 224 398 L 175 362 Z" stroke="#71baaf" fill="#71baaf" /><path d="M 175 362 L 224 398 L 256 332 Z" stroke="#5fb7a9" fill="#5fb7a9" /><path d="M 362 364 L 432 271 L 371 249 Z" stroke="#2f9f8e" fill="#2f9f8e" /><path d="M 65 408 L 141 360 L 35 323 Z" stroke="#7eac80" fill="#7eac80" /><path d="M -48 295 L -25 336 L 35 323 Z" stroke="#74855a" fill="#74855a" /><path d="M 362 364 L 280 262 L 256 332 Z" stroke="#49ae9e" fill="#49ae9e" /><path d="M 371 249 L 432 271 L 425 189 Z" stroke="#43aa9a" fill="#43aa9a" /><path d="M 425 189 L 432 271 L 437 61 Z" stroke="#71baaf" fill="#71baaf" /><path d="M -99 177 L -106 264 L -34 174 Z" stroke="#ada079" fill="#ada079" /><path d="M -48 295 L -120 323 L -25 336 Z" stroke="#74855a" fill="#74855a" /><path d="M -120 323 L -106 264 L -99 177 Z" stroke="#8d946a" fill="#8d946a" /><path d="M 348 440 L 362 364 L 256 332 Z" stroke="#289b8a" fill="#289b8a" /><path d="M -10 428 L 65 408 L 35 323 Z" stroke="#64885b" fill="#64885b" /><path d="M -51 -96 L -121 -91 L -48 -30 Z" stroke="#a6611a" fill="#a6611a" /><path d="M -106 -18 L -121 -91 L -99 177 Z" stroke="#ae6f28" fill="#ae6f28" /><path d="M 195 -124 L -121 -91 L -51 -96 Z" stroke="#a9661f" fill="#a9661f" /><path d="M 65 408 L 120 445 L 141 360 Z" stroke="#74ad8c" fill="#74ad8c" /><path d="M 224 398 L 247 444 L 256 332 Z" stroke="#43aa9b" fill="#43aa9b" /><path d="M 120 445 L 247 444 L 224 398 Z" stroke="#60b4a7" fill="#60b4a7" /><path d="M 410 434 L 403 369 L 362 364 Z" stroke="#098976" fill="#098976" /><path d="M 362 364 L 403 369 L 432 271 Z" stroke="#1b9482" fill="#1b9482" /><path d="M -121 -91 L -120 323 L -99 177 Z" stroke="#caa376" fill="#caa376" /><path d="M -106 264 L -120 323 L -48 295 Z" stroke="#7e8b60" fill="#7e8b60" /><path d="M -25 336 L -10 428 L 35 323 Z" stroke="#627b4f" fill="#627b4f" /><path d="M 65 408 L -10 428 L 120 445 Z" stroke="#68966a" fill="#68966a" /><path d="M -104 425 L -10 428 L -25 336 Z" stroke="#557446" fill="#557446" /><path d="M 247 444 L 348 440 L 256 332 Z" stroke="#2f9f8e" fill="#2f9f8e" /><path d="M 348 440 L 410 434 L 362 364 Z" stroke="#0c8b78" fill="#0c8b78" /><path d="M 403 369 L 410 434 L 432 271 Z" stroke="#128e7c" fill="#128e7c" /><path d="M -120 323 L -104 425 L -25 336 Z" stroke="#637c4f" fill="#637c4f" /><path d="M -10 428 L -104 425 L 120 445 Z" stroke="#547447" fill="#547447" /></svg>
data/fixtures/BuGn.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="400" height="400"><path d="M 139 136 L 151 207 L 212 194 Z" stroke="#5cbd99" fill="#5cbd99" /><path d="M 212 194 L 213 105 L 139 136 Z" stroke="#63bf9e" fill="#63bf9e" /><path d="M 212 194 L 260 141 L 213 105 Z" stroke="#54b78c" fill="#54b78c" /><path d="M 76 227 L 152 262 L 151 207 Z" stroke="#5cba92" fill="#5cba92" /><path d="M 151 207 L 152 262 L 212 194 Z" stroke="#4cb385" fill="#4cb385" /><path d="M 212 194 L 263 215 L 260 141 Z" stroke="#40ad77" fill="#40ad77" /><path d="M 268 248 L 263 215 L 212 194 Z" stroke="#33a567" fill="#33a567" /><path d="M 139 136 L 76 227 L 151 207 Z" stroke="#6dc4a6" fill="#6dc4a6" /><path d="M 206 298 L 268 248 L 212 194 Z" stroke="#2fa363" fill="#2fa363" /><path d="M 365 105 L 297 77 L 260 141 Z" stroke="#59b18b" fill="#59b18b" /><path d="M 297 77 L 173 34 L 213 105 Z" stroke="#76c6a7" fill="#76c6a7" /><path d="M 213 105 L 173 34 L 139 136 Z" stroke="#81cdb8" fill="#81cdb8" /><path d="M 139 136 L 28 106 L 76 227 Z" stroke="#8dd3c4" fill="#8dd3c4" /><path d="M 198 373 L 206 298 L 144 377 Z" stroke="#329b66" fill="#329b66" /><path d="M 152 262 L 206 298 L 212 194 Z" stroke="#3daa73" fill="#3daa73" /><path d="M 173 34 L 149 24 L 139 136 Z" stroke="#95d5c8" fill="#95d5c8" /><path d="M 327 185 L 260 141 L 263 215 Z" stroke="#3ca772" fill="#3ca772" /><path d="M 260 141 L 297 77 L 213 105 Z" stroke="#60ba93" fill="#60ba93" /><path d="M 173 34 L 173 -19 L 149 24 Z" stroke="#a3dacb" fill="#a3dacb" /><path d="M 268 248 L 327 185 L 263 215 Z" stroke="#2e9f62" fill="#2e9f62" /><path d="M 36 52 L 28 106 L 139 136 Z" stroke="#aee0dd" fill="#aee0dd" /><path d="M 149 24 L 36 52 L 139 136 Z" stroke="#a8ded9" fill="#a8ded9" /><path d="M 265 -19 L 173 -19 L 173 34 Z" stroke="#9ad4bd" fill="#9ad4bd" /><path d="M 149 24 L 26 -26 L 36 52 Z" stroke="#cdeced" fill="#cdeced" /><path d="M -25 225 L 27 294 L 76 227 Z" stroke="#82c8a8" fill="#82c8a8" /><path d="M 76 227 L 27 294 L 152 262 Z" stroke="#6abe9b" fill="#6abe9b" /><path d="M 173 -19 L 147 -29 L 149 24 Z" stroke="#abded1" fill="#abded1" /><path d="M 365 105 L 341 60 L 297 77 Z" stroke="#62b291" fill="#62b291" /><path d="M 297 77 L 265 -19 L 173 34 Z" stroke="#81c8a7" fill="#81c8a7" /><path d="M 327 185 L 365 105 L 260 141 Z" stroke="#46a87c" fill="#46a87c" /><path d="M 198 373 L 294 330 L 206 298 Z" stroke="#229453" fill="#229453" /><path d="M 206 298 L 294 330 L 268 248 Z" stroke="#239754" fill="#239754" /><path d="M 268 248 L 369 258 L 327 185 Z" stroke="#249656" fill="#249656" /><path d="M 327 185 L 410 140 L 365 105 Z" stroke="#3fa074" fill="#3fa074" /><path d="M 341 60 L 265 -19 L 297 77 Z" stroke="#76bd9d" fill="#76bd9d" /><path d="M 173 -19 L 224 -76 L 147 -29 Z" stroke="#a2d9c6" fill="#a2d9c6" /><path d="M 28 106 L -25 225 L 76 227 Z" stroke="#96d4c0" fill="#96d4c0" /><path d="M -34 121 L -25 225 L 28 106 Z" stroke="#aedfd3" fill="#aedfd3" /><path d="M 144 377 L 206 298 L 152 262 Z" stroke="#3ca573" fill="#3ca573" /><path d="M 27 294 L 144 377 L 152 262 Z" stroke="#58b18a" fill="#58b18a" /><path d="M -15 39 L -34 121 L 28 106 Z" stroke="#cbebeb" fill="#cbebeb" /><path d="M 327 332 L 369 258 L 268 248 Z" stroke="#1b8e4c" fill="#1b8e4c" /><path d="M 270 406 L 327 332 L 294 330 Z" stroke="#148543" fill="#148543" /><path d="M 294 330 L 327 332 L 268 248 Z" stroke="#1c8e4c" fill="#1c8e4c" /><path d="M 26 -26 L -15 39 L 36 52 Z" stroke="#dff3f5" fill="#dff3f5" /><path d="M 36 52 L -15 39 L 28 106 Z" stroke="#cfedee" fill="#cfedee" /><path d="M -25 225 L -11 302 L 27 294 Z" stroke="#88c7a8" fill="#88c7a8" /><path d="M 27 294 L 28 363 L 144 377 Z" stroke="#66b392" fill="#66b392" /><path d="M 369 258 L 410 180 L 327 185 Z" stroke="#269358" fill="#269358" /><path d="M 440 63 L 368 -16 L 341 60 Z" stroke="#6cb091" fill="#6cb091" /><path d="M 410 180 L 410 140 L 327 185 Z" stroke="#329967" fill="#329967" /><path d="M 147 -29 L 26 -26 L 149 24 Z" stroke="#c3e8e4" fill="#c3e8e4" /><path d="M -11 302 L 28 363 L 27 294 Z" stroke="#7cbe9e" fill="#7cbe9e" /><path d="M 369 258 L 405 254 L 410 180 Z" stroke="#1a8a4a" fill="#1a8a4a" /><path d="M 420 359 L 405 254 L 369 258 Z" stroke="#0f7f3e" fill="#0f7f3e" /><path d="M 274 -117 L 224 -76 L 265 -19 Z" stroke="#8bcbab" fill="#8bcbab" /><path d="M 265 -19 L 224 -76 L 173 -19 Z" stroke="#94d1b5" fill="#94d1b5" /><path d="M 147 -29 L 57 -98 L 26 -26 Z" stroke="#d1edef" fill="#d1edef" /><path d="M 368 -16 L 265 -19 L 341 60 Z" stroke="#7ebe9e" fill="#7ebe9e" /><path d="M 198 373 L 270 406 L 294 330 Z" stroke="#188a48" fill="#188a48" /><path d="M 327 332 L 420 359 L 369 258 Z" stroke="#0f7f3e" fill="#0f7f3e" /><path d="M 204 445 L 270 406 L 198 373 Z" stroke="#1c8b4c" fill="#1c8b4c" /><path d="M 134 430 L 198 373 L 144 377 Z" stroke="#35996a" fill="#35996a" /><path d="M -25 225 L -72 252 L -11 302 Z" stroke="#8acaaa" fill="#8acaaa" /><path d="M -11 302 L -20 351 L 28 363 Z" stroke="#7fbd9d" fill="#7fbd9d" /><path d="M -113 179 L -72 252 L -25 225 Z" stroke="#94d1b6" fill="#94d1b6" /><path d="M -113 179 L -25 225 L -34 121 Z" stroke="#a4dac9" fill="#a4dac9" /><path d="M 440 63 L 341 60 L 365 105 Z" stroke="#5dab8a" fill="#5dab8a" /><path d="M 56 407 L 134 430 L 144 377 Z" stroke="#4aa17b" fill="#4aa17b" /><path d="M -112 352 L -20 351 L -11 302 Z" stroke="#7fbd9e" fill="#7fbd9e" /><path d="M 28 363 L 56 407 L 144 377 Z" stroke="#5dab8a" fill="#5dab8a" /><path d="M -28 446 L 56 407 L 28 363 Z" stroke="#70b091" fill="#70b091" /><path d="M -112 -15 L -77 61 L -15 39 Z" stroke="#e3f4f7" fill="#e3f4f7" /><path d="M -15 39 L -77 61 L -34 121 Z" stroke="#d2eeef" fill="#d2eeef" /><path d="M 134 430 L 204 445 L 198 373 Z" stroke="#2c9460" fill="#2c9460" /><path d="M 224 -76 L 138 -113 L 147 -29 Z" stroke="#a6dbcb" fill="#a6dbcb" /><path d="M 274 -117 L 138 -113 L 224 -76 Z" stroke="#97d3b9" fill="#97d3b9" /><path d="M 57 -98 L -7 -52 L 26 -26 Z" stroke="#e4f5f7" fill="#e4f5f7" /><path d="M 26 -26 L -7 -52 L -15 39 Z" stroke="#edf8fb" fill="#edf8fb" /><path d="M 410 140 L 440 63 L 365 105 Z" stroke="#4ea37e" fill="#4ea37e" /><path d="M 410 180 L 440 63 L 410 140 Z" stroke="#429e75" fill="#429e75" /><path d="M 420 359 L 440 63 L 410 180 Z" stroke="#248f56" fill="#248f56" /><path d="M -72 252 L -112 352 L -11 302 Z" stroke="#84c3a3" fill="#84c3a3" /><path d="M -116 115 L -113 179 L -34 121 Z" stroke="#b4e1d8" fill="#b4e1d8" /><path d="M 138 -113 L 57 -98 L 147 -29 Z" stroke="#bfe6e1" fill="#bfe6e1" /><path d="M -112 -15 L -116 115 L -77 61 Z" stroke="#d9f1f3" fill="#d9f1f3" /><path d="M -77 61 L -116 115 L -34 121 Z" stroke="#c6e9e7" fill="#c6e9e7" /><path d="M 365 -90 L 274 -117 L 265 -19 Z" stroke="#84c3a3" fill="#84c3a3" /><path d="M 204 445 L 342 420 L 270 406 Z" stroke="#128240" fill="#128240" /><path d="M 270 406 L 342 420 L 327 332 Z" stroke="#0e7e3c" fill="#0e7e3c" /><path d="M 342 420 L 420 359 L 327 332 Z" stroke="#097837" fill="#097837" /><path d="M 405 254 L 420 359 L 410 180 Z" stroke="#138342" fill="#138342" /><path d="M 368 -16 L 365 -90 L 265 -19 Z" stroke="#80be9e" fill="#80be9e" /><path d="M 423 -90 L 365 -90 L 368 -16 Z" stroke="#79b596" fill="#79b596" /><path d="M 57 -98 L -7 -107 L -7 -52 Z" stroke="#e8f6f9" fill="#e8f6f9" /><path d="M -7 -52 L -112 -15 L -15 39 Z" stroke="#edf8fb" fill="#edf8fb" /><path d="M 138 -113 L -7 -107 L 57 -98 Z" stroke="#d6eff1" fill="#d6eff1" /><path d="M -98 -88 L -112 -15 L -7 -52 Z" stroke="#edf8fb" fill="#edf8fb" /><path d="M -116 115 L -112 352 L -113 179 Z" stroke="#95d2b8" fill="#95d2b8" /><path d="M -113 179 L -112 352 L -72 252 Z" stroke="#8acaaa" fill="#8acaaa" /><path d="M -20 351 L -28 446 L 28 363 Z" stroke="#78b596" fill="#78b596" /><path d="M 204 445 L 409 415 L 342 420 Z" stroke="#0b7b39" fill="#0b7b39" /><path d="M 342 420 L 409 415 L 420 359 Z" stroke="#026f2e" fill="#026f2e" /><path d="M 56 407 L -28 446 L 134 430 Z" stroke="#63ab8b" fill="#63ab8b" /><path d="M 134 430 L -28 446 L 204 445 Z" stroke="#4ea37e" fill="#4ea37e" /><path d="M -80 409 L -28 446 L -20 351 Z" stroke="#77b393" fill="#77b393" /><path d="M 440 63 L 447 -52 L 368 -16 Z" stroke="#77b393" fill="#77b393" /><path d="M -112 352 L -80 409 L -20 351 Z" stroke="#7bb798" fill="#7bb798" /><path d="M 447 -52 L 423 -90 L 368 -16 Z" stroke="#77b393" fill="#77b393" /><path d="M 365 -90 L 423 -90 L 274 -117 Z" stroke="#7dba9b" fill="#7dba9b" /><path d="M -7 -107 L -98 -88 L -7 -52 Z" stroke="#edf8fb" fill="#edf8fb" /></svg>
data/fixtures/GnBu.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="400" height="400"><path d="M 130 150 L 136 226 L 176 203 Z" stroke="#8e8dc2" fill="#8e8dc2" /><path d="M 130 150 L 68 207 L 136 226 Z" stroke="#9799c8" fill="#9799c8" /><path d="M 176 203 L 199 116 L 130 150 Z" stroke="#8d94c5" fill="#8d94c5" /><path d="M 68 207 L 99 273 L 136 226 Z" stroke="#988cc2" fill="#988cc2" /><path d="M 136 226 L 208 264 L 176 203 Z" stroke="#8a74b6" fill="#8a74b6" /><path d="M 99 273 L 208 264 L 136 226 Z" stroke="#8d77b7" fill="#8d77b7" /><path d="M 176 203 L 258 210 L 199 116 Z" stroke="#8a7bb9" fill="#8a7bb9" /><path d="M 199 116 L 149 73 L 130 150 Z" stroke="#98a6cf" fill="#98a6cf" /><path d="M 130 150 L 38 125 L 68 207 Z" stroke="#a0b2d5" fill="#a0b2d5" /><path d="M 68 207 L 58 271 L 99 273 Z" stroke="#9f91c4" fill="#9f91c4" /><path d="M 208 264 L 258 210 L 176 203 Z" stroke="#8966af" fill="#8966af" /><path d="M 53 76 L 38 125 L 130 150 Z" stroke="#acc2dd" fill="#acc2dd" /><path d="M 68 207 L -7 175 L 58 271 Z" stroke="#ada5cf" fill="#ada5cf" /><path d="M 258 210 L 257 125 L 199 116 Z" stroke="#8c7ab9" fill="#8c7ab9" /><path d="M 199 116 L 181 50 L 149 73 Z" stroke="#9fabd1" fill="#9fabd1" /><path d="M 149 73 L 53 76 L 130 150 Z" stroke="#a7bcda" fill="#a7bcda" /><path d="M 257 125 L 181 50 L 199 116 Z" stroke="#9a97c7" fill="#9a97c7" /><path d="M 149 73 L 122 -19 L 53 76 Z" stroke="#b9cde3" fill="#b9cde3" /><path d="M -48 143 L -7 175 L 38 125 Z" stroke="#c0cbe3" fill="#c0cbe3" /><path d="M 38 125 L -7 175 L 68 207 Z" stroke="#b0bbda" fill="#b0bbda" /><path d="M -19 302 L 66 339 L 58 271 Z" stroke="#ac8fc3" fill="#ac8fc3" /><path d="M 58 271 L 66 339 L 99 273 Z" stroke="#9e87bf" fill="#9e87bf" /><path d="M 99 273 L 178 354 L 208 264 Z" stroke="#8969af" fill="#8969af" /><path d="M 100 377 L 178 354 L 99 273 Z" stroke="#906db0" fill="#906db0" /><path d="M 208 264 L 298 264 L 258 210 Z" stroke="#8851a4" fill="#8851a4" /><path d="M 253 370 L 298 264 L 208 264 Z" stroke="#86469d" fill="#86469d" /><path d="M 258 210 L 345 194 L 257 125 Z" stroke="#8965ad" fill="#8965ad" /><path d="M -16 44 L -48 143 L 38 125 Z" stroke="#cadaeb" fill="#cadaeb" /><path d="M -7 175 L -19 302 L 58 271 Z" stroke="#b6a2ce" fill="#b6a2ce" /><path d="M 66 339 L 100 377 L 99 273 Z" stroke="#9a7bb7" fill="#9a7bb7" /><path d="M -95 282 L -19 302 L -7 175 Z" stroke="#baa4cf" fill="#baa4cf" /><path d="M 66 339 L 65 420 L 100 377 Z" stroke="#9c74b3" fill="#9c74b3" /><path d="M 300 46 L 210 -2 L 181 50 Z" stroke="#afa2ce" fill="#afa2ce" /><path d="M 181 50 L 122 -19 L 149 73 Z" stroke="#b2c1dd" fill="#b2c1dd" /><path d="M 298 264 L 345 194 L 258 210 Z" stroke="#8750a2" fill="#8750a2" /><path d="M 257 125 L 300 46 L 181 50 Z" stroke="#a092c5" fill="#a092c5" /><path d="M 210 -2 L 122 -19 L 181 50 Z" stroke="#b9c0dd" fill="#b9c0dd" /><path d="M 53 76 L -16 44 L 38 125 Z" stroke="#c7dbeb" fill="#c7dbeb" /><path d="M 70 -27 L -16 44 L 53 76 Z" stroke="#d5e6f1" fill="#d5e6f1" /><path d="M 362 113 L 300 46 L 257 125 Z" stroke="#987eb9" fill="#987eb9" /><path d="M 180 408 L 253 370 L 178 354 Z" stroke="#86469c" fill="#86469c" /><path d="M 178 354 L 253 370 L 208 264 Z" stroke="#874da0" fill="#874da0" /><path d="M 298 264 L 352 288 L 345 194 Z" stroke="#86409a" fill="#86409a" /><path d="M 65 420 L 133 402 L 100 377 Z" stroke="#9567ac" fill="#9567ac" /><path d="M 100 377 L 133 402 L 178 354 Z" stroke="#8d5fa8" fill="#8d5fa8" /><path d="M 133 402 L 180 408 L 178 354 Z" stroke="#8754a2" fill="#8754a2" /><path d="M 122 -19 L 70 -27 L 53 76 Z" stroke="#ccdfed" fill="#ccdfed" /><path d="M -19 302 L 3 368 L 66 339 Z" stroke="#b28dc2" fill="#b28dc2" /><path d="M 300 46 L 281 3 L 210 -2 Z" stroke="#b49ecb" fill="#b49ecb" /><path d="M 210 -2 L 140 -94 L 122 -19 Z" stroke="#bdc8e1" fill="#bdc8e1" /><path d="M 122 -19 L 140 -94 L 70 -27 Z" stroke="#c9d8e9" fill="#c9d8e9" /><path d="M 345 194 L 362 113 L 257 125 Z" stroke="#8c69ae" fill="#8c69ae" /><path d="M 300 46 L 351 3 L 281 3 Z" stroke="#b393c5" fill="#b393c5" /><path d="M 253 370 L 352 288 L 298 264 Z" stroke="#853a96" fill="#853a96" /><path d="M 345 194 L 431 204 L 362 113 Z" stroke="#8753a2" fill="#8753a2" /><path d="M 3 368 L 65 420 L 66 339 Z" stroke="#a77db8" fill="#a77db8" /><path d="M 133 402 L 65 420 L 180 408 Z" stroke="#8f5ea7" fill="#8f5ea7" /><path d="M 70 -27 L -14 -10 L -16 44 Z" stroke="#e7f4f9" fill="#e7f4f9" /><path d="M -109 134 L -113 208 L -48 143 Z" stroke="#bcc6e0" fill="#bcc6e0" /><path d="M -113 208 L -95 282 L -7 175 Z" stroke="#bbaed5" fill="#bbaed5" /><path d="M -19 302 L -107 337 L 3 368 Z" stroke="#b892c4" fill="#b892c4" /><path d="M -113 208 L -7 175 L -48 143 Z" stroke="#bcc1de" fill="#bcc1de" /><path d="M -109 134 L -48 143 L -117 37 Z" stroke="#cadaeb" fill="#cadaeb" /><path d="M -117 37 L -48 143 L -16 44 Z" stroke="#d2e4f0" fill="#d2e4f0" /><path d="M 424 108 L 373 57 L 362 113 Z" stroke="#976daf" fill="#976daf" /><path d="M 362 113 L 373 57 L 300 46 Z" stroke="#9e7cb8" fill="#9e7cb8" /><path d="M 373 57 L 351 3 L 300 46 Z" stroke="#ab87be" fill="#ab87be" /><path d="M 218 -120 L 140 -94 L 210 -2 Z" stroke="#bcbbdb" fill="#bcbbdb" /><path d="M 70 -27 L 56 -89 L -14 -10 Z" stroke="#dfeef5" fill="#dfeef5" /><path d="M 257 -97 L 210 -2 L 281 3 Z" stroke="#baa5d0" fill="#baa5d0" /><path d="M 253 370 L 352 376 L 352 288 Z" stroke="#842d8e" fill="#842d8e" /><path d="M 352 288 L 431 204 L 345 194 Z" stroke="#853c97" fill="#853c97" /><path d="M 333 439 L 352 376 L 253 370 Z" stroke="#832388" fill="#832388" /><path d="M 65 420 L 261 445 L 180 408 Z" stroke="#864f9f" fill="#864f9f" /><path d="M 180 408 L 261 445 L 253 370 Z" stroke="#853693" fill="#853693" /><path d="M -14 -10 L -72 -2 L -16 44 Z" stroke="#e9f5f9" fill="#e9f5f9" /><path d="M -6 -99 L -72 -2 L -14 -10 Z" stroke="#edf8fb" fill="#edf8fb" /><path d="M 140 -94 L 56 -89 L 70 -27 Z" stroke="#cee0ed" fill="#cee0ed" /><path d="M -113 208 L -107 337 L -95 282 Z" stroke="#ba9fcc" fill="#ba9fcc" /><path d="M -95 282 L -107 337 L -19 302 Z" stroke="#b998c8" fill="#b998c8" /><path d="M 3 368 L -14 432 L 65 420 Z" stroke="#b07fb9" fill="#b07fb9" /><path d="M -107 337 L -14 432 L 3 368 Z" stroke="#b788be" fill="#b788be" /><path d="M 65 420 L -14 432 L 261 445 Z" stroke="#9466ab" fill="#9466ab" /><path d="M 442 274 L 431 204 L 352 288 Z" stroke="#842f8f" fill="#842f8f" /><path d="M 373 57 L 428 23 L 351 3 Z" stroke="#ad80ba" fill="#ad80ba" /><path d="M 431 204 L 424 108 L 362 113 Z" stroke="#8b59a4" fill="#8b59a4" /><path d="M -72 -2 L -117 37 L -16 44 Z" stroke="#e3f1f7" fill="#e3f1f7" /><path d="M -109 134 L -117 37 L -113 208 Z" stroke="#c5d3e7" fill="#c5d3e7" /><path d="M 324 -73 L 257 -97 L 281 3 Z" stroke="#b99ccb" fill="#b99ccb" /><path d="M 424 364 L 442 274 L 352 288 Z" stroke="#832388" fill="#832388" /><path d="M 431 204 L 428 23 L 424 108 Z" stroke="#9263aa" fill="#9263aa" /><path d="M 261 445 L 333 439 L 253 370 Z" stroke="#84298c" fill="#84298c" /><path d="M 352 376 L 424 364 L 352 288 Z" stroke="#832187" fill="#832187" /><path d="M 257 -97 L 218 -120 L 210 -2 Z" stroke="#bbacd3" fill="#bbacd3" /><path d="M 140 -94 L 218 -120 L 56 -89 Z" stroke="#c2cfe4" fill="#c2cfe4" /><path d="M 351 3 L 324 -73 L 281 3 Z" stroke="#b996c6" fill="#b996c6" /><path d="M 257 -97 L 421 -122 L 218 -120 Z" stroke="#b99ac9" fill="#b99ac9" /><path d="M 413 -26 L 324 -73 L 351 3 Z" stroke="#b88cc1" fill="#b88cc1" /><path d="M 218 -120 L -6 -99 L 56 -89 Z" stroke="#cedfed" fill="#cedfed" /><path d="M 56 -89 L -6 -99 L -14 -10 Z" stroke="#e9f5f9" fill="#e9f5f9" /><path d="M -72 -2 L -119 -119 L -117 37 Z" stroke="#edf8fb" fill="#edf8fb" /><path d="M 442 274 L 428 23 L 431 204 Z" stroke="#8650a0" fill="#8650a0" /><path d="M 424 108 L 428 23 L 373 57 Z" stroke="#a073b2" fill="#a073b2" /><path d="M 433 443 L 424 364 L 352 376 Z" stroke="#81107d" fill="#81107d" /><path d="M 428 23 L 413 -26 L 351 3 Z" stroke="#b784bc" fill="#b784bc" /><path d="M -113 208 L -117 428 L -107 337 Z" stroke="#b994c6" fill="#b994c6" /><path d="M -107 337 L -117 428 L -14 432 Z" stroke="#b784bc" fill="#b784bc" /><path d="M -14 432 L -117 428 L 261 445 Z" stroke="#a778b5" fill="#a778b5" /><path d="M -117 37 L -117 428 L -113 208 Z" stroke="#bbadd4" fill="#bbadd4" /><path d="M 333 439 L 433 443 L 352 376 Z" stroke="#821580" fill="#821580" /><path d="M 424 364 L 433 443 L 442 274 Z" stroke="#821881" fill="#821881" /><path d="M 261 445 L 433 443 L 333 439 Z" stroke="#821c84" fill="#821c84" /><path d="M 218 -120 L -119 -119 L -6 -99 Z" stroke="#e2f0f6" fill="#e2f0f6" /><path d="M -6 -99 L -119 -119 L -72 -2 Z" stroke="#edf8fb" fill="#edf8fb" /><path d="M -117 37 L -119 -119 L -117 428 Z" stroke="#c7d6e9" fill="#c7d6e9" /><path d="M 324 -73 L 421 -122 L 257 -97 Z" stroke="#b892c4" fill="#b892c4" /><path d="M 218 -120 L 421 -122 L -119 -119 Z" stroke="#bcc2de" fill="#bcc2de" /><path d="M 413 -26 L 421 -122 L 324 -73 Z" stroke="#b787bd" fill="#b787bd" /><path d="M 428 23 L 421 -122 L 413 -26 Z" stroke="#b784bb" fill="#b784bb" /><path d="M 442 274 L 421 -122 L 428 23 Z" stroke="#a274b3" fill="#a274b3" /></svg>
data/fixtures/OrRd.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="400" height="400"><path d="M 107 186 L 72 130 L 64 208 Z" stroke="#faa66e" fill="#faa66e" /><path d="M 107 186 L 117 117 L 72 130 Z" stroke="#fcab71" fill="#fcab71" /><path d="M -43 193 L 55 249 L 64 208 Z" stroke="#f4a17f" fill="#f4a17f" /><path d="M 64 208 L 100 276 L 107 186 Z" stroke="#f38e5f" fill="#f38e5f" /><path d="M -28 75 L -7 116 L 78 26 Z" stroke="#fdddae" fill="#fdddae" /><path d="M 72 130 L -7 116 L 64 208 Z" stroke="#fdb886" fill="#fdb886" /><path d="M 55 249 L 100 276 L 64 208 Z" stroke="#ef8c61" fill="#ef8c61" /><path d="M 107 186 L 188 111 L 117 117 Z" stroke="#fc9f67" fill="#fc9f67" /><path d="M -7 116 L -43 193 L 64 208 Z" stroke="#fbb894" fill="#fbb894" /><path d="M 55 249 L 34 353 L 100 276 Z" stroke="#e8835e" fill="#e8835e" /><path d="M 117 117 L 118 56 L 72 130 Z" stroke="#fdbb7d" fill="#fdbb7d" /><path d="M 100 276 L 182 227 L 107 186 Z" stroke="#f17c52" fill="#f17c52" /><path d="M 117 117 L 188 111 L 118 56 Z" stroke="#fdae73" fill="#fdae73" /><path d="M 182 227 L 188 111 L 107 186 Z" stroke="#fa8756" fill="#fa8756" /><path d="M 78 26 L -7 116 L 72 130 Z" stroke="#fdcf97" fill="#fdcf97" /><path d="M -7 116 L -90 144 L -43 193 Z" stroke="#fdc29c" fill="#fdc29c" /><path d="M 118 56 L 78 26 L 72 130 Z" stroke="#fdca8c" fill="#fdca8c" /><path d="M -77 259 L -52 262 L -43 193 Z" stroke="#f19e86" fill="#f19e86" /><path d="M -43 193 L -52 262 L 55 249 Z" stroke="#f19f87" fill="#f19f87" /><path d="M -28 75 L -90 144 L -7 116 Z" stroke="#fdd2a8" fill="#fdd2a8" /><path d="M -52 262 L -8 323 L 55 249 Z" stroke="#eb9480" fill="#eb9480" /><path d="M -120 205 L -77 259 L -43 193 Z" stroke="#f4a68b" fill="#f4a68b" /><path d="M -52 262 L -117 328 L -8 323 Z" stroke="#e78e7c" fill="#e78e7c" /><path d="M 78 26 L 24 -3 L -28 75 Z" stroke="#fee3bd" fill="#fee3bd" /><path d="M -28 75 L -127 29 L -90 144 Z" stroke="#fdddb1" fill="#fdddb1" /><path d="M 118 56 L 152 -3 L 78 26 Z" stroke="#fdca99" fill="#fdca99" /><path d="M 78 26 L 113 -80 L 24 -3 Z" stroke="#fee0b6" fill="#fee0b6" /><path d="M 188 111 L 193 34 L 118 56 Z" stroke="#fcad76" fill="#fcad76" /><path d="M 270 41 L 193 34 L 188 111 Z" stroke="#f4996d" fill="#f4996d" /><path d="M -8 323 L 34 353 L 55 249 Z" stroke="#e6876e" fill="#e6876e" /><path d="M 100 276 L 226 281 L 182 227 Z" stroke="#eb6340" fill="#eb6340" /><path d="M 193 34 L 152 -3 L 118 56 Z" stroke="#fdba8c" fill="#fdba8c" /><path d="M 214 342 L 226 281 L 100 276 Z" stroke="#e35538" fill="#e35538" /><path d="M 182 227 L 265 208 L 188 111 Z" stroke="#f06e48" fill="#f06e48" /><path d="M 34 353 L 119 356 L 100 276 Z" stroke="#e3754f" fill="#e3754f" /><path d="M -90 144 L -120 205 L -43 193 Z" stroke="#fab694" fill="#fab694" /><path d="M 226 281 L 265 208 L 182 227 Z" stroke="#e65137" fill="#e65137" /><path d="M 28 -106 L -7 -37 L 24 -3 Z" stroke="#feedd2" fill="#feedd2" /><path d="M 24 -3 L -7 -37 L -28 75 Z" stroke="#feedd3" fill="#feedd3" /><path d="M -90 144 L -127 29 L -120 205 Z" stroke="#fdcca3" fill="#fdcca3" /><path d="M 265 208 L 293 140 L 188 111 Z" stroke="#ee6c47" fill="#ee6c47" /><path d="M 119 356 L 214 342 L 100 276 Z" stroke="#e35e3d" fill="#e35e3d" /><path d="M 226 281 L 278 264 L 265 208 Z" stroke="#df442f" fill="#df442f" /><path d="M 362 221 L 357 115 L 293 140 Z" stroke="#e15637" fill="#e15637" /><path d="M 254 340 L 278 264 L 226 281 Z" stroke="#d93a28" fill="#d93a28" /><path d="M 293 140 L 270 41 L 188 111 Z" stroke="#ee8258" fill="#ee8258" /><path d="M 193 34 L 206 -31 L 152 -3 Z" stroke="#f9b593" fill="#f9b593" /><path d="M 277 3 L 206 -31 L 193 34 Z" stroke="#f3a388" fill="#f3a388" /><path d="M 152 -3 L 113 -80 L 78 26 Z" stroke="#fdd0a7" fill="#fdd0a7" /><path d="M -19 431 L 66 411 L 34 353 Z" stroke="#d9725f" fill="#d9725f" /><path d="M 34 353 L 66 411 L 119 356 Z" stroke="#dc6e4d" fill="#dc6e4d" /><path d="M 119 356 L 133 405 L 214 342 Z" stroke="#dc5033" fill="#dc5033" /><path d="M -19 431 L 34 353 L -8 323 Z" stroke="#dd7f70" fill="#dd7f70" /><path d="M -104 -5 L -127 29 L -28 75 Z" stroke="#fee9c9" fill="#fee9c9" /><path d="M 66 411 L 133 405 L 119 356 Z" stroke="#d95e3f" fill="#d95e3f" /><path d="M -120 205 L -117 328 L -77 259 Z" stroke="#ed9782" fill="#ed9782" /><path d="M -77 259 L -117 328 L -52 262 Z" stroke="#ea937f" fill="#ea937f" /><path d="M -127 29 L -117 328 L -120 205 Z" stroke="#f9b393" fill="#f9b393" /><path d="M -7 -37 L -104 -5 L -28 75 Z" stroke="#feeed4" fill="#feeed4" /><path d="M 214 342 L 254 340 L 226 281 Z" stroke="#d83b28" fill="#d83b28" /><path d="M 273 434 L 254 340 L 214 342 Z" stroke="#ce2a1d" fill="#ce2a1d" /><path d="M 206 -31 L 113 -80 L 152 -3 Z" stroke="#fdc09a" fill="#fdc09a" /><path d="M -7 -37 L -97 -112 L -104 -5 Z" stroke="#fef0d9" fill="#fef0d9" /><path d="M 334 -16 L 277 3 L 270 41 Z" stroke="#e88e79" fill="#e88e79" /><path d="M 270 41 L 277 3 L 193 34 Z" stroke="#ef9678" fill="#ef9678" /><path d="M 206 -31 L 225 -74 L 113 -80 Z" stroke="#fab694" fill="#fab694" /><path d="M 66 411 L 178 423 L 133 405 Z" stroke="#d85437" fill="#d85437" /><path d="M 133 405 L 178 423 L 214 342 Z" stroke="#d7432b" fill="#d7432b" /><path d="M -117 328 L -19 431 L -8 323 Z" stroke="#de8173" fill="#de8173" /><path d="M 66 411 L -19 431 L 178 423 Z" stroke="#d86747" fill="#d86747" /><path d="M 113 -80 L 28 -106 L 24 -3 Z" stroke="#fee4be" fill="#fee4be" /><path d="M 277 3 L 225 -74 L 206 -31 Z" stroke="#f19f87" fill="#f19f87" /><path d="M 113 -80 L 276 -123 L 28 -106 Z" stroke="#fdc79f" fill="#fdc79f" /><path d="M 293 140 L 357 115 L 270 41 Z" stroke="#e6744e" fill="#e6744e" /><path d="M 337 -92 L 276 -123 L 225 -74 Z" stroke="#eb9480" fill="#eb9480" /><path d="M 362 221 L 293 140 L 265 208 Z" stroke="#e15034" fill="#e15034" /><path d="M 362 221 L 265 208 L 278 264 Z" stroke="#db402b" fill="#db402b" /><path d="M 358 303 L 362 221 L 278 264 Z" stroke="#d22f21" fill="#d22f21" /><path d="M 276 -123 L -7 -118 L 28 -106 Z" stroke="#fdd7ac" fill="#fdd7ac" /><path d="M 28 -106 L -7 -118 L -7 -37 Z" stroke="#feefd7" fill="#feefd7" /><path d="M 423 137 L 366 66 L 357 115 Z" stroke="#db6040" fill="#db6040" /><path d="M 357 115 L 366 66 L 270 41 Z" stroke="#e27753" fill="#e27753" /><path d="M 254 340 L 358 303 L 278 264 Z" stroke="#d12e20" fill="#d12e20" /><path d="M 324 406 L 358 303 L 254 340 Z" stroke="#c82016" fill="#c82016" /><path d="M 366 66 L 334 -16 L 270 41 Z" stroke="#e4836a" fill="#e4836a" /><path d="M -7 -118 L -97 -112 L -7 -37 Z" stroke="#fef0d9" fill="#fef0d9" /><path d="M -104 -5 L -97 -112 L -127 29 Z" stroke="#fef0d9" fill="#fef0d9" /><path d="M -115 452 L 273 434 L 178 423 Z" stroke="#d8593b" fill="#d8593b" /><path d="M 178 423 L 273 434 L 214 342 Z" stroke="#ce2d1e" fill="#ce2d1e" /><path d="M -117 328 L -115 452 L -19 431 Z" stroke="#d9786d" fill="#d9786d" /><path d="M -19 431 L -115 452 L 178 423 Z" stroke="#d87565" fill="#d87565" /><path d="M -127 29 L -115 452 L -117 328 Z" stroke="#ec9681" fill="#ec9681" /><path d="M 273 434 L 324 406 L 254 340 Z" stroke="#c51c14" fill="#c51c14" /><path d="M 324 406 L 377 332 L 358 303 Z" stroke="#c21710" fill="#c21710" /><path d="M 427 247 L 426 213 L 362 221 Z" stroke="#cd2a1d" fill="#cd2a1d" /><path d="M 362 221 L 423 137 L 357 115 Z" stroke="#da4c30" fill="#da4c30" /><path d="M 426 213 L 423 137 L 362 221 Z" stroke="#d33a25" fill="#d33a25" /><path d="M 409 -32 L 337 -92 L 334 -16 Z" stroke="#df8173" fill="#df8173" /><path d="M 337 -92 L 225 -74 L 277 3 Z" stroke="#eb9480" fill="#eb9480" /><path d="M 225 -74 L 276 -123 L 113 -80 Z" stroke="#f6ac8e" fill="#f6ac8e" /><path d="M 337 -92 L 277 3 L 334 -16 Z" stroke="#e58b7a" fill="#e58b7a" /><path d="M 427 247 L 362 221 L 358 303 Z" stroke="#cb251a" fill="#cb251a" /><path d="M 377 332 L 427 247 L 358 303 Z" stroke="#c51b13" fill="#c51b13" /><path d="M 409 -32 L 334 -16 L 366 66 Z" stroke="#dd7e6e" fill="#dd7e6e" /><path d="M 449 -74 L 428 38 L 423 137 Z" stroke="#d8705c" fill="#d8705c" /><path d="M 423 137 L 428 38 L 366 66 Z" stroke="#d86645" fill="#d86645" /><path d="M 449 -74 L 423 137 L 426 213 Z" stroke="#d86141" fill="#d86141" /><path d="M 377 332 L 420 350 L 427 247 Z" stroke="#c1150e" fill="#c1150e" /><path d="M 420 417 L 420 350 L 377 332 Z" stroke="#b80805" fill="#b80805" /><path d="M 428 38 L 409 -32 L 366 66 Z" stroke="#d87361" fill="#d87361" /><path d="M 273 434 L 420 417 L 324 406 Z" stroke="#bc0e0a" fill="#bc0e0a" /><path d="M 324 406 L 420 417 L 377 332 Z" stroke="#b90a07" fill="#b90a07" /><path d="M 420 350 L 420 417 L 427 247 Z" stroke="#bc0e0a" fill="#bc0e0a" /><path d="M 427 247 L 449 -74 L 426 213 Z" stroke="#d85336" fill="#d85336" /><path d="M 428 38 L 449 -74 L 409 -32 Z" stroke="#d9786d" fill="#d9786d" /><path d="M 409 -32 L 449 -74 L 337 -92 Z" stroke="#d9786d" fill="#d9786d" /><path d="M 337 -92 L 449 -74 L 276 -123 Z" stroke="#df8374" fill="#df8374" /><path d="M 420 417 L 449 -74 L 427 247 Z" stroke="#d23724" fill="#d23724" /></svg>
@@ -0,0 +1,37 @@
1
+ module TrianglePattern
2
+ class Grid
3
+
4
+ def initialize(width, height, cell_size, variance, seed)
5
+ @width = width
6
+ @height = height
7
+ @cell_size = cell_size
8
+ @variance = variance
9
+ @seed = seed
10
+ @calc_variance = cell_size * variance / 2.to_f
11
+ cells_x = ((@width + 4 * @cell_size) / @cell_size).floor
12
+ cells_y = ((@height + 4 * @cell_size) / @cell_size).floor
13
+ @bleed_x = ((cells_x * @cell_size) - width) / 2
14
+ @bleed_y = ((cells_y * @cell_size) - height) / 2
15
+ end
16
+
17
+ def generate_grid
18
+ half_cell_size = (@cell_size / 2.to_f).round
19
+ double_v = @calc_variance * 2
20
+ negative_v = -@calc_variance
21
+ grid = []
22
+ prng1 = Random.new(@seed)
23
+ h = @height + @bleed_y
24
+ w = @width + @bleed_x
25
+ i = -@bleed_x
26
+ j = -@bleed_y
27
+ (-@bleed_x..w-@bleed_x).step(@cell_size) do |i|
28
+ (-@bleed_y..h-@bleed_x).step(@cell_size) do |j|
29
+ x = (i + half_cell_size) + (prng1.rand * double_v + negative_v)
30
+ y = (j + half_cell_size) + (prng1.rand * double_v + negative_v)
31
+ grid << [x.floor, y.floor]
32
+ end
33
+ end
34
+ grid
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,93 @@
1
+ module TrianglePattern
2
+ class Pattern
3
+ def initialize(width, height, cell_size, variance, seed, colors, svg = TrianglePattern::SvgImage.new)
4
+ @svg = svg
5
+ @width = width
6
+ @height = height
7
+ @points = TrianglePattern::Grid.new(@width, @height, cell_size, variance, seed).generate_grid
8
+ d = Delaunator::Triangulator.new(@points.flatten)
9
+ d.triangulate
10
+ @delauny_indicies = d.triangles
11
+ @colors = colors
12
+ @triangles = generate_triangles
13
+ end
14
+
15
+ def to_svg
16
+ image.to_s
17
+ end
18
+
19
+ def to_base64
20
+ Base64.strict_encode64(to_svg)
21
+ end
22
+
23
+ private
24
+
25
+ def generate_triangles
26
+ triangles = []
27
+ triangle_count = @delauny_indicies.length / 3
28
+ gradient_map = build_color_gradient
29
+ color_index = 0
30
+ (0..@delauny_indicies.length-1).step(3) do |i|
31
+ vertices = [@points[@delauny_indicies[i]], @points[@delauny_indicies[i + 1]], @points[@delauny_indicies[i + 2]]]
32
+ centroid = centroid(vertices)
33
+ x_col = gradient_map.at(norm('x', centroid[:x]))
34
+ y_col = gradient_map.at(norm('y', centroid[:y]))
35
+ t_col = Gradient::Map.new(Gradient::Point.new(0, x_col.color, 1.0), Gradient::Point.new(1, y_col.color, 1.0))
36
+ color_point = t_col.at(0.5)
37
+ triangle_color = color_point.color.html
38
+ triangles << [triangle_color, vertices]
39
+ color_index += 1
40
+ end
41
+ triangles
42
+ end
43
+
44
+ def image
45
+ @svg.height = @height
46
+ @svg.width = @width
47
+ @triangles.each do |triangle|
48
+ polygon = triangle[1].flatten.insert(0, "M").insert(3, "L").insert(6, "L").insert(-1, "Z").join(' ')
49
+ @svg.path(polygon, { stroke: triangle[0], fill: triangle[0] })
50
+ end
51
+ @svg
52
+ end
53
+
54
+ def build_color_gradient
55
+ gradient_palette = []
56
+ @colors.each_with_index do |color, index|
57
+ step = if index == 0
58
+ index
59
+ elsif index == @colors.length - 1
60
+ 1
61
+ else
62
+ (index / @colors.length.to_f).round(2)
63
+ end
64
+ gradient_palette << Gradient::Point.new(step, Color::RGB.from_html(color), 1.0)
65
+ end
66
+ map = Gradient::Map.new(gradient_palette)
67
+ return map
68
+ end
69
+
70
+ def centroid(d)
71
+ return {
72
+ x: (d[0][0] + d[1][0] + d[2][0])/3.to_f,
73
+ y: (d[0][1] + d[1][1] + d[2][1])/3.to_f
74
+ }
75
+ end
76
+
77
+ def norm(axis, value)
78
+ dimension = axis == 'x' ? @width : @height
79
+ return clamp(
80
+ _map(value, [0, dimension], [0, 1]),
81
+ [0, 1]
82
+ )
83
+ end
84
+
85
+ def _map(num, in_range, out_range)
86
+ (num - in_range[0] ) * ( out_range[1] - out_range[0] ) / ( in_range[1] - in_range[0] ).to_f + out_range[0]
87
+ end
88
+
89
+ def clamp (num, interval)
90
+ [[num, interval[0]].max, interval[1]].min
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,74 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'logger'
4
+
5
+ module TrianglePattern
6
+ class RakeTask < ::Rake::TaskLib
7
+ include ::Rake::DSL if defined?(::Rake::DSL)
8
+
9
+ attr_reader :name
10
+
11
+ attr_reader :description
12
+
13
+ attr_reader :verbose
14
+
15
+ private
16
+
17
+ attr_reader :task_arguments, :task_block, :logger, :working_directory
18
+
19
+ def initialize(opts = {}, &task_block)
20
+ @options = {
21
+ description: nil,
22
+ name: self.class.to_s.split(/::/).slice(-2..-1).join(':').gsub(/Task$/, ''),
23
+ arguments: [],
24
+ logger: ::Logger.new($stderr),
25
+ working_directory: Dir.getwd
26
+ }.merge opts
27
+
28
+ before_initialize
29
+
30
+ raise ArgumentError, :description if @options[:description].nil?
31
+
32
+ @description = @options[:description]
33
+ @task_arguments = Array(@options[:arguments])
34
+ @task_block = task_block
35
+ @logger = @options[:logger]
36
+ @working_directory = @options[:working_directory]
37
+ @name = @options[:name]
38
+
39
+ after_initialize
40
+
41
+ define_task
42
+ end
43
+
44
+ def after_initialize; end
45
+
46
+ def before_initialize; end
47
+
48
+ def define_task
49
+ desc description unless ::Rake.application.last_comment
50
+
51
+ task name, *task_arguments do |_, task_args|
52
+ RakeFileUtils.__send__(:verbose, verbose) do
53
+ instance_exec(*[self, task_args].slice(0, task_block.arity), &task_block) if task_block.respond_to? :call
54
+ run_task verbose
55
+ end
56
+ end
57
+ end
58
+
59
+ def run_task(_verbose); end
60
+
61
+ public
62
+
63
+ def instance_binding
64
+ binding
65
+ end
66
+
67
+ # Include module in instance
68
+ def include(modules)
69
+ modules = Array(modules)
70
+
71
+ modules.each { |m| self.class.include m }
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,85 @@
1
+ module TrianglePattern
2
+ class SvgImage
3
+ include Comparable
4
+
5
+ private
6
+
7
+ attr_reader :svg_string
8
+
9
+ public
10
+
11
+ attr_reader :height, :width
12
+
13
+ def initialize
14
+ @width = 100
15
+ @height = 100
16
+ @svg_string = ''
17
+ end
18
+
19
+ def width=(width)
20
+ @width = width.floor
21
+ end
22
+
23
+ def height=(height)
24
+ @height = height.floor
25
+ end
26
+
27
+ def include?(string)
28
+ body.include? string
29
+ end
30
+
31
+ def svg_header
32
+ %(<svg xmlns="http://www.w3.org/2000/svg" width="#{@width}" height="#{@height}">)
33
+ end
34
+
35
+ def svg_closer
36
+ '</svg>'
37
+ end
38
+
39
+ def to_s
40
+ svg_header + svg_string + svg_closer
41
+ end
42
+
43
+ def body
44
+ svg_string
45
+ end
46
+
47
+ def <<(svg)
48
+ svg_string << svg.body
49
+ end
50
+
51
+ def path(str, args = {})
52
+ svg_string << %(<path d="#{str}" #{write_args(args)} />)
53
+ end
54
+
55
+ def group(elements, args = {})
56
+ svg_string << %(<g #{write_args(args)}>)
57
+ elements.each { |e| eval e }
58
+ svg_string << %(</g>)
59
+ end
60
+
61
+ def write_args(args)
62
+ str = ''
63
+ args.each do |key, value|
64
+ if value.is_a?(Hash)
65
+ str << %(#{key}=")
66
+ value.each do |k, v|
67
+ str << %(#{k}:#{v};)
68
+ end
69
+ str << %(" )
70
+ else
71
+ str << %(#{key}="#{value}" )
72
+ end
73
+ end
74
+ str
75
+ end
76
+
77
+ def self.as_comment(str)
78
+ "<!-- #{str} -->"
79
+ end
80
+
81
+ def <=>(other)
82
+ to_s <=> other.to_s
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,37 @@
1
+ require 'triangle_pattern'
2
+ require 'triangle_pattern/rake_task'
3
+
4
+ module TrianglePattern
5
+ class TriangleTask < RakeTask
6
+ attr_reader :data
7
+ def initialize(opts = {})
8
+ super
9
+ raise ArgumentError, :data if @options[:data].nil?
10
+ @data = @options[:data]
11
+ end
12
+
13
+ def run_task(_verbose)
14
+ data.each do |path, string|
15
+ opts = {}
16
+ path = File.expand_path(path)
17
+
18
+ if string.is_a?(Hash)
19
+ opts[:colors] = string[:colors] if string.key? :colors
20
+ opts[:width] = string[:width] if string.key? :width
21
+ opts[:height] = string[:height] if string.key? :height
22
+ opts[:cell_size] = string[:cell_size] if string.key? :cell_size
23
+ opts[:seed] = string[:seed] if string.key? :seed
24
+ opts[:variance] = string[:variance] if string.key? :variance
25
+ else
26
+ raise 'Invalid data structure for Rake Task'
27
+ end
28
+
29
+ pattern = TrianglePattern.generate(opts)
30
+
31
+ logger.info "Creating pattern at \"#{path}\"."
32
+ FileUtils.mkdir_p File.dirname(path)
33
+ File.write(path, pattern.to_svg)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module TrianglePattern
2
+ VERSION = "0.2.1"
3
+ end
@@ -0,0 +1,13 @@
1
+ require 'base64'
2
+ require 'triangle_pattern/version'
3
+ require 'triangle_pattern/pattern'
4
+ require 'triangle_pattern/grid'
5
+ require 'triangle_pattern/svg_image'
6
+ require 'delaunator/triangulator'
7
+ require 'gradient'
8
+
9
+ module TrianglePattern
10
+ def self.generate(width: 900, height: 500, cell_size: 75, variance: 0.75, seed: 135, colors: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"])
11
+ TrianglePattern::Pattern.new(width, height, cell_size, variance, seed, colors)
12
+ end
13
+ end
@@ -0,0 +1,31 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "triangle_pattern/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "triangle_pattern"
7
+ spec.version = TrianglePattern::VERSION
8
+ spec.authors = ["Wolfgang Wohanka"]
9
+ spec.email = ["wolfgang.wohanka@pludoni.de"]
10
+
11
+ spec.summary = "Background pattern generator using Delaunay Triangulation"
12
+ spec.description = "Background pattern generator using Delaunay Triangulation"
13
+ spec.homepage = "https://github.com/hendrixfan/triangle"
14
+ spec.license = "MIT"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/hendrixfan/triangle"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+ spec.add_development_dependency "bundler", "~> 2.0"
28
+
29
+ spec.add_dependency 'delaunator'
30
+ spec.add_dependency 'gradient'
31
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: triangle_pattern
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Wolfgang Wohanka
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-03-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: delaunator
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: gradient
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Background pattern generator using Delaunay Triangulation
56
+ email:
57
+ - wolfgang.wohanka@pludoni.de
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - fixtures/BrBG.svg
73
+ - fixtures/BuGn.svg
74
+ - fixtures/GnBu.svg
75
+ - fixtures/OrRd.svg
76
+ - lib/triangle_pattern.rb
77
+ - lib/triangle_pattern/grid.rb
78
+ - lib/triangle_pattern/pattern.rb
79
+ - lib/triangle_pattern/rake_task.rb
80
+ - lib/triangle_pattern/svg_image.rb
81
+ - lib/triangle_pattern/triangle_task.rb
82
+ - lib/triangle_pattern/version.rb
83
+ - triangle_pattern.gemspec
84
+ homepage: https://github.com/hendrixfan/triangle
85
+ licenses:
86
+ - MIT
87
+ metadata:
88
+ homepage_uri: https://github.com/hendrixfan/triangle
89
+ source_code_uri: https://github.com/hendrixfan/triangle
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubygems_version: 3.1.2
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Background pattern generator using Delaunay Triangulation
109
+ test_files: []