(AGK version: 2019.12.17)
Submitted: 2020-04-05 04:30:53
SetScreenResolution(1000, 1000)
Setvirtualresolution(1000, 1000)
SetVSync(1) `use whatever framerate is preferred by the platform
SetScissor(0, 0, 0, 0) `use the maximum available screen space, no black borders
UseNewDefaultFonts(1)
SetPrintColor(0, 0, 0)

`"Menu.png" = CC0 image from https://opengameart.org/content/beach-background
LoadImageResized(1, "Menu.png", 0.625, 0.625, 0) `scaled down to 1000x1000.

`sprite to morph via UV manipulation
CreateSprite(1, 1) 

`visualization texture
CreateSprite(2, 1) 
SetSpriteScale(2, 0.5, 0.5)
SetSpritePosition(2, 250, 250)
SetSpriteColorAlpha(2, 127)
SetSpriteVisible(2, 0)

#Constant KEY_SPACE 32
#Constant KEY_ENTER 13
#Constant KEY_SHIFT 16

Local intSelectedVertex as Integer = 1 

u1# = 0.0
v1# = 0.0

u2# = 0.0
v2# = 1.0

u3# = 1.0
v3# = 0.0

u4# = 1.0
v4# = 1.0

Do
	`display information text
	`-----------------------------
	Select intSelectedVertex
		Case 1 `(upper left)
			Print("Selected Vertex: 1, upper-left (" + Str(u1#, 2) + ", " + Str(v1#, 2) + ")")
		EndCase
		
		Case 2 `(lower left)
			Print("Selected Vertex: 2, lower-left (" + Str(u2#, 2) + ", " + Str(v2#, 2) + ")")		
		EndCase
			
		Case 3 `(upper right)
			Print("Selected Vertex: 3, upper-right (" + Str(u3#, 2) + ", " + Str(v3#, 2) + ")")
		EndCase
		
		Case 4 `(lower right)
			Print("Selected Vertex: 4, lower-right (" + Str(u4#, 2) + ", " + Str(v4#, 2) + ")")
		EndCase
	EndSelect
	
	Print("Click the image to set vertex #" + Str(intSelectedVertex)  + " to (" + Str((GetRawMouseX() - 250) / 500.0, 2) + ", " + Str((GetRawMouseY() - 250) / 500.0, 2) + ")")
	Print("Press [space] or scroll mouse-wheel to select next vertex")
	Print("Hold [shift] to see texture visualization")
	Print("Press [enter] to reset vertices")
	`-----------------------------
	
	
	`select next vertex
	`-----------------------------
	If GetRawKeyPressed(KEY_SPACE)
		Inc intSelectedVertex
		If intSelectedVertex > 4 Then intSelectedVertex = 1
	EndIf
	
	MouseWheelDelta = GetRawMouseWheelDelta ()
	If MouseWheelDelta > 0 
		Inc intSelectedVertex
		If intSelectedVertex > 4 Then intSelectedVertex = 1
	ElseIf MouseWheelDelta < 0 
		Dec intSelectedVertex
		If intSelectedVertex < 1 Then intSelectedVertex = 4
	EndIf
	`-----------------------------
	
	
	`set selected vertex's UV value based on cursor position.
	`-----------------------------
	If GetRawMouseLeftState()
		Select intSelectedVertex
			Case 1 `(upper left)
				u1# = (GetRawMouseX() - 250) / 500.0
				v1# = (GetRawMouseY() - 250) / 500.0
			EndCase
			
			Case 2 `(lower left)
				u2# = (GetRawMouseX() - 250) / 500.0
				v2# = (GetRawMouseY() - 250) / 500.0
			EndCase
				
			Case 3 `(upper right)
				u3# = (GetRawMouseX() - 250) / 500.0
				v3# = (GetRawMouseY() - 250) / 500.0
			EndCase
			
			Case 4 `(lower right)
				u4# = (GetRawMouseX() - 250) / 500.0
				v4# = (GetRawMouseY() - 250) / 500.0
			EndCase
		EndSelect
			
		SetSpriteUV(1, u1#, v1#, u2#, v2#, u3#, v3#, u4#, v4#)
	EndIf
	`-----------------------------
	
	
	`reset sprite's UV back to default
	`-----------------------------
	If GetRawKeyPressed(KEY_ENTER)
		ResetSpriteUV(1)
		u1# = 0.0
		v1# = 0.0
		
		u2# = 0.0
		v2# = 1.0
		
		u3# = 1.0
		v3# = 0.0
		
		u4# = 1.0
		v4# = 1.0
	EndIf
	`-----------------------------
	
	
	`draw boxes for visualization
	`-----------------------------
	If GetRawKeyPressed(KEY_SHIFT) Then SetSpriteVisible(2, 1)
	If GetRawKeyState(KEY_SHIFT)	
		DrawLine(250 + (u1# * 500), 250 + (v1# * 500), 250 + (u2# * 500), 250 + (v2# * 500), 255, 0, 0)
		DrawLine(250 + (u2# * 500), 250 + (v2# * 500), 250 + (u4# * 500), 250 + (v4# * 500), 255, 0, 0)
		DrawLine(250 + (u4# * 500), 250 + (v4# * 500), 250 + (u3# * 500), 250 + (v3# * 500), 255, 0, 0)
		DrawLine(250 + (u3# * 500), 250 + (v3# * 500), 250 + (u1# * 500), 250 + (v1# * 500), 255, 0, 0)
		If intSelectedVertex = 1 Then DrawEllipse(250 + (u1# * 500), 250 + (v1# * 500), 4, 4, MakeColor(0, 0, 255), MakeColor(0, 0, 255), 1)
		If intSelectedVertex = 2 Then DrawEllipse(250 + (u2# * 500), 250 + (v2# * 500), 4, 4, MakeColor(0, 0, 255), MakeColor(0, 0, 255), 1)
		If intSelectedVertex = 3 Then DrawEllipse(250 + (u3# * 500), 250 + (v3# * 500), 4, 4, MakeColor(0, 0, 255), MakeColor(0, 0, 255), 1)
		If intSelectedVertex = 4 Then DrawEllipse(250 + (u4# * 500), 250 + (v4# * 500), 4, 4, MakeColor(0, 0, 255), MakeColor(0, 0, 255), 1)
	EndIf
	If GetRawKeyReleased(KEY_SHIFT) Then SetSpriteVisible(2, 0)
	`-----------------------------
	
    Sync()
Loop
Help make AGK better by submitting an example for this command!
(All examples are subject to approval)
Login to post an example of your own.