It is currently Sun Mar 29, 2020 1:25 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Minimal Wallpaper Generator
PostPosted: Wed Oct 09, 2019 10:21 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Nov 09, 2011 8:58 am
Posts: 578
Here's another example of how to create a little application in just a few lines of code.
It's a quick, dirty and ugly minimal wallpaper generator I made a few years ago.

Feel free to enhance it! :)


Code:

ExamineDesktops() : UsePNGImageEncoder() : Global W=DesktopWidth(0) , H=DesktopHeight(0) 

Global DefStatus$ = " Space to generate, S to save PNG" + Space(235) + "Made with PureBasic"

OpenWindow(0, 55, 55, 1010, 556, "Minimal Wallpaper Generator 1.0", #PB_Window_SystemMenu)

CreateImage(99, W, H)  : ImageGadget(33,0,0,W,H,ImageID(99))

CreateStatusBar(0,WindowID(0)) :  AddStatusBarField(#PB_Ignore ) :     StatusBarText(0,0,DefStatus$)

Procedure gennew()
 
  Repeat
    StartDrawing(ImageOutput(99))  :  Lines = 0  :   Box(0,0,W,H, 42) 
    For i = 0 To H Step 60 :  If Not Random(5) : Line(0, i, W+1, 1, 0)  : Lines + 1 : EndIf :  Next
    For j = 0 To W Step 60 :  If Not Random(5) : Line(j, 0, 1, H+1, 0)  : Lines + 1 : EndIf :  Next

    For j = 5 To H*0.9 Step 55 :
      For k = 5 To W*0.9 Step 35 :
       If Point(k,j) = 42 : FillArea(k, j, -1, RGB(Random($33),Random($33),Random($33)) + $565656) : EndIf
    Next : Next
    StopDrawing()
  Until Lines > 2
  SetGadgetState(33,ImageID(99)) :    StatusBarText(0,0,DefStatus$)
EndProcedure

Procedure save()
  fname$ = Str(Date())+".png" : SaveImage(99,fname$, #PB_ImagePlugin_PNG) : StatusBarText(0,0,"Saved as " +fname$)
EndProcedure

gennew() 

AddKeyboardShortcut(0, #PB_Shortcut_Space, 15) :  BindEvent(#PB_Event_Menu, @gennew(), 0, 15)
AddKeyboardShortcut(0, #PB_Shortcut_S, 16) :      BindEvent(#PB_Event_Menu, @save(),  0, 16)

Repeat : Until WaitWindowEvent() = 13116


_________________
My new project: A simple HTML/CSS UI engine for PB desktop apps
viewtopic.php?f=7&t=74582


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye