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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 070d5820c9f46a99eefa0f5c4c0eb73d3a19dd8e
4
- data.tar.gz: 70f3ebd76a04b3264ca3af7e6a850f5ff84d849c
3
+ metadata.gz: e7699028d92d659d49e21553288816158498a387
4
+ data.tar.gz: be6e6b282bc5d6466e0f39364aff986052d22c29
5
5
  SHA512:
6
- metadata.gz: a5bd9de07a0e7124d84bb3c314dc073f0bc4c766e6e4cac85b14b9381fa819f204b0c537ca08ade8963888438b7fd0d95778ca883a505c9a8c3cca541cf44d1b
7
- data.tar.gz: 36abe71f5e5780ab42798541b79c7404877a6660f567bc7fcda8de8c2e3a4ec199f0a66cea44292a74d43021eea4ffcfb97b4bdeef87b1ff9f967803324c24dd
6
+ metadata.gz: ae2ddb08c5289bc74afadc23536206d3ccb70bb046487ea40466951b1908a3cd15d372bad6f2ad343f5b08c142a90ceaf5bd862d3ca8548c926d2f7fbaf09b5c
7
+ data.tar.gz: 64ccff0fb50e6ce08c15e111ea2f24e5e73a83304f7a51c194870672feb1eecb267829b31894af51a384448f4c5a5bb24e7f89e4070e62a8eaf7abd59f0cb07e
@@ -11,7 +11,7 @@ gradient2_1:
11
11
  red: 0
12
12
  green: 255
13
13
  blue: 0
14
- location: 100
14
+ location: 80
15
15
  mid_point: 50
16
16
  opacity_ranges:
17
17
  -
data/example/gradient.rb CHANGED
@@ -1,27 +1,34 @@
1
- require './lib/rainbow'
1
+ require_relative '../lib/rainbow'
2
+ require 'pp'
2
3
 
3
- first_color = Rainbow::Color.new(ChunkyPNG::Color(255, 255, 255), 0)
4
- second_color = Rainbow::Color.new(ChunkyPNG::Color(255, 255, 255), 100)
5
- color_range = Rainbow::ColorRange.new(first_color, second_color, 50)
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(0, 100)
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: 53,
16
- angle: 180,
22
+ scale: 100,
23
+ angle: 0,
17
24
 
18
25
  style: 'linear',
19
26
  gradient: {
20
- color_ranges: [color_range],
27
+ color_ranges: [color_range1, color_range2, color_range3],
21
28
  opacity_ranges: [opacity_range]
22
29
  }
23
30
  }
24
- gradient = Rainbow::Gradient.new(400, 50, args)
31
+ gradient = Rainbow::Gradient.new(195, 27, args)
25
32
  gradient.save_as_png(filename)
26
33
 
27
34
  `open #{filename}`
Binary file
@@ -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?
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Rainbow
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
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.2
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-04-06 00:00:00.000000000 Z
11
+ date: 2014-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chunky_png