(AGK version: 108.14)
Submitted: 2013-07-12 08:28:43
// 	Screen Magnifier - Example of Using SetScissor with SetViewOffset & SetViewZoom()
//	By Marl = 12 July 2013
//	
//	To use this example, you will need a picture in the media folder of the project
//	Called "background.png", this should ideally be the same aspect ratio as the device.
//
//     Operation
//	Touch the screen at the point to be magnified
//	Escape (Back) to exit
//

// Get Device Resolution
thisWidth = getDeviceWidth()
thisHeight = getDeviceHeight()
thisMidX = thisWidth * 0.5
thisMidY = thisHeight * 0.5

// Size of area to be magnified ( initially 1/3 of display )
ScissorW = thisWidth / 3.0
ScissorH = thisHeight / 3.0

// Zoom Magnification
myZoom# = 3.0

// Switch Device Resolution
setVirtualResolution( thisWidth , thisHeight )
sync()

// Load an image for the background and create a sprite for it
myImage = loadImage( "background.png" )
mySprite = createSprite( myImage )

// Set Sprite Size to full screen and depth to 100
setSpriteSize( mySprite , thisWidth , thisHeight )
setSpriteDepth( mySprite , 100 )

// Set Sprite to World Plane so we can use setviewOffset()
fixSpriteToScreen( mySprite , 0)

ScissorX = 0
ScissorY = 0

// Precalculate offset from pointer to top left of magnified area
myOffsetScale# = 0.5 / myZoom#
myOffsetX# = ScissorW * myOffsetScale#
myOffsetY# = ScissorH * myOffsetScale#

// Initialise X and Y of portion to magnify - initially center
myX = thisMidX - myOffsetX#
myY = thisMidY - myOffsetY#

// Create a Sprite to represent to zoomed portion in Transparent Orange
mySprite2 = createSprite( 0 )
setSpriteSize( mySprite2 , myOffsetX# * 2.0 , myOffsetY# * 2.0 )
setSpriteColor( mySprite2 , 255 , 191 , 0 , 127 )
setSpritePositionByOffset( mySprite2 , thisMidX , thisMidY )

do
	// Escape Key to Exit (Back on mobile devices)
	if getRawKeyState(27) then exit

	// Check if pointer is pressed
	if getPointerState()
		// Get pointer position and determine offset to top left of magnified region
		pointerX = getPointerX()
		pointerY = getPointerY()
		setSpritePositionByOffset( mySprite2 , pointerX , pointerY )
		myX = pointerX - myOffsetX#
		myY = pointerY - myOffsetY#

		// Position zoom region away from pointer
		if pointerX > thisMidX
			ScissorX = 0
		else
			ScissorX = thisWidth - ScissorW
		endif
		if pointerY > thisMidY
			ScissorY = 0
		else
			ScissorY = thisHeight - ScissorH
		endif
	endif

	// Render full screen Image
	update(0)
	render()

	// Limit drawing to magnified region
	setScissor( ScissorX , ScissorY ,  ScissorX + ScissorW , ScissorY + ScissorH )
	setViewZoom( myZoom# )
	setViewOffset( myX - ScissorX / myZoom# , myY - ScissorY / myZoom# )
	
	// Hide Highlight Sprite
	setSpriteVisible( mySprite2 , 0 )
	
	// Draw magnified region
	render()

	// Restore Scissor
	setScissor( 0 , 0, thisWidth , thisHeight )
	setViewZoom( 1.0 )
	setViewOffset( 0 , 0 )

	// Show Highlight Sprite
	setSpriteVisible( mySprite2 , 1 )
	
	// Swap Buffer
	swap()
loop

// Clean up
deleteSprite( mySprite )
deleteimage( myImage )
// Exit
end
(AGK version: AGK2)
Submitted: 2019-09-02 08:32:47
// Project: scissor 
// Created: 2019-09-02
// Shows how to use the SetScissor() and SetViewOffset() commands to create
//    a split screen effect

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "scissor" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts

//create a couple of player sprites
sprite1 = createsprite(0)
setspritecolor(sprite1,255,0,0,255)
SetSpriteSize(sprite1,64,64)
sprite2 = createsprite(0)
setspritecolor(sprite2,0,255,0,255)
setspritesize(sprite2,64,64)

//set a random direction for sprite movement
angle1 as float
angle2 as float

angle1 = random(0,360)
angle2 = random(0,360)

dx1 as float
dy1 as float
dx2 as float
dy2 as float

dx1 = cos(angle1)*4
dy1 = sin(angle1)*4
dx2 = cos(angle2)*4
dy2 = sin(angle2)*4

//set a random starting position for the sprites
px1 as float
py1 as float
px2 as float
py2 as float

px1 = random(0,1024)
py1 = random(0,768)
SetSpritePosition(sprite1,px1,py1)
px2 = random(0,1024)
py2 = random(0,768)
SetSpritePosition(sprite2,px2,py2)

//lets fill the area with some random static sprites
for i = 1 to 20
	sprite = createsprite(0)
	setspritecolor(sprite,0,0,255,255)
	setspritesize(sprite,random(32,128),random(32,128))
	setspriteposition(sprite,random(0,1024),random(0,768))
next

do
	//update the sprites positions
	px1 = px1 + dx1
	py1 = py1 + dy1
	if px1 <= 0 or px1 >= 959 then dx1 = -dx1
	if py1 <=0 or py1 >= 703 then dy1 = -dy1
	SetSpritePosition(sprite1,px1,py1)
	
	px2 = px2 + dx2
	py2 = py2 + dy2
	if px2 <= 0 or px2 >= 959 then dx2 = -dx2
	if py2 <=0 or py2 >= 703 then dy2 = -dy2
	SetSpritePosition(sprite2,px2,py2)

	//set rendering to left half and view offset centered on sprite1
    SetScissor(0,0,511,767)
    SetViewOffset(Round(px1)-224,Round(py1)-352)
    render()
 
 	//set rendering to left half and view offset centered on sprite2   
    SetScissor(512,0,1023,767)
    SetViewOffset(round(px2)-736,round(py2)-352)
    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.