#module
#deffunc grdbox int x1, int y1, int x2, int y2, int dir, int er, int eg, int eb, local x, local y, local count, local r, local g, local b, local sr, local sg, local sb
// 上下左右逆転している場合の補正とサイズ取得(0:小 1:大 2:サイズ)
if x1 > x2 : x = x2, x1, x1 - x2 : else : x = x1, x2, x2 - x1
if y1 > y2 : y = y2, y1, y1 - y2 : else : y = y1, y2, y2 - y1
// 開始色(カレントカラー)の取得
mref bmscr, 67
sr = bmscr.40 & 0xFF : sg = bmscr.40 >> 8 & 0xFF : sb = bmscr.40 >> 16 & 0xFF
// 繰り返し回数(描画処理数)
if dir = 0 | dir = 1 : count = x.1 - x.0
if dir = 2 | dir = 3 : count = y.1 - y.0
if dir >= 4 : count = x.2 + y.2 : x.1 = x : y.1 = y
// 描画
repeat count
if dir = 0 | dir = 1 : x.0++ : y.0 = y1 : x.1 = x.0 : y.1 = y2
if dir = 2 | dir = 3 : x.0 = x1 : y.0++ : x.1 = x2 : y.1 = y.0
if dir >= 4 {
if y.2 > cnt : x.0 = x1 : y.0++ : else : x.0++ : y.0 = y2
if x.2 > cnt : x.1++ : y.1 = y1 : else : x.1 = x2: y.1++
}
r = limit((er - sr) * cnt / (count - 1) + sr, 0, 255)
g = limit((eg - sg) * cnt / (count - 1) + sg, 0, 255)
b = limit((eb - sb) * cnt / (count - 1) + sb, 0, 255)
color r, g, b : line x.0, y.0, x.1, y.1
loop
if dir = 1 | dir = 5 : pos x2 + 1, y1 : gzoom -x.2 - 1, y.2, ginfo_act, x1, y1, x.2, y.2
if dir = 3 | dir = 6 : pos x1, y2 + 1 : gzoom x.2, -y.2 - 1, ginfo_act, x1, y1, x.2, y.2
if dir = 7 : pos x1, y1 : gzoom x.2 + 1, y.2 + 1, ginfo_act, x.1, y.1, -x.2 - 1, -y.2 - 1
color sr, sg, sb // 元の色に戻す
return
#global
color 255, 128
redraw 0
grdbox 10, 10, 210, 150, 0, 255, 0, 255 // 左から右にグラデーション
grdbox 220, 10, 420, 150, 1, 255, 0, 255 // 右から左にグラデーション
grdbox 430, 10, 630, 150, 2, 255, 0, 255 // 上から下にグラデーション
grdbox 10, 160, 210, 300, 3, 255, 0, 255 // 下から上にグラデーション
grdbox 220, 160, 420, 300, 4, 255, 0, 255 // 左上から右下にグラデーション
grdbox 430, 160, 630, 300, 5, 255, 0, 255 // 右上から左下にグラデーション
grdbox 10, 310, 210, 450, 6, 255, 0, 255 // 左下から右上にグラデーション
grdbox 220, 310, 420, 450, 7, 255, 0, 255 // 右下から左上にグラデーション
redraw 1
|