By chance, much trial and error, I hit upon a bit of simple code that produces an amazing image pattern IMO.
I thought it was worthy of its own topic in the Tricks 'n' Tips section.
It scales well for different image sizes.
I really have no idea exactly how the complexity of this pattern is produced.
At first I was plotting with the use of the RGBA() function and that worked fine when I was using x86 version of PB.
To my dismay I found it gave different and undesirable results when I switched to x64 version.
After some experimentation I was able to eliminate the use of RGBA() function and use bit shifting to obtain the desired
result for both x86 and x64 versions of PB.
You can disregard the drawing of the text, that's no big deal.
The real magic is in the two nested for/next loops.
Tested OK on Windows-7 and Linux Mint.
Code: Select all
EnableExplicit
Define.i c, x, y, z, t
#W = 1024
#H = 576
#image = 0
LoadFont(1,"Arial",36,#PB_Font_Bold | #PB_Font_Italic | #PB_Font_HighQuality)
Macro DrawShadowedText(txt)
FrontColor($FFFFFF) ;shadow color
x = (OutputWidth() - TextWidth(txt))/2
DrawText(x+3,y+3,txt)
FrontColor($44B8ED) ;text color
DrawText(x,y,txt)
y + t
EndMacro
If OpenWindow(0,0,0,#W,#H,"Cool Image ",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateImage(#image,#W,#H,32,0)
StartDrawing(ImageOutput(#image))
DrawingFont(FontID(1))
DrawingMode(#PB_2DDrawing_AlphaBlend)
For y = 0 To OutputHeight()-1
For x = 0 To OutputWidth()-1
c = (x * y) | %01010101
z = (x+y)|z
Plot(x, y, c!z + (c|z)<<8 + (c|z)<<16 + C<<27 )
Next
Next
DrawingMode( #PB_2DDrawing_Transparent)
t = TextHeight("Ag") ;arbitrary text
y = OutputHeight()/2 - t*1.5
DrawShadowedText("CQ Image Editor")
DrawShadowedText("by")
DrawShadowedText("BasicallyPure")
StopDrawing()
FreeFont(1)
ImageGadget(#PB_Any,0,0,#W,#H,ImageID(#image))
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
EndIf