OK, I got:
- Line Draw
- Box outline
- Box filled
- Elipse
- Disc
What I need now is the FLOOD FILL implemented. I found one in the archive, but it is rather complex for me. I'll try to get my head wrapped around it another day.
EDIT: Thanks Yan for the link, good article. Don't know if I have the patience to learn this method thoe but maybe I'll try to implement it some day.
http://www.blitzbasic.com/codearcs/codearcs.php?code=2157EDIT2: Here's my pimped up FloodFill, ready to be transformed for usage with banks :)
Graphics 800,600,0,2
Global Image = LoadImage("apple_logo_640x480.jpg") ; <---- put image filename here
SetBuffer BackBuffer()
SeedRnd MilliSecs()
While Not KeyDown(1)
Cls
If MouseHit(1) Then FloodFill(Image,MouseX(),MouseY(),Rand(255),Rand(255),Rand(255))
DrawImage Image,0,0
Color 255,255,255
Plot MouseX(),MouseY()
Flip
Wend
End
Type Pixel
Field X,Y
End Type
Function FloodFill(FillImage, Fill_X, Fill_Y, FR, FG, FB)
Local width% = ImageWidth(FillImage)
Local height% = ImageHeight(FillImage)
If Fill_X < 0 Or Fill_X > width - 1 Or Fill_Y < 0 Or Fill_Y > height - 1
Return ; Coords ouside image boundaries
EndIf
Local CurrentBuffer = GraphicsBuffer()
SetBuffer ImageBuffer(FillImage)
LockBuffer
Local Current_RGB% = ReadPixelFast(Fill_X, Fill_Y)
Local RGB% = FB + FG Shl 8 + FR Shl 16
Pixel.Pixel = New Pixel
Pixel\X = Fill_X
Pixel\Y = Fill_Y
WritePixelFast Pixel\X,Pixel\Y,RGB
Repeat
Local PixelsRemaining = False
For Pixel.Pixel = Each Pixel
PixelX = Pixel\X
PixelY = Pixel\Y
PixelLeft = False
PixelAbove = False
PixelRight = False
PixelBelow = False
If Pixel\X > 0;check left
If Current_RGB = ReadPixelFast(Pixel\X - 1,Pixel\Y) Then
PixelLeft = True
PixelsRemaining = True
EndIf
EndIf
If Pixel\Y > 0;check above
If Current_RGB = ReadPixelFast(Pixel\X,Pixel\Y - 1) Then
PixelAbove = True
PixelsRemaining = True
EndIf
EndIf
If Pixel\X < width - 1;check right
If Current_RGB = ReadPixelFast(Pixel\X + 1,Pixel\Y) Then
PixelRight = True
PixelsRemaining = True
EndIf
EndIf
If Pixel\Y < height - 1;check below
If Current_RGB = ReadPixelFast(Pixel\X,Pixel\Y + 1) Then
PixelBelow = True
PixelsRemaining = True
EndIf
EndIf
Delete Pixel
If PixelLeft = True
Pixel.Pixel = New Pixel
Pixel\X = PixelX - 1
Pixel\Y = PixelY
PixelLeft = False
WritePixelFast Pixel\X,Pixel\Y,RGB
EndIf
If PixelAbove = True
Pixel.Pixel = New Pixel
Pixel\X = PixelX
Pixel\Y = PixelY - 1
PixelAbove = False
WritePixelFast Pixel\X,Pixel\Y,RGB
EndIf
If PixelRight = True
Pixel.Pixel = New Pixel
Pixel\X = PixelX + 1
Pixel\Y = PixelY
PixelRight = False
WritePixelFast Pixel\X,Pixel\Y,RGB
EndIf
If PixelBelow = True
Pixel.Pixel = New Pixel
Pixel\X = PixelX
Pixel\Y = PixelY + 1
PixelBelow = False
WritePixelFast Pixel\X,Pixel\Y,RGB
EndIf
Next
Until PixelsRemaining = False
UnlockBuffer
SetBuffer CurrentBuffer
End Function