〜 グラフィック 〜
90度単位の回転

HSP3からはgrotate命令で任意の矩形を回転コピーさせることが出来ますが、
HSP2までは用意されていませんでしたので、モジュールで用意してみました。
但し、1ドットずつコピー元バッファを選択してコピーし、
コピー先ウィンドウを選択して1ドット貼り付ける作業を繰り返しますので、非常に低速です。
予めご了承ください。
	

grotate 読込先バッファ, X座標, Y座標, 横幅, 高さ, 方向
読込先バッファコピーするウィンドウIDを指定する
X座標コピーする画像の基点X座標指定する
Y座標コピーする画像の基点Y座標指定する
横幅コピーする画像の横サイズを指定する
高さコピーする画像の縦サイズを指定する
方向反転方向を指定する(0:回転なし 1:90度回転 2:180度回転 3:270度回転転)

 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
#module
#deffunc grotate int, int, int, int, int, int
	mref id, 0 : mref bx, 1 : mref by, 2 : mref sx, 3 : mref sy, 4 : mref direction, 5
	mref bmscr, 67
	act = bmscr.18 // コピー先(アクティブ)ウィンドウを保持
	bcol = bmscr.40 & 0xFF, bmscr.40 >> 8 & 0xFF, bmscr.40 >> 16 & 0xFF
	cx = csrx : cy = csry
	repeat sx * sy
		gsel id
		pget cnt \ sx, cnt / sx
		col = rval, gval, bval
		gsel act
		color col.0, col.1, col.2
		if direction = 0 : pset cx + (cnt \ sx), cy + (cnt / sx)
		if direction = 1 : pset cx + sy - (cnt / sx) - 1, cy + (cnt \ sx)
		if direction = 2 : pset cx + sx - (cnt \ sx) - 1, cy + sy - (cnt / sx) - 1
		if direction = 3 : pset cx + (cnt / sx), cy + sx - (cnt \ sx) - 1
	loop
	pos cx, cy // カレントポジションを戻す
	color bcol.0, bcol.1, bcol.2
	return
#global

	buffer 2
	picload "sample/ssaver/Aruface.bmp"
	gsel 0
	redraw 0
	pos 150,  50 : mes "0度"
	pos 150,  80 : grotate 2, , , 80, 80, 0
	pos 350,  50 : mes "90度"
	pos 350,  80 : grotate 2, , , 80, 80, 1
	pos 150, 300 : mes "180度"
	pos 150, 330 : grotate 2, , , 80, 80, 2
	pos 350, 300 : mes "270度"
	pos 350, 330 : grotate 2, , , 80, 80, 3
	redraw 1
	stop

grotate2 読込先バッファ, X座標, Y座標, 横幅, 高さ, 方向
読込先バッファコピーするウィンドウIDを指定する
X座標コピーする画像の基点X座標指定する
Y座標コピーする画像の基点Y座標指定する
横幅コピーする画像の横サイズを指定する
高さコピーする画像の縦サイズを指定する
方向反転方向を指定する(0:回転なし 1:90度回転 2:180度回転 3:270度回転転)

 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
#module
#deffunc grotate2 int id, int bx, int by, int sx, int sy, int dir, local act, local bcol, local cx, local cy
	act = ginfo_act : bcol = ginfo_r, ginfo_g, ginfo_b
	cx = ginfo_cx : cy = ginfo_cy
	repeat sx * sy
		gsel id
		pget cnt \ sx, cnt / sx
		col = ginfo_r, ginfo_g, ginfo_b
		gsel act
		color col.0, col.1, col.2
		if dir = 0 : pset cx + (cnt \ sx), cy + (cnt / sx)
		if dir = 1 : pset cx + sy - (cnt / sx) - 1, cy + (cnt \ sx)
		if dir = 2 : pset cx + sx - (cnt \ sx) - 1, cy + sy - (cnt / sx) - 1
		if dir = 3 : pset cx + (cnt / sx), cy + sx - (cnt \ sx) - 1
	loop
	pos cx, cy // カレントポジションを戻す
	color bcol.0, bcol.1, bcol.2
	return
#global

	buffer 2
	picload "sample/demo/onibtn.gif"
	gsel 0
	redraw 0
	pos 150,  50 : mes "0度"
	pos 150,  80 : grotate2 2, , , 136, 50, 0
	pos 350,  50 : mes "90度"
	pos 350,  80 : grotate2 2, , , 136, 50, 1
	pos 150, 300 : mes "180度"
	pos 150, 330 : grotate2 2, , , 136, 50, 2
	pos 350, 300 : mes "270度"
	pos 350, 330 : grotate2 2, , , 136, 50, 3
	redraw 1