Here are some functions you can use for the clipping:
Function CreateClippingArea(width, height)
id = find free image()
ik create render target id, abs(width), abs(height)
endFunction id
Function CreateMaskedImage(image, mask, clipArea, x, y)
If Not Core_CheckImage(clipArea) then exitfunction
If Not Core_CheckImage(image) then exitfunction
If Not Core_CheckImage(mask) then exitfunction
ik set blend mode 19
ik paste image on image mask, clipArea, 0, 0
ik set blend mode 18
ik paste image on image image, clipArea, x, y
ik set blend mode 1
endFunction clipArea
Function CreateClippedImage(image, clipArea, x, y)
If Not Core_CheckImage(clipArea) then exitfunction
If Not Core_CheckImage(image) then exitfunction
ik set blend mode 19
ik paste image on image image, clipArea, x, y
ik set blend mode 1
endFunction image
Use them like this:
maskImage = reserve free image()
imageToClip = reserve free image()
load image "mask.png", maskImage
load image "large.png", imageToClip
clipArea = CreateClippingArea(64, 64)
Do
paste image CreateMaskedImage(imageToClip, maskImage, clipArea, mousex(), mousey()), 0, 0, 1
Sync
Loop