scale 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scale.rb +5 -1
- data/lib/scale/node.rb +6 -1
- data/lib/scale/shapes/line.rb +13 -0
- data/lib/scale/shapes/path.rb +40 -0
- data/lib/scale/shapes/polygon.rb +10 -0
- data/lib/scale/shapes/polyline.rb +10 -0
- data/lib/scale/shapes/rectangle.rb +3 -0
- data/lib/scale/text.rb +12 -0
- data/lib/scale/version.rb +1 -1
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6db10add3a6a7cb43dd0aaeab42c7ab03db0015c
|
4
|
+
data.tar.gz: a9c78645146671badd41ca7d72298b1d28853ea0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a49b92c1193a9cc392b9b63f00991e0c2cd0d72c04a4fb37d2995614e6f98f9ed4f36c3d1bb25d975073ce39a43a4d06d2f6f6ff3ecb5501d5d0e49dd10846a3
|
7
|
+
data.tar.gz: c9eeb380134d3539cdf995f0def378734d4861fe95c6f7a1d15ae798a09c36be7fd0f88d68a3d1175eb1e4d50ffca1df087879b53e8c85ef8e4d19811e92d1f2
|
data/lib/scale.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
require "scale/version"
|
2
2
|
require "scale/node"
|
3
3
|
require "scale/svg"
|
4
|
-
require "scale/shapes/rectangle"
|
5
4
|
require "scale/shapes/circle"
|
6
5
|
require "scale/shapes/ellipse"
|
6
|
+
require "scale/shapes/line"
|
7
|
+
require "scale/shapes/path"
|
8
|
+
require "scale/shapes/polygon"
|
9
|
+
require "scale/shapes/polyline"
|
10
|
+
require "scale/shapes/rectangle"
|
7
11
|
require "scale/text"
|
8
12
|
require "scale/dsl"
|
9
13
|
|
data/lib/scale/node.rb
CHANGED
@@ -5,6 +5,7 @@ module Scale
|
|
5
5
|
include Enumerable
|
6
6
|
include Virtus.module
|
7
7
|
attr_reader :content
|
8
|
+
attribute :style, String
|
8
9
|
|
9
10
|
def children
|
10
11
|
@children ||= []
|
@@ -36,7 +37,11 @@ module Scale
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def xml_attributes
|
39
|
-
attributes.
|
40
|
+
attributes.inject({}) do |memo, (key, value)|
|
41
|
+
new_key = key.to_s.gsub(/\_/, "-").to_sym
|
42
|
+
memo[new_key] = value unless value.nil?
|
43
|
+
memo
|
44
|
+
end
|
40
45
|
end
|
41
46
|
|
42
47
|
private
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Scale
|
2
|
+
class Line
|
3
|
+
include Node
|
4
|
+
attribute :x1, Integer # the x position of point 1
|
5
|
+
attribute :y1, Integer # the y position of point 1
|
6
|
+
attribute :x2, Integer # the x position of point 2
|
7
|
+
attribute :y2, Integer # the y position of point 2
|
8
|
+
|
9
|
+
def xml_tag
|
10
|
+
:line
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Scale
|
2
|
+
class Path
|
3
|
+
include Node
|
4
|
+
attribute :d, String
|
5
|
+
|
6
|
+
def move_to(x:, y:)
|
7
|
+
command("M#{x} #{y}")
|
8
|
+
end
|
9
|
+
|
10
|
+
def line_to(x:, y:)
|
11
|
+
command("L #{x} #{y}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def horizontal(n, relative: false)
|
15
|
+
command("#{relative ? "h" : "H"} #{n}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def vertical(n, relative: false)
|
19
|
+
command("#{relative ? "v" : "V"} #{n}")
|
20
|
+
end
|
21
|
+
|
22
|
+
def close_path
|
23
|
+
command("Z")
|
24
|
+
end
|
25
|
+
|
26
|
+
def xml_tag
|
27
|
+
:path
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def command(instructions)
|
33
|
+
if self.d.nil?
|
34
|
+
self.d = instructions
|
35
|
+
else
|
36
|
+
self.d = "#{self.d} #{instructions}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -4,6 +4,9 @@ module Scale
|
|
4
4
|
attribute :width, String
|
5
5
|
attribute :height, String
|
6
6
|
attribute :fill, String
|
7
|
+
attribute :fill_opactiy, String
|
8
|
+
attribute :stroke, String
|
9
|
+
attribute :stroke_opacity, String
|
7
10
|
attribute :x, Integer
|
8
11
|
attribute :y, Integer
|
9
12
|
attribute :rx, Integer
|
data/lib/scale/text.rb
CHANGED
@@ -4,6 +4,18 @@ module Scale
|
|
4
4
|
attribute :x, Integer
|
5
5
|
attribute :y, Integer
|
6
6
|
|
7
|
+
attribute :font_family, String
|
8
|
+
attribute :font_style, String
|
9
|
+
attribute :font_weight, String
|
10
|
+
attribute :font_variant, String
|
11
|
+
attribute :font_stretch, String
|
12
|
+
attribute :font_size, String
|
13
|
+
attribute :font_size_adjust, String
|
14
|
+
attribute :kerning, String
|
15
|
+
attribute :letter_spacing, String
|
16
|
+
attribute :word_spacing, String
|
17
|
+
attribute :text_decoration, String
|
18
|
+
|
7
19
|
def initialize(text, attributes = {})
|
8
20
|
@content = text
|
9
21
|
super(attributes)
|
data/lib/scale/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mo khan
|
@@ -105,6 +105,10 @@ files:
|
|
105
105
|
- lib/scale/node.rb
|
106
106
|
- lib/scale/shapes/circle.rb
|
107
107
|
- lib/scale/shapes/ellipse.rb
|
108
|
+
- lib/scale/shapes/line.rb
|
109
|
+
- lib/scale/shapes/path.rb
|
110
|
+
- lib/scale/shapes/polygon.rb
|
111
|
+
- lib/scale/shapes/polyline.rb
|
108
112
|
- lib/scale/shapes/rectangle.rb
|
109
113
|
- lib/scale/svg.rb
|
110
114
|
- lib/scale/text.rb
|