rainbow_gradient 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example/data/gradient2.yml +1 -1
- data/example/gradient.rb +16 -9
- data/example/output/gradient.png +0 -0
- data/lib/rainbow/color_range.rb +4 -4
- data/lib/rainbow/gradient.rb +1 -1
- data/lib/rainbow/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7699028d92d659d49e21553288816158498a387
|
4
|
+
data.tar.gz: be6e6b282bc5d6466e0f39364aff986052d22c29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae2ddb08c5289bc74afadc23536206d3ccb70bb046487ea40466951b1908a3cd15d372bad6f2ad343f5b08c142a90ceaf5bd862d3ca8548c926d2f7fbaf09b5c
|
7
|
+
data.tar.gz: 64ccff0fb50e6ce08c15e111ea2f24e5e73a83304f7a51c194870672feb1eecb267829b31894af51a384448f4c5a5bb24e7f89e4070e62a8eaf7abd59f0cb07e
|
data/example/data/gradient2.yml
CHANGED
data/example/gradient.rb
CHANGED
@@ -1,27 +1,34 @@
|
|
1
|
-
|
1
|
+
require_relative '../lib/rainbow'
|
2
|
+
require 'pp'
|
2
3
|
|
3
|
-
first_color = Rainbow::Color.new(ChunkyPNG::Color(255,
|
4
|
-
second_color = Rainbow::Color.new(ChunkyPNG::Color(255,
|
5
|
-
|
4
|
+
first_color = Rainbow::Color.new(ChunkyPNG::Color(255, 221, 23), 0)
|
5
|
+
second_color = Rainbow::Color.new(ChunkyPNG::Color(255, 221, 23), 80)
|
6
|
+
color_range1 = Rainbow::ColorRange.new(first_color, second_color, 50)
|
7
|
+
|
8
|
+
third_color = Rainbow::Color.new(ChunkyPNG::Color(255, 221, 23), 81)
|
9
|
+
color_range2 = Rainbow::ColorRange.new(second_color, third_color, 50)
|
10
|
+
|
11
|
+
fouth_color = Rainbow::Color.new(ChunkyPNG::Color(255, 221, 23), 100)
|
12
|
+
color_range3 = Rainbow::ColorRange.new(third_color, fouth_color, 50)
|
6
13
|
|
7
14
|
first_opacity = Rainbow::Opacity.new(100, 0)
|
8
|
-
second_opacity = Rainbow::Opacity.new(
|
15
|
+
second_opacity = Rainbow::Opacity.new(100, 100)
|
9
16
|
opacity_range = Rainbow::OpacityRange.new(first_opacity, second_opacity, 50)
|
10
17
|
|
11
18
|
filename = './example/output/gradient.png'
|
12
19
|
args = {
|
13
20
|
reverse: false,
|
14
21
|
opacity: 100,
|
15
|
-
scale:
|
16
|
-
angle:
|
22
|
+
scale: 100,
|
23
|
+
angle: 0,
|
17
24
|
|
18
25
|
style: 'linear',
|
19
26
|
gradient: {
|
20
|
-
color_ranges: [
|
27
|
+
color_ranges: [color_range1, color_range2, color_range3],
|
21
28
|
opacity_ranges: [opacity_range]
|
22
29
|
}
|
23
30
|
}
|
24
|
-
gradient = Rainbow::Gradient.new(
|
31
|
+
gradient = Rainbow::Gradient.new(195, 27, args)
|
25
32
|
gradient.save_as_png(filename)
|
26
33
|
|
27
34
|
`open #{filename}`
|
data/example/output/gradient.png
CHANGED
Binary file
|
data/lib/rainbow/color_range.rb
CHANGED
@@ -59,15 +59,15 @@ module Rainbow
|
|
59
59
|
from_color.g + (to_color.g - from_color.g) / 2,
|
60
60
|
from_color.b + (to_color.b - from_color.b) / 2)
|
61
61
|
|
62
|
-
@width = gradient.width * (to_color.location - from_color.location) / 100
|
63
|
-
@first_width = @width * mid_point / 100
|
62
|
+
@width = (gradient.width * (to_color.location - from_color.location) / 100.0).round
|
63
|
+
@first_width = (@width * mid_point / 100.0).round
|
64
64
|
@second_width = @width - @first_width
|
65
65
|
|
66
|
-
@from_location_in_pixel = from_color.location * gradient.width / 100
|
66
|
+
@from_location_in_pixel = (from_color.location * gradient.width / 100.0).round
|
67
67
|
@mid_location_in_pixel = @from_location_in_pixel + @first_width
|
68
68
|
@to_location_in_pixel = @from_location_in_pixel + @width
|
69
69
|
|
70
|
-
@leftover_width = (100 - to_color.location) * gradient.width / 100
|
70
|
+
@leftover_width = ((100 - to_color.location) * gradient.width / 100.0).round
|
71
71
|
end
|
72
72
|
|
73
73
|
def in_scale_range?
|
data/lib/rainbow/gradient.rb
CHANGED
@@ -117,7 +117,7 @@ module Rainbow
|
|
117
117
|
|
118
118
|
@scale_start_location_in_pixel = scale_start * width / 100
|
119
119
|
@scale_end_location_in_pixel = scale_end * width / 100
|
120
|
-
@scale_half_distance_in_pixel = (@scale_end_location_in_pixel - @scale_start_location_in_pixel) / 2
|
120
|
+
@scale_half_distance_in_pixel = (@scale_end_location_in_pixel - @scale_start_location_in_pixel) / 2.0
|
121
121
|
@scale_mid_location_in_pixel = @scale_start_location_in_pixel + @scale_half_distance_in_pixel
|
122
122
|
end
|
123
123
|
|
data/lib/rainbow/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rainbow_gradient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sophy Eung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chunky_png
|