@@ -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
8383else
8484
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
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 )
125125end
126126
127127obj.effect("クリッピング", "上", top + crop[1], "下", h - bottom - 1 + crop[2], "左", left + crop[3], "右", w - right - 1 + crop[4], "中心の位置を変更", chk)
0 commit comments