red-palette 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a79f4c5d1a76337bf252b00c1aea0f776dd1ee1678a5050d4c37b87e02bde3e
4
- data.tar.gz: 9417c77ce946dda675e26c8269d7b054e2864a327758568b1f92dd8b0c52358b
3
+ metadata.gz: f12b7fc4cf789b440ea06399e24819d4579a78ad85d13cd9f39098470ff52c1c
4
+ data.tar.gz: 73cce0dfa74982c73d927f548313a46a46310060423cfda3e848b3710c8adb34
5
5
  SHA512:
6
- metadata.gz: ad8687cd9af527240704a8b35c865a048b5b0c1fc4f6683ea8546403646e8378f281811ef5d3c70e25f24c5a5d954b7ea2e9bc429f6d442ad63aa82844383683
7
- data.tar.gz: a72e57186ab666533bbfb86ab5fdd589f8450fa4fc730c5e86c4d743f46ec45b84cc741e5960891c591e393db24d605244de0187b0cc511a7ff50b7c32eb2724
6
+ metadata.gz: 4b7e09883c5eb529d2c999aca1c297655d6d162fb3f49af18272dc29e947e1573597447f0d09e1e4592c1d02c444fc7c4200335fe814e362167251f2bba4beea
7
+ data.tar.gz: 1c017fc86fc8cfc3b178773ae17235e0094d215a382abc61e161fd3223fc9c84dda2caf24cf266b84b824ecfec02070510934a793c42d4bc3a88f9a0620cc7a2
data/lib/palette.rb CHANGED
@@ -95,6 +95,23 @@ class Palette
95
95
  @palette.dup
96
96
  end
97
97
 
98
+ def to_iruby
99
+ ["image/svg", to_svg]
100
+ end
101
+
102
+ def to_svg
103
+ w = 55
104
+ n = n_colors
105
+ svg = %Q[<svg width="#{n*w}" height="#{w}">]
106
+ @colors.each_with_index do |color, i|
107
+ hex = color.to_rgb.to_hex_string
108
+ svg << %Q[<rect x="#{i*w}" y="0" width="#{w}" height="#{w}" style="fill:#{hex};]
109
+ svg << %Q[stroke-width:2;stroke:rgb(255,255,255)"/>]
110
+ end
111
+ svg << %Q[</svg>]
112
+ svg
113
+ end
114
+
98
115
  private def normalize_palette_name(palette)
99
116
  case palette
100
117
  when String
@@ -1,3 +1,3 @@
1
1
  class Palette
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red-palette
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta Murata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-20 00:00:00.000000000 Z
11
+ date: 2021-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: red-colors
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 3.1.2
138
+ rubygems_version: 3.2.3
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Red Palette provides features for dealing with palette.