15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/comic_walker/item_decoder/unknown.rb', line 15
def calculate_moves(width, height, rect_width, rect_height, pattern)
wcnt = width / rect_width
hcnt = height / rect_height
width %= rect_width
height %= rect_height
moves = []
w_t0 = wcnt - (43*pattern)%wcnt
w_t1 =
if w_t0 % wcnt == 0
(wcnt - 4) % wcnt
else
w_t0
end
h_t0 = hcnt - 47 * pattern % hcnt;
h_t1 =
if h_t0 % hcnt == 0
(hcnt - 4) % hcnt
else
h_t0;
end
if width > 0 && height > 0
x = w_t1 * rect_width
y = h_t1 * rect_height
moves.push(srcX: x, srcY: y, destX: x, destY: y, width: width, height: height)
end
if height > 0
wcnt.times do |j|
l = calcXCoordinateXRest_(j, wcnt, pattern)
k = calcYCoordinateXRest_(l, w_t1, h_t1, hcnt, pattern)
destX = calcPositionWithRest_(l, w_t1, width, rect_width)
destY = k * rect_height
srcX = calcPositionWithRest_(j, w_t1, width, rect_width)
srcY = h_t1 * rect_height
moves.push(srcX: srcX, srcY: srcY, destX: destX, destY: destY, width: rect_width, height: height)
end
end
if width > 0
hcnt.times do |i|
k = calcYCoordinateYRest_(i, hcnt, pattern)
l = calcXCoordinateYRest_(k, w_t1, h_t1, wcnt, pattern)
destX = l * rect_width
destY = calcPositionWithRest_(k, h_t1, height, rect_height)
srcX = w_t1 * rect_width
srcY = calcPositionWithRest_(i, h_t1, height, rect_height)
moves.push(srcX: srcX, srcY: srcY, destX: destX, destY: destY, width: width, height: rect_height)
end
end
wcnt.times do |j|
hcnt.times do |i|
p = (j + 29 * pattern + 31 * i) % wcnt
k = (i + 37 * pattern + 41 * p) % hcnt
q = p >= calcXCoordinateYRest_(k, w_t1, h_t1, wcnt, pattern) ? width : 0
m = k >= calcYCoordinateXRest_(p, w_t1, h_t1, hcnt, pattern) ? height : 0
destX = p * rect_width + q
destY = k * rect_height + m
srcX = j * rect_width + (j >= w_t1 ? width : 0)
srcY = i * rect_height + (i >= h_t1 ? height : 0)
moves.push(srcX: srcX, srcY: srcY, destX: destX, destY: destY, width: rect_width, height: rect_height)
end
end
moves
end
|