Let me see if i get it right:
Createimage makes an empty timage with its width and height.
Grabimage copyies a piece of the backbuffer using a timage width and height at a certain x and y coords and pastes it into a timage. Something like a cookie cutter?.
So, if i want a white masked circle i would need to draw it before any image is drawn on the backbuffer, and use the cls color matching the mask color, right?.
That's pretty much it, except the mask defaults to black so, using MASKBLEND to draw the image, you'll get a masked oval regardless of the background colour.
OOP-fied example:
SuperStrict
SeedRnd(MilliSecs())
Const GWIDTH:Int = 800
Const GHEIGHT:Int = 600
Const OVAL_SIZE:Int = 32
Const NUMBER_OF_PARALLAX_FIELDS:Byte = 4
Graphics GWIDTH,GHEIGHT
OvalField.Init(NUMBER_OF_PARALLAX_FIELDS)
SetClsColor 100,200,200
While Not KeyHit(KEY_ESCAPE)
Cls
OvalField.Update()
Flip True
Wend
Type OvalField
Global OvalPic:TImage = CreateImage(OVAL_SIZE,OVAL_SIZE)
Global OvalList:TList = CreateList()
Function Init(Fields_arg:Byte)
SetBlend SOLIDBLEND
Cls
DrawOval 0,0,OVAL_SIZE,OVAL_SIZE
GrabImage OvalPic,0,0
For Local Scanline:Int = 0 To (GHEIGHT - 1)
Local NewOval:Oval = New Oval
NewOval.YPos = Scanline
NewOval.XPos = Rand(0,GWIDTH-1)
NewOval.Speed = Rand(1,Fields_arg)
NewOval.Shade = ( (200/Fields_arg)*NewOval.Speed ) + 55
NewOval.Scale = (1.0 / 255)*NewOval.Shade
ListAddLast OvalList,NewOval
Next
SortList(OvalList, True, CompareSpeed)
End Function
Function Update()
SetBlend MASKBLEND
For Local CurrentOval:Oval = EachIn OvalList
CurrentOval.XPos = CurrentOval.XPos - CurrentOval.Speed
If CurrentOval.XPos < -OVAL_SIZE Then CurrentOval.XPos:+GWIDTH+OVAL_SIZE
CurrentOval.Draw()
Next
End Function
Function CompareSpeed:Int(ObjectA_arg:Object, ObjectB_arg:Object)
If Oval(ObjectA_arg).Speed > Oval(ObjectB_arg).Speed
Return True
Else
Return False
EndIf
End Function
End Type
Type Oval
Field XPos:Int
Field YPos:Int
Field Shade:Byte
Field Speed:Byte
Field Scale:Float
Method Draw()
SetColor Self.Shade,Self.Shade,Self.Shade
SetScale Self.Scale,Self.Scale
DrawImage OvalField.OvalPic, Self.XPos, Self.YPos
End Method
End Type