#define global SCREEN_PALETTE_MODE   TRUE   // pbgJ[ON
#define global __GENERAL_SAMPLE__
#include "..\\..\\header_general.hsp"       // wb_[ ėp

	scrMain  = ScreenManagerAddScreen()	// CEBhE
	title " [ `̉E[hbO XXP[O ]  wasdŋ`TCY / hbOňړ" 
	
*init
	
	gridSize = 8f, 32f

	; Sel
	bp = 500f, 300f  :   bs = 100f, 100f

*main
	if( ScreenManagerBegin( scrMain ) ){
	
			//***** Obhݒ
			SetGrid@ManipulateUnit   gridSize(0), gridSize(1)
	
			//***** jbgψ XV
			InputGetMousePos mousePos
			Update@ManipulateUnit   mousePos

		;------------------------------------
		
			a = Drag@ManipulateScaling(   isSel, bp, bs, mousePos )
			scalingStat = GetStat@ManipulateScaling()

		if( ScalingStat ){
			
			GetMouseDisp@ManipulateUnit  disp
			
			a = gridSize(0) * disp(0)

			; ޔ
			Vec2Copy pp, bp  :  Vec2Copy ss, bs
				MathExpandBox bp,bs,   bp,bs, a, 4
			; 
			if( bs(0)<gridSize(0)*0.5 ){ Vec2Copy bp, pp  :  Vec2Copy bs, ss }

		} else {

			a = Drag@ManipulatePixelSel(       isSel,   bp,    bs, mousePos, gridSize )
		}

		
		;------------------------------------
		DrawGrid gridSIze

		ColSet _DARK_BLUE : : if( isSel ) : ColSet _LIGHT_BLUE
		ShapeBox    bp,   bs
		

			pos 100f, 50f
			color : mes "scalingStat : " + scalingStat
	
			if( scalingStat ){
				
				CollisionRectSideDraw
			}
			
		Draw@ManipulateScaling

		
		ScreenManagerEnd
	}
    goto *main





;-------------------------------------------------------------------------------------
							// ObhA`
							#deffunc DrawGrid array _gridSize
				
								a = 3.5
								; ObhTCYύX
								if( InputGetKey('A')==1 ) : gridSize(0) - a
								if( InputGetKey('D')==1 ) : gridSize(0) + a
								if( InputGetKey('W')==1 ) : gridSize(1) - a
								if( InputGetKey('S')==1 ) : gridSize(1) + a
				
								ColSet _GRAY
								repeat (1f / _gridSize(0)+1) * ginfo_winx
									xy = _gridSize(0) * cnt + (_gridSize(0)*0.5), 300f
									ShapeLineVecCenter xy, VEC2_UP, 600f
								loop
								repeat (1f / _gridSize(1)+1) * ginfo_winy
									xy = 400f, _gridSize(1) * cnt + (_gridSize(1)*0.5)
									ShapeLineVecCenter xy, VEC2_RIGHT, 800f
								loop
								return