resedit 1.3.3 → 1.4
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/lib/resedit.rb +1 -1
- data/lib/resedit/font/font.rb +9 -4
- data/lib/resedit/font/font_char.rb +30 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6ddbe66a77c0195afafaaff1c2756e915f38614
|
4
|
+
data.tar.gz: c97154c36b5753121497f2d01ef6ce38fc0d1fc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9d0e7a836d85b455f4b2172b4d891f9f938f55c38b275f8e7aaa0c88e36b362e9bb4601927fed859a48c1a2767f414092f1adc38672f115e84e1633cdf10127
|
7
|
+
data.tar.gz: 60b8f1b47633ea8520649b2be11592ec057e53f682caa1e98cb3ca5a9ab2429d7e20111d8a6a2f687a39e0ad994877ce1a58cf0cfabbea643f39ebb4accf2874
|
data/lib/resedit.rb
CHANGED
data/lib/resedit/font/font.rb
CHANGED
@@ -5,7 +5,7 @@ module Resedit
|
|
5
5
|
|
6
6
|
class Font
|
7
7
|
attr_reader :count, :width, :height
|
8
|
-
attr_accessor :gridColor, :charColor, :userData, :widthColor
|
8
|
+
attr_accessor :gridColor, :charColor, :userData, :widthColor, :bgColor
|
9
9
|
|
10
10
|
# charWidth, charHeight, characters count
|
11
11
|
def initialize(width, height, count=256)
|
@@ -18,9 +18,9 @@ module Resedit
|
|
18
18
|
@userData = nil
|
19
19
|
end
|
20
20
|
|
21
|
-
def setChar(id, data, width=nil)
|
21
|
+
def setChar(id, data, width=nil, flags=nil)
|
22
22
|
width=@width if !width
|
23
|
-
@chars[id] = FontChar.new(@width, @height, id, data, width)
|
23
|
+
@chars[id] = FontChar.new(@width, @height, id, data, width, flags)
|
24
24
|
end
|
25
25
|
|
26
26
|
def getChar(id)
|
@@ -40,6 +40,11 @@ module Resedit
|
|
40
40
|
return @chars[id].realWidth ? @chars[id].realWidth : @width
|
41
41
|
end
|
42
42
|
|
43
|
+
def charFlags(id)
|
44
|
+
return nil if !@chars[id]
|
45
|
+
return @chars[id].flags
|
46
|
+
end
|
47
|
+
|
43
48
|
def save(filename)
|
44
49
|
rows = @count/16 + (@count%16 == 0 ? 0 : 1)
|
45
50
|
img = Resedit.createImage(@width*16+17 , @height*rows+rows+1, filename)
|
@@ -72,7 +77,7 @@ module Resedit
|
|
72
77
|
x += 1+x*@width
|
73
78
|
y += 1+y*@height
|
74
79
|
c = FontChar.new(width,height,idx)
|
75
|
-
c.scan(img, @charColor, x, y, @widthColor)
|
80
|
+
c.scan(img, @charColor, x, y, @widthColor, [@bgColor, @gridColor])
|
76
81
|
@chars[c.index] = c if c.data
|
77
82
|
end
|
78
83
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module Resedit
|
2
2
|
|
3
3
|
class FontChar
|
4
|
-
attr_accessor :index, :data, :realWidth
|
4
|
+
attr_accessor :index, :data, :realWidth, :flags
|
5
5
|
|
6
|
-
def initialize(width, height, index, data=nil, realWidth=nil)
|
6
|
+
def initialize(width, height, index, data=nil, realWidth=nil, flags=nil)
|
7
7
|
@width, @height, @index = width, height, index
|
8
8
|
@realWidth=realWidth
|
9
|
+
@flags = flags
|
9
10
|
@data=data if (data && data.length==width*height)
|
10
11
|
end
|
11
12
|
|
@@ -19,12 +20,34 @@ module Resedit
|
|
19
20
|
image.setPixel(x+i, y+j, color) if hasPixel(i,j)
|
20
21
|
end
|
21
22
|
end
|
22
|
-
if @realWidth
|
23
|
-
image.setPixel(x
|
23
|
+
if @realWidth
|
24
|
+
image.setPixel(x+@realWidth, y, wColor)
|
25
|
+
end
|
26
|
+
if @flags && @flags.length>0
|
27
|
+
for i in 0..@flags.length-1
|
28
|
+
image.setPixel(x+@realWidth, y+i+1, @flags[i])
|
29
|
+
end
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
27
|
-
def
|
33
|
+
def readFlags(image, x, y, bgcolors)
|
34
|
+
empty = true
|
35
|
+
flags = []
|
36
|
+
for i in 0..@height-2
|
37
|
+
flags += [bgcolors[0]]
|
38
|
+
col = image.getPixel(x, y+i)
|
39
|
+
if bgcolors.include?(col)
|
40
|
+
next
|
41
|
+
end
|
42
|
+
empty=false
|
43
|
+
flags[i] = col
|
44
|
+
end
|
45
|
+
return nil if empty
|
46
|
+
return flags
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def scan(image, color, x, y, wColor, bgcolors)
|
28
51
|
@data=[0]*@width*@height
|
29
52
|
@realWidth = nil
|
30
53
|
_hasData = false
|
@@ -40,6 +63,8 @@ module Resedit
|
|
40
63
|
end
|
41
64
|
end
|
42
65
|
end
|
66
|
+
fx = x + (@realWidth ? @realWidth : @width)
|
67
|
+
@flags = readFlags(image, fx, y+1, bgcolors)
|
43
68
|
@data=nil if !_hasData
|
44
69
|
return @data!=nil
|
45
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resedit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bjfn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chunky_png
|