Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Commit 4af2e28

Browse files
authored
Merge pull request #1 from sigma-axis/main
既に透明と分かっているピクセル領域を検索から除外.
2 parents 1f5334d + baf67d0 commit 4af2e28

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

AutoClipping_M.anm

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ if jit ~= nil then
5656
return -1
5757
end
5858

59-
local function get_top(cdata, w, h)
60-
for y = 0, h - 1 do for x = 0, w - 1 do
59+
local function get_top(cdata, w, h, left, right)
60+
for y = 0, h - 1 do for x = left, right do
6161
if (cdata + x + y * w).a ~= 0 then return y end
6262
end end
6363
return -1
6464
end
6565

66-
local function get_bottom(cdata, w, h)
67-
for y = h - 1, 0, -1 do for x = 0, w - 1 do
66+
local function get_bottom(cdata, w, h, left, right)
67+
for y = h - 1, 0, -1 do for x = left, right do
6868
if (cdata + x + y * w).a ~= 0 then return y end
6969
end end
7070
return -1
@@ -77,8 +77,8 @@ if jit ~= nil then
7777
return
7878
end
7979
right = get_right(cdata, w, h)
80-
top = get_top(cdata, w, h)
81-
bottom = get_bottom(cdata, w, h)
80+
top = get_top(cdata, w, h, left, right)
81+
bottom = get_bottom(cdata, w, h, left, right)
8282

8383
else
8484

@@ -99,16 +99,16 @@ else
9999
return -1
100100
end
101101

102-
local function get_top(w, h)
103-
for y = 0, h - 1 do for x = 0, w - 1 do
102+
local function get_top(w, h, left, right)
103+
for y = 0, h - 1 do for x = left, right do
104104
local col, a = obj.getpixel(x, y, "col")
105105
if a ~= 0 then return y end
106106
end end
107107
return -1
108108
end
109109

110-
local function get_bottom(w, h)
111-
for y = h - 1, 0, -1 do for x = 0, w - 1 do
110+
local function get_bottom(w, h, left, right)
111+
for y = h - 1, 0, -1 do for x = left, right do
112112
local col, a = obj.getpixel(x, y, "col")
113113
if a ~= 0 then return y end
114114
end end
@@ -120,8 +120,8 @@ else
120120
return
121121
end
122122
right = get_right(w, h)
123-
top = get_top(w, h)
124-
bottom = get_bottom(w, h)
123+
top = get_top(w, h, left, right)
124+
bottom = get_bottom(w, h, left, right)
125125
end
126126

127127
obj.effect("クリッピング", "上", top + crop[1], "下", h - bottom - 1 + crop[2], "左", left + crop[3], "右", w - right - 1 + crop[4], "中心の位置を変更", chk)

0 commit comments

Comments
 (0)