pixelart 0.2.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +1 -0
- data/lib/pixelart/base.rb +2 -2
- data/lib/pixelart/sketch.rb +69 -0
- data/lib/pixelart/version.rb +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c77200956faad2093e12cba99a8f8a3339941e612406701a795eecdcdd8248d8
|
4
|
+
data.tar.gz: d3dfbf4c9d278db95219b695dc55cea1b31debd8b5a08a20305135526d3618d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db9abc2122d9727e2fee58c54913174983ff3dd03d2e2658c4b0a84d80114f0f482673d2b7e51fea61dbbb423f1df05eb5e027ba51d741ab86dc7e16d6f2eb72
|
7
|
+
data.tar.gz: 36c0733c3c5e15f18cca6787185eb2229fa8d7a98c3d037cf781295b8d32fc74be542a433de1504981afb984d9234730191dcf14443b3f614cd3dc9139d4fa7e
|
data/Manifest.txt
CHANGED
data/lib/pixelart/base.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
module Pixelart
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
class Image
|
6
|
+
def sketch( sketch=4, line: 1 )
|
7
|
+
# todo: line - find a better name eg. line_strenght/width or such?
|
8
|
+
width = @img.width*sketch + (@img.width+1)*line
|
9
|
+
height = @img.height*sketch + (@img.height+1)*line
|
10
|
+
|
11
|
+
puts " #{width}x#{height}"
|
12
|
+
|
13
|
+
img = Image.new( width, height, Color::WHITE )
|
14
|
+
|
15
|
+
@img.width.times do |x|
|
16
|
+
@img.height.times do |y|
|
17
|
+
pixel = @img[x,y]
|
18
|
+
|
19
|
+
## get surrounding pixels - if "out-of-bound" use transparent (0)
|
20
|
+
left = x == 0 ? Color::TRANSPARENT : @img[x-1,y]
|
21
|
+
top = y == 0 ? Color::TRANSPARENT : @img[x ,y-1]
|
22
|
+
|
23
|
+
if pixel != left ## draw vertical line
|
24
|
+
(sketch+line*2).times do |n|
|
25
|
+
line.times do |m|
|
26
|
+
img[ x*sketch + line*x + m,
|
27
|
+
n + y*sketch + line*y] = Color::BLACK
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if pixel != top ## draw horizontal line
|
33
|
+
(sketch+line*2).times do |n|
|
34
|
+
line.times do |m|
|
35
|
+
img[n + x*sketch + line*x,
|
36
|
+
y*sketch + line*y + m] = Color::BLACK
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
## check special edge case for x and y to add "finish-up" right and bottom line
|
43
|
+
if x == @img.width-1 && pixel != Color::TRANSPARENT
|
44
|
+
## draw vertical line
|
45
|
+
(sketch+line*2).times do |n|
|
46
|
+
line.times do |m|
|
47
|
+
img[ (x+1)*sketch + line*(x+1) + m,
|
48
|
+
n + y*sketch + line*y] = Color::BLACK
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
if y== @img.height-1 && pixel != Color::TRANSPARENT
|
54
|
+
## draw horizontal line
|
55
|
+
(sketch+line*2).times do |n|
|
56
|
+
line.times do |m|
|
57
|
+
img[n + x*sketch + line*x,
|
58
|
+
(y+1)*sketch + line*(y+1) + m] = Color::BLACK
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
img
|
66
|
+
end
|
67
|
+
end # class Image
|
68
|
+
end # module Pixelart
|
69
|
+
|
data/lib/pixelart/version.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: 0.
|
4
|
+
version: 1.0.0
|
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-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chunky_png
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/pixelart/misc.rb
|
83
83
|
- lib/pixelart/palette.rb
|
84
84
|
- lib/pixelart/pixelator.rb
|
85
|
+
- lib/pixelart/sketch.rb
|
85
86
|
- lib/pixelart/version.rb
|
86
87
|
homepage: https://github.com/rubycoco/pixel
|
87
88
|
licenses:
|