〜 グラフィック 〜
グラデーションボックスを描画

標準命令に矩形を塗りつぶすものがありますが、単色です。
ある色から異なる色へと徐々に変化するグラデーションによる塗りつぶしがあってもよいだろう
と思い立ったことからモジュールによる命令にしたものがサンプルの命令です。
使用するパラメータはboxf命令よりややこしく、line命令による連続した線描画により時間が掛かります。
若干のデメリットもありますが、コレを参考によりよい命令を作ってみてください。
	

grdbox 左上X, 左上Y, 右下X, 右下Y, 方向, 終了R, 終了G, 終了B
左上X矩形左上のX座標を指定する。
左上Y矩形左上のY座標を指定する。
右下X矩形右下のX座標を指定する。
右下Y矩形右下のY座標を指定する。
方向グラデーションする方向を指定する。
 0で左から右へ、1で右から左へ、
 2で上から下へ、3で下から上へ、
 4で左上から右下へ、5で右上から左下へ、
 6で左下から右上へ、7で右下から左上へカレントカラーから終了RGBに変わっていく。
終了R一番終端に描画する色の赤輝度を指定する。
終了G一番終端に描画する色の緑輝度を指定する。
終了B一番終端に描画する色の青輝度を指定する。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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
#module
#deffunc grdbox int, int, int, int, int, int, int, int
	mref x1, 0 : mref y1, 1 : mref x2, 2 : mref y2, 3 : mref direction, 4 : mref er, 5 : mref eg, 6 : mref eb, 7
	// 上下左右逆転している場合の補正とサイズ取得(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 (direction = 0) | (direction = 1) : count = x.1 - x.0
	if (direction = 2) | (direction = 3) : count = y.1 - y.0
	if direction >= 4 : count = x.2 + y.2 : x.1 = x : y.1 = y
	// 描画
	repeat count
		if (direction = 0) | (direction = 1) : x.0++ : y.0 = y1 : x.1 = x.0 : y.1 = y2
		if (direction = 2) | (direction = 3) : x.0 = x1 : y.0++ : x.1 = x2 : y.1 = y.0
		if direction >= 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 = (er - sr) * cnt / (count - 1) + sr : if r < 0 : r = 0 : else : if r > 255 : r = 255
		g = (eg - sg) * cnt / (count - 1) + sg : if g < 0 : g = 0 : else : if g > 255 : g = 255
		b = (eb - sb) * cnt / (count - 1) + sb : if b < 0 : b = 0 : else : if b > 255 : b = 255
		color r, g, b : line x.0, y.0, x.1, y.1
	loop
	ginfo 1
	if (direction = 1) | (direction = 5) : pos x2 + 1, y1 : gzoom -x.2 - 1, y.2, prmy, x1, y1, x.2, y.2
	if (direction = 3) | (direction = 6) : pos x1, y2 + 1 : gzoom x.2, -y.2 - 1, prmy, x1, y1, x.2, y.2
	if direction = 7 : pos x1, y1 : gzoom x.2 + 1, y.2 + 1, prmy, 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
	stop

grdbox 左上X, 左上Y, 右下X, 右下Y, 方向, 終了R, 終了G, 終了B
左上X矩形左上のX座標を指定する。
左上Y矩形左上のY座標を指定する。
右下X矩形右下のX座標を指定する。
右下Y矩形右下のY座標を指定する。
方向グラデーションする方向を指定する。
 0で左から右へ、1で右から左へ、
 2で上から下へ、3で下から上へ、
 4で左上から右下へ、5で右上から左下へ、
 6で左下から右上へ、7で右下から左上へカレントカラーから終了RGBに変わっていく。
終了R一番終端に描画する色の赤輝度を指定する。
終了G一番終端に描画する色の緑輝度を指定する。
終了B一番終端に描画する色の青輝度を指定する。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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
#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