
http://blogs.scientificamerican.com/sym ... your-eyes/

Code: Select all
#FontSize = 140
#Width = 670
#Height = 220
#Radius = 5
#Holes = 300
Define.i i, event
If OpenWindow(0, 0, 0, #Width, #Height, "Mmmhh", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) = 0
MessageRequester("Fatal error", "Program terminated.")
End
EndIf
If LoadFont(1, "Arial", #FontSize) = 0
MessageRequester("Couldn't load font", "Program terminated.")
End
EndIf
If CreateImage(0, #Width, #Height) And StartDrawing(ImageOutput(0))
DrawingFont(FontID(1))
DrawText(10, 10, "Cheese", #Yellow)
For i = 1 To #Holes
Circle(Random(#Width-#Radius,#Radius), Random(#Height-#Radius,#Radius), #Radius, 0)
Next
StopDrawing()
ImageGadget(0, 0, 0, #Width, #Height, ImageID(0))
EndIf
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindowCode: Select all
#FontSize1 = 100
#FontSize2 = 90
#FontSize3 = 120
#width = 460
#height = 250
Procedure handleError(value, msg.s)
If value = 0: MessageRequester("Fatal error", msg): End: EndIf
EndProcedure
handleError(OpenWindow(0, 0, 0, #width, #height, "pop pop", #PB_Window_SystemMenu | #PB_Window_ScreenCentered),"Couldn't open window.")
handleError(LoadFont(1, "Arial", #FontSize1), "Couldn't load font.")
handleError(LoadFont(2, "Arial", #FontSize2), "Couldn't load font.")
handleError(LoadFont(3, "Arial", #FontSize3), "Couldn't load font.")
Define.i i, Event
If CreateImage(0, #width, #height) And StartDrawing(ImageOutput(0))
Box(0, 0, #width, #height, RGB(231, 231, 231))
FrontColor($000000)
Box(0,132, #width, #height)
Ellipse(228, 123, 200, 50, RGB(231, 231, 231))
DrawingFont(FontID(1))
DrawRotatedText(-5, 136, "b", 75)
DrawRotatedText(50, 50, "u", 50)
DrawRotatedText(160, 61, "b", 60)
DrawRotatedText(220, 188, "l", 97)
DrawRotatedText(312, 198, "s", 116)
DrawingFont(FontID(2))
DrawRotatedText(240, 157, "e", 90)
DrawingFont(FontID(3))
DrawRotatedText(97, 182, "b", 94)
StopDrawing()
ImageGadget(0, 0, 0, #width, #height, ImageID(0))
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Code: Select all
#FontSize = 40
#Width = 270
#Height = 220
Define.i event
If OpenWindow(0, 0, 0, #Width, #Height, "a²+b² = c²", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) = 0
MessageRequester("Fatal error", "Program terminated.")
End
EndIf
If LoadFont(1, "Arial", #FontSize) = 0
MessageRequester("Couldn't load font", "Program terminated.")
End
EndIf
If CreateImage(0, #Width, #Height) And StartDrawing(ImageOutput(0))
DrawingFont(FontID(1))
DrawRotatedText( 10, 120, "P y", 60)
DrawRotatedText(120, 20, "t h a g", -30)
DrawRotatedText( 60, 130, "o r a s", 0)
StopDrawing()
ImageGadget(0, 0, 0, #Width, #Height, ImageID(0))
EndIf
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
Code: Select all
#FontSize = 40
#Width = 600
#Height = 500
#ImgWidth = 60
#ImgHeight = 60
#MaxStep = 4
#Wind = 3
CompilerIf Not Defined(Point, #PB_Structure)
Structure POINT
x.l
y.l
EndStructure
CompilerEndIf
Procedure.i CreateBalloons (text$)
Protected i.i, ret.i
If LoadFont(1, "Arial", #FontSize) = 0
ProcedureReturn 0 ; error
EndIf
ret = Len(text$)
For i = 1 To ret
CompilerIf #PB_Compiler_Version < 520
If CreateImage(i, #ImgWidth, #ImgHeight, 32|#PB_Image_Transparent) And StartDrawing(ImageOutput(i))
CompilerElse
If CreateImage(i, #ImgWidth, #ImgHeight, 32, #PB_Image_Transparent) And StartDrawing(ImageOutput(i))
CompilerEndIf
DrawingMode(#PB_2DDrawing_AlphaBlend | #PB_2DDrawing_Transparent)
DrawingFont(FontID(1))
FrontColor(RGBA(Random(255),Random(255),Random(255),255))
DrawText(0, 0, Mid(text$,i,1))
StopDrawing()
EndIf
Next
FreeFont(1)
ProcedureReturn ret
EndProcedure
Procedure DrawBalloons (images.i)
Static Dim posn.Point(0)
Protected i.i
If ArraySize(posn()) = 0
Dim posn.Point(images)
For i = 1 To images
posn(i)\x = i*#ImgWidth + 10
posn(i)\y = #Height - #FontSize*2
Next
Else
For i = 1 To images
posn(i)\x + Random(#MaxStep + #Wind) - #MaxStep/2
posn(i)\y - Random(#MaxStep, #MaxStep/2)
Next
EndIf
If StartDrawing(ImageOutput(0))
Box(0, 0, #Width, #Height, 0)
DrawingMode(#PB_2DDrawing_AlphaBlend)
For i = 1 To images
DrawImage(ImageID(i), posn(i)\x, posn(i)\y)
Next
StopDrawing()
EndIf
SetGadgetState(0, ImageID(0))
EndProcedure
Define count.i
If OpenWindow(0, 0, 0, #Width, #Height, "", #PB_Window_ScreenCentered|#PB_Window_SystemMenu) = 0
MessageRequester("Fatal error", "Program terminated.")
End
EndIf
count = CreateBalloons("balloons")
If count = 0
MessageRequester("Couldn't create balloons", "Program terminated.")
End
EndIf
CreateImage(0, #Width, #Height)
ImageGadget(0, 0, 0, #Width, #Height, 0)
AddWindowTimer(0, 0, 50)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Timer
DrawBalloons(count)
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
It should bedavido wrote:Hi Little John,
Had an image error regarding depth.
I tried changing line 19 to: CreateImage(i, #ImgWidth, #ImgHeight, 32) And StartDrawing(ImageOutput(i))
It then appeared to work, with the 'BALLOON' vanishing through the top of the window!
Code: Select all
CreateImage(i, #ImgWidth, #ImgHeight, 32, #PB_Image_TransparentCode: Select all
CreateImage(i, #ImgWidth, #ImgHeight, 32|#PB_Image_TransparentCode: Select all
CreateImage(i, #ImgWidth, #ImgHeight, 32)Code: Select all
If CreateImage(i, #ImgWidth, #ImgHeight, 32, #PB_Image_Transparent) And StartDrawing(ImageOutput(i))

Code: Select all
If Not Defined(Point, #PB_Structure)
Structure POINT
x.i
y.i
EndStructure
EndIf


Code: Select all
#FontSize = 40
#Width = 400
#Height = 200
#ImgWidth = 180
#ImgHeight = 60
#Step = 4
#Edge = 180
#Falling = 40
Procedure CreateWordImage (text$)
If LoadFont(1, "Arial", #FontSize)
If CreateImage(1, #ImgWidth, #ImgHeight) And StartDrawing(ImageOutput(1))
DrawingFont(FontID(1))
DrawText(0, 0, text$)
StopDrawing()
FreeFont(1)
ProcedureReturn 1 ; success
EndIf
FreeFont(1)
EndIf
ProcedureReturn 0 ; error
EndProcedure
Procedure DrawWordImage ()
Static x.i = 0
Static y.i = #Height - #FontSize*2
Static stepp = #Step
If x < #Edge
x + #Step
y + stepp
stepp = -stepp
Else
y + #Falling
EndIf
If StartDrawing(ImageOutput(0))
Box(0, 0, #Width, #Height, 0)
DrawImage(ImageID(1), x, y)
StopDrawing()
EndIf
SetGadgetState(0, ImageID(0))
EndProcedure
If OpenWindow(0, 0, 0, #Width, #Height, "Oops!", #PB_Window_ScreenCentered|#PB_Window_SystemMenu) = 0
MessageRequester("Fatal error", "Program terminated.")
End
EndIf
If CreateWordImage("trapped") = 0
MessageRequester("Couldn't create image of the word", "Program terminated.")
End
EndIf
CreateImage(0, #Width, #Height)
ImageGadget(0, 0, 0, #Width, #Height, 0)
AddWindowTimer(0, 0, 50)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Timer
DrawWordImage()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver