Code: Select all
EnableExplicit
Procedure CreateFancyImage(ID, w, h, mode=0)
Protected img, x, y, c
Protected result=CreateImage(ID, w, h, 32)
If ID=#PB_Any : ID=result : EndIf
StartDrawing(ImageOutput(ID))
For y=0 To OutputHeight()-1
For x=0 To OutputWidth()-1
Select mode
Case 0
;// chain
c=Int(x*1.4)%200 ! Int(y*1.3)%233
Case 1
;// wall
c=Int(x*2)%30 | ~Int(y*1.3)%233 & $FF
Case 2
;// perspective
c=x%(y+1)
Case 3
;// pavement
c=x ! y
Case 4
;// noise screen
c=(x & $FF)*(y & $FF)
Case 5
;// castle
c=x-(y ! x & $FFFF)
Case 6
;// strips
c=y+(x % 100)
Case 7
;// strips hashed
c=(y+(x % 100) & $FF) ! ((x+y) & $FF)
Case 8
;// Left Arrow
Define xx=x%512
Define yy=y%512
c=Abs(xx-Abs(yy-256))
Default
MessageRequester("CreateFancyImage", "mode "+Str(mode)+" not defined!")
End
EndSelect
Plot(x, y, RGB(c, 0, c/3))
Next
Next
StopDrawing()
ProcedureReturn result
EndProcedure
DisableExplicit
; ********************
; EXAMPLE @ eddy
; ********************
#imgsize=1024
CreateFancyImage(10, #imgsize, #imgsize, 0)
#w=800
#h=600
OpenWindow(0, 0, 0, #w, #h, "Click to switch image mode", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
ScrollAreaGadget(1, 0, 0, #w, #h, ImageWidth(10), ImageHeight(10))
ImageGadget(0, 0, 0, 0, 0, ImageID(10))
CloseGadgetList()
Repeat
e=WaitWindowEvent()
If e=#PB_Event_Gadget
mode=(mode+1)%9
CreateFancyImage(10, #imgsize, #imgsize, mode)
SetGadgetState(0, ImageID(10))
EndIf
Until e=#PB_Event_CloseWindow