palettetown 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -6
- data/lib/palettetown.rb +1 -0
- data/lib/palettetown/color.rb +10 -6
- data/lib/palettetown/monkeypatches.rb +8 -0
- data/lib/palettetown/scheme.rb +5 -5
- data/lib/palettetown/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d70cf361a1952993a74a5563cfd577852410a3a
|
4
|
+
data.tar.gz: 5c58590d55cce79f56c796c3685f768595b18704
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86c9ae9f8f737f0c36bd59996efbfc2eed048c8e0312f20f8e0fb509416c4417149840c2d57f4a5d2183656aac067604bf5c39c488481b4b088480a8485098a1
|
7
|
+
data.tar.gz: d878ba6111e4e00c705115434ea5b31e4d4b5c6d02738fb34dd6f67689a5749372b77521d134b4a086d83cfde597d3388b0a1344fb1aec5e67e15fe1e930cbda
|
data/README.md
CHANGED
@@ -16,16 +16,21 @@ description 'the most super kawaii theme ever'
|
|
16
16
|
main_bg = "00FF00"
|
17
17
|
|
18
18
|
hi :Normal, "0000FF", main_bg
|
19
|
-
hi :LineNr, darker(hi[:Normal][:fg], 10)
|
19
|
+
hi :LineNr, darker(hi[:Normal][:fg], 10.percent)
|
20
|
+
hi :String, spin(hi[:Normal][:bg], 90.degrees)
|
20
21
|
hi :Boolean, :bg => main_bg
|
21
22
|
```
|
22
23
|
|
23
24
|
### Helpers
|
24
|
-
* `lighter(color, amount)` - Increases luminosity of a color by `amount
|
25
|
-
* `darker(color, amount)` - Decreases luminosity of a color by `amount
|
26
|
-
* `saturate(color, amount)` - Increases saturation of a color by `amount
|
27
|
-
* `desaturate(color, amount)` - Decreases saturation of a color by `amount
|
28
|
-
* `spin(color, amount)` - shifts the hue by `amount`
|
25
|
+
* `lighter(color, amount)` - Increases luminosity of a color by `amount`.
|
26
|
+
* `darker(color, amount)` - Decreases luminosity of a color by `amount`.
|
27
|
+
* `saturate(color, amount)` - Increases saturation of a color by `amount`.
|
28
|
+
* `desaturate(color, amount)` - Decreases saturation of a color by `amount`.
|
29
|
+
* `spin(color, amount)` - shifts the hue by `amount` radians.
|
30
|
+
|
31
|
+
#### Monkeypatches
|
32
|
+
* `Fixnum#degrees` - provides a simple expression of degrees, returned in radians
|
33
|
+
* `Fixnum#percent` - provides a simple expression of percent, returned as a decimal
|
29
34
|
|
30
35
|
## Building a palette file
|
31
36
|
Once you've written a palette file, you build it into a proper vim theme with
|
data/lib/palettetown.rb
CHANGED
data/lib/palettetown/color.rb
CHANGED
@@ -4,6 +4,8 @@ module PaletteTown
|
|
4
4
|
def initialize color
|
5
5
|
if color.is_a? String
|
6
6
|
color = self.class.from_hex(color)
|
7
|
+
elsif color.is_a? Fixnum
|
8
|
+
color = self.class.from_hex("%06x" % color)
|
7
9
|
elsif color.is_a? PaletteTown::Color
|
8
10
|
color = color.to_h
|
9
11
|
elsif color.is_a? Hash
|
@@ -25,9 +27,10 @@ module PaletteTown
|
|
25
27
|
@lum + @sat - (@lum * @sat)
|
26
28
|
end
|
27
29
|
x = @lum * 2.0 - y
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
# Why are we using 2pi here? Because we're using Radians, bitch.
|
31
|
+
r = self.class.hue_to_rgb(x, y, @hue * Math::PI * 2 + 1.0/3.0)
|
32
|
+
g = self.class.hue_to_rgb(x, y, @hue * Math::PI * 2)
|
33
|
+
b = self.class.hue_to_rgb(x, y, @hue * Math::PI * 2 - 1.0/3.0)
|
31
34
|
end
|
32
35
|
return {
|
33
36
|
:r => (r * 255).to_i,
|
@@ -52,9 +55,9 @@ module PaletteTown
|
|
52
55
|
private
|
53
56
|
def self.from_hex color
|
54
57
|
color.shift if color[0] == '#'
|
55
|
-
r = color[0
|
56
|
-
g = color[2
|
57
|
-
b = color[4
|
58
|
+
r = color[0..1].to_i 16
|
59
|
+
g = color[2..3].to_i 16
|
60
|
+
b = color[4..5].to_i 16
|
58
61
|
|
59
62
|
from_rgb(r, g, b)
|
60
63
|
end
|
@@ -92,6 +95,7 @@ module PaletteTown
|
|
92
95
|
hue += 4
|
93
96
|
end
|
94
97
|
hue /= 6
|
98
|
+
hue *= Math::PI * 2 # Convert 0..1 into radians
|
95
99
|
end
|
96
100
|
return {hue: hue, sat: sat, lum: lum}
|
97
101
|
end
|
data/lib/palettetown/scheme.rb
CHANGED
@@ -24,26 +24,26 @@ module PaletteTown
|
|
24
24
|
end
|
25
25
|
def lighter color, amount
|
26
26
|
color = PaletteTown::Color.new color unless color.is_a? PaletteTown::Color
|
27
|
-
color.lum
|
27
|
+
color.lum *= 1.0 - amount
|
28
28
|
color
|
29
29
|
end
|
30
30
|
def darker color, amount
|
31
31
|
color = PaletteTown::Color.new color unless color.is_a? PaletteTown::Color
|
32
|
-
color.lum
|
32
|
+
color.lum *= 1.0 - amount
|
33
33
|
color
|
34
34
|
end
|
35
35
|
def saturate color, amount
|
36
36
|
color = PaletteTown::Color.new color unless color.is_a? PaletteTown::Color
|
37
|
-
color.sat
|
37
|
+
color.sat *= 1.0 + amount
|
38
38
|
color
|
39
39
|
end
|
40
40
|
def desaturate color, amount
|
41
41
|
color = PaletteTown::Color.new color unless color.is_a? PaletteTown::Color
|
42
|
-
color.sat
|
42
|
+
color.sat *= 1.0 - amount
|
43
43
|
end
|
44
44
|
def spin color, amount
|
45
45
|
color = PaletteTown::Color.new color unless color.is_a? PaletteTown::Color
|
46
|
-
color.hue += amount
|
46
|
+
color.hue += amount
|
47
47
|
color
|
48
48
|
end
|
49
49
|
def hi *options
|
data/lib/palettetown/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: palettetown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Lejeck
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/palettetown.rb
|
70
70
|
- lib/palettetown/cli.rb
|
71
71
|
- lib/palettetown/color.rb
|
72
|
+
- lib/palettetown/monkeypatches.rb
|
72
73
|
- lib/palettetown/rule.rb
|
73
74
|
- lib/palettetown/scheme.rb
|
74
75
|
- lib/palettetown/version.rb
|