pixelart 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/lib/pixelart/base.rb +3 -0
- data/lib/pixelart/image.rb +9 -6
- data/lib/pixelart/vector.rb +55 -0
- data/lib/pixelart/version.rb +1 -1
- data/lib/pixelart.rb +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e407d45e71520e9e7c34448811a80e796254aba70c791e3497df00b0fa700486
|
4
|
+
data.tar.gz: 55c324e6cf901bd8ed78fa48d97f27a3f66c60d314d070a457ef4e272ebe9f01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e36d0cb47e5e36b81b3a3f47d62fa119b898f9bbf11c422d53f5ab3cfdfe022a8f3dda3d82ea1db4f2eb422376ea82ac153922add94caeb5aff97214813a81a
|
7
|
+
data.tar.gz: b8957560272efd295ef73bdd450531dc9d631fd293215dbd0f9f835bdbdb50669018f1d24a27a6df45d8714a2633bc1d22a6b6761979dc7804b3c5290c2f1eaa
|
data/Rakefile
CHANGED
data/lib/pixelart/base.rb
CHANGED
data/lib/pixelart/image.rb
CHANGED
@@ -64,18 +64,21 @@ end
|
|
64
64
|
|
65
65
|
|
66
66
|
|
67
|
-
def zoom( zoom=2 )
|
67
|
+
def zoom( zoom=2, spacing: 0 )
|
68
68
|
## create a new zoom factor x image (2x, 3x, etc.)
|
69
69
|
|
70
|
-
|
71
|
-
|
70
|
+
width = @img.width*zoom+(@img.width-1)*spacing
|
71
|
+
height = @img.height*zoom+(@img.height-1)*spacing
|
72
72
|
|
73
|
-
|
74
|
-
|
73
|
+
img = Image.new( width, height )
|
74
|
+
|
75
|
+
@img.width.times do |x|
|
76
|
+
@img.height.times do |y|
|
75
77
|
pixel = @img[x,y]
|
76
78
|
zoom.times do |n|
|
77
79
|
zoom.times do |m|
|
78
|
-
img[n+zoom*x
|
80
|
+
img[n+zoom*x+spacing*x,
|
81
|
+
m+zoom*y+spacing*y] = pixel
|
79
82
|
end
|
80
83
|
end
|
81
84
|
end # each x
|
data/lib/pixelart/vector.rb
CHANGED
@@ -25,6 +25,53 @@ class Vector # holds a vector graphics image (in source)
|
|
25
25
|
end
|
26
26
|
end # class Circle
|
27
27
|
|
28
|
+
class Path < Shape
|
29
|
+
def initialize( fill:, stroke: )
|
30
|
+
@commands = []
|
31
|
+
@fill = fill
|
32
|
+
@stroke = stroke
|
33
|
+
end
|
34
|
+
|
35
|
+
def move_to( x, y ) ## add a move_to instruction
|
36
|
+
@commands << ['M', x, y]
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
def line_to( x, y )
|
41
|
+
@commands << ['L', x, y]
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
def line( *coords ) ## move_to/line_to all-in-one shortcut
|
46
|
+
## todo/check - assert coords has at least two x/y pairs - why? why not?
|
47
|
+
move_to( *coords[0..1] )
|
48
|
+
coords[2..-1].each_slice( 2) do |coord|
|
49
|
+
line_to( *coord )
|
50
|
+
end
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
def to_svg
|
57
|
+
buf = %Q{<path style="stroke: #{@stroke}; fill: #{@fill || 'none'};" }
|
58
|
+
buf << %Q{d="}
|
59
|
+
last_command = ''
|
60
|
+
@commands.each_with_index do |command,i|
|
61
|
+
buf << " " if i > 0 # add space separator
|
62
|
+
|
63
|
+
## "optimize" - that is, do not repead command if same as before
|
64
|
+
buf << command[0] if command[0] != last_command
|
65
|
+
buf << "#{command[1]} #{command[2]}"
|
66
|
+
last_command = command[0]
|
67
|
+
end
|
68
|
+
|
69
|
+
buf << %Q{"}
|
70
|
+
buf << "/>"
|
71
|
+
buf
|
72
|
+
end
|
73
|
+
end # class Path
|
74
|
+
|
28
75
|
|
29
76
|
|
30
77
|
def initialize( width, height, header: nil )
|
@@ -39,6 +86,14 @@ class Vector # holds a vector graphics image (in source)
|
|
39
86
|
@shapes << Circle.new( cx, cy, r, fill: fill )
|
40
87
|
end
|
41
88
|
|
89
|
+
## note: default stroke (color) to black (#000000) for now - why? why not?
|
90
|
+
def path( stroke: '#000000', fill: nil )
|
91
|
+
path = Path.new( stroke: stroke, fill: fill )
|
92
|
+
@shapes << path
|
93
|
+
|
94
|
+
path ## note: MUST return "inner" path shape for chaining "dsl-like" methods / commands
|
95
|
+
end
|
96
|
+
|
42
97
|
|
43
98
|
|
44
99
|
def to_image
|
data/lib/pixelart/version.rb
CHANGED
data/lib/pixelart.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixelart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chunky_png
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: csvreader
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rdoc
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|