Circles2.0

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
A.D.
User
User
Posts: 98
Joined: Tue Oct 06, 2009 9:11 pm

Circles2.0

Post by A.D. »

Hi to all out there,

I just beefed up my old screensaver called "circles". It's really fun watching it and it has a nice calming effect on you when you are e.g. stressed from working on your
personal computer. I made a normal executable from it and one as a screensaver. I hope you enjoy it !

Greets
A.D.

https://dl.dropbox.com/u/79165522/circles.zip
Repeat
PureBasic
ForEver
User avatar
A.D.
User
User
Posts: 98
Joined: Tue Oct 06, 2009 9:11 pm

Re: Circles2.0

Post by A.D. »

Here's my code and sorry that my links were offline...

Code: Select all

;*************************************************************************************************************************
;************************************************** CIRCLES Bildschirmschoner **************************************************
;**************************************************  by Alexander Diaconu  ******************************************************
;*************************************************************************************************************************

; Lizenzvereinbarung / Urheberrechtshinweise
; 
; a) ENDBENUTZERVERTRAG:
; Mit Installation und/oder Verwendung dieser Software sowie der Weitergabe an Dritte akzeptiert der Anwender diese Lizenzvereinbarung.
; 
; 1. CIRCLES ist kostenlos! Der Anwender ist berechtigt, diese Software zu benutzen und kostenfrei an Dritte weiterzugeben. Eine Nutzung im kommerziellen Bereich ist
; nur mit dem Einverständnis und unter den Bedingungen des Authors erlaubt.
; 2. Haftungsauschluss: der Autor dieses Programmes kann unter keinen Umständen, eingeschlossen Fahrlässigkeit, für Schäden jeglicher Art (inklusive Datenverlust,
; Gewinn-/Umsatzeinbußen, die durch Verwendung oder Verbreitung der Software verursacht werden, zur Verantwortung gezogen werden.
; 
; 2016 Copyright by Alexander Diaconu

; ************************************************************************************************************************
 

; Init
Declare Run()
Declare About()

Global Kreise.w   
Global Abstand = 2
Global Delay = 5
Global Delay2 = 300   
Global BreakID.b
Global Started = 0


; ************************************************************************************************************************
 

Macro RandomizeColors
  Farbe1 = RGB(Random(255), Random(255), Random(255))
  Farbe2 = RGB(Random(255), Random(255), Random(255))
  Farbe3 = RGB(Random(255), Random(255), Random(255))
  Farbe4 = RGB(Random(255), Random(255), Random(255))
  Farbe5 = RGB(Random(255), Random(255), Random(255))
  Farbe6 = RGB(Random(255), Random(255), Random(255))
  ;Farbe1 = RGBA(Random(255), Random(255), Random(255),Random(255))
  ;Farbe2 = RGBA(Random(255), Random(255), Random(255),Random(255))
  ;Farbe3 = RGBA(Random(255), Random(255), Random(255),Random(255))
  ;Farbe4 = RGBA(Random(255), Random(255), Random(255),Random(255))
  ;Farbe5 = RGBA(Random(255), Random(255), Random(255),Random(255))
  ;Farbe6 = RGBA(Random(255), Random(255), Random(255),Random(255))
 EndMacro
  
Macro RandomArea(StartValue, EndValue, StepValue)
( Random(Int(((EndValue)-(StartValue))/(StepValue)))*(StepValue)+(StartValue) )
EndMacro

                  
Procedure Run()
  
 UseCRC32Fingerprint() 
 If Not FileFingerprint("license.txt",#PB_Cipher_CRC32) = "b73ab90e" : End : EndIf
  
 ShowCursor_(0) 
 InitKeyboard()
 InitSprite()
 
 Desk=ExamineDesktops()
 Screen_X = DesktopWidth(0)
 Screen_Y = DesktopHeight(0)
 
;  Debug Desk
;  Debug Screen_X
;  Debug Screen_Y
;  Debug DesktopX(1)
;  Debug DesktopY(1)
;  End

 ;GetCursorPos_(Maus.Point)
 ;Screen_X = GetSystemMetrics_(#SM_CXSCREEN) 
 ;Screen_Y = GetSystemMetrics_(#SM_CYSCREEN)
 
 WinID = OpenWindow(0, 0, 0, Screen_X, Screen_Y, "",#PB_Window_BorderLess)
 OpenWindowedScreen(WinID, 0, 0, Screen_X, Screen_Y,0,0,0,0) : StickyWindow(0, 1) ;: SetFrameRate(57)
 
 Kreise = Sqr(Pow(Screen_X/2,2) + Pow(Screen_Y/2,2)) 
 ClearScreen($000000)

 Sprite = 0 : CreateSprite(Sprite,Screen_X,Screen_Y,#PB_Sprite_AlphaBlending) 
 
 posx =  -screen_x/2
 posy =  -screen_y/2
 
 Repeat 
    
  Select Mode
  Case 0
   x1 = Random(Screen_X) : y1 = Random(Screen_Y)
   lum = RandomArea(30, 50, 5)
  Case 1 
   x1 = Random(Screen_X*1.7) : y1 = Random(Screen_Y*1.7)
   ;lum = 20
   lum = RandomArea(20, 40, 10)
  EndSelect
  x2 = x1 + Random(2) 
  
  
  RandomizeColors : Radius = 0 
  ;Timer = 2500
  Timer = RandomArea(Random(1000,200), Random(8700, 2600), 10); Random(100,10))
  ;If Started = 1 : Delay(Delay2) : Else : Started = 1 : EndIf
  ;Abstand = Random(2,1)
   
  For Radius = 1 To Kreise 
    
    Select Mode
    Case 0
     DisplayTransparentSprite(Sprite, 0, 0, lum) 
     ;SpriteBlendingMode(#PB_Sprite_BlendInvertSourceColor,#PB_Sprite_BlendDestinationColor)
     Delay(Delay) 
    Case 1
     RotateSprite(Sprite, Gamma.f,  #PB_Relative) ;: ZoomSprite(Sprite, Screen_X+RandomArea(-100,100,1), Screen_Y+RandomArea(-100,100,1))
     ;ZoomSprite(Sprite, SpriteWidth(Sprite)+RandomArea(-10,10,1), SpriteHeight(Sprite)+RandomArea(-10,10,1))
     DisplayTransparentSprite(Sprite, posx, posy, lum)
     ;Delay(0)
    EndSelect
   
   FlipBuffers()
   
   ;If Radius = Kreise : Delay(Delay) : EndIf
   
   ;GetCursorPos_(temp.POINT) 
   ;If Maus\x <> temp\x : Break_ID = 1 : Break : EndIf
   ;If Maus\y <> temp\y : Break_ID = 1 : Break : EndIf
   
   ExamineKeyboard() 
  
   If KeyboardReleased(#PB_Key_P)
    Select Psychedelic
     Case 0 : Psychedelic = 1
     Case 1  :  Psychedelic = 0
    EndSelect
   EndIf
   
   If KeyboardReleased(#PB_Key_Space) 
    Select Mode
     Case 0 
      Mode = 1 : Radius = 1 : ClearScreen($000000) : Gamma.f = RandomArea(-0.14, 0.14, 0.01)
      Kreise = Sqr(Pow(Screen_X/2,2) + Pow(Screen_Y/2,2)) * 2 
      x1 = Screen_X + RandomArea(-300, 300, 1) : y1 = Screen_Y + RandomArea(-300, 300, 1)
      Sprite = 0 : FreeSprite(Sprite) : CreateSprite(Sprite,Screen_X*2,Screen_Y*2,#PB_Sprite_AlphaBlending)
      RandomizeColors : Psychedelic = 0
     Case 1 
      x1 = Random(Screen_X) : y1 = Random(Screen_Y) : y2 = y1 : x2 = x1 + Random(2) 
      Mode = 0 : Radius = 1 : ClearScreen($000000) : Delay = 5
      Kreise = Sqr(Pow(Screen_X/2,2) + Pow(Screen_Y/2,2))
      Sprite = 0 :  FreeSprite(Sprite) : CreateSprite(Sprite,Screen_X,Screen_Y,#PB_Sprite_AlphaBlending)
      RandomizeColors : Psychedelic = 0
    EndSelect
   EndIf
   
   If Mode = 0
   If KeyboardReleased(#PB_Key_Add)
   Delay-1 : If Delay < 0 : Delay = 0 : EndIf
   ElseIf KeyboardReleased(#PB_Key_Subtract)
   Delay+1 : If Delay > 30 : Delay = 30 : EndIf
   EndIf
   EndIf
   
   If KeyboardReleased(#PB_Key_Divide)
   Gamma.f - 0.01 : If Gamma.f < -1.4 : Gamma.f = 0.01 : EndIf
   If Gamma.f = 0 : Gamma.f = - 0.01 : EndIf
   ;ZoomSprite(Sprite, SpriteWidth(Sprite)+10, SpriteHeight(Sprite)+10)
   ElseIf KeyboardReleased(#PB_Key_Multiply)
   Gamma.f + 0.01 : If Gamma.f > 1.4 : Gamma.f = 1.4 : EndIf
   ;ZoomSprite(Sprite, SpriteWidth(Sprite)-10, SpriteHeight(Sprite)-10)
   If Gamma.f = 0 : Gamma.f = 0.01 : EndIf
   EndIf
   
   If KeyboardReleased(#PB_Key_Pad0) : Gamma.f = 0.01 : EndIf
   If KeyboardReleased(#PB_Key_PadEnter) : Gamma.f = 1.4 : EndIf
   If KeyboardPushed(#PB_Key_Escape) <> 0 : Quit = 1 : Break : EndIf
    
   Repeat
   Event = WindowEvent()
   Until Event = 0
    
    t = ElapsedMilliseconds() 
    If t >= M1 + Timer
    If Psychedelic = 1
    If DrawPsychedelic = 0 : DrawPsychedelic = 1 : Else :  DrawPsychedelic = 0 : EndIf
    EndIf
    M1 = t
    EndIf
  
   StartDrawing(SpriteOutput(Sprite)) 
  
   If DrawPsychedelic = 0 
   DrawingMode(#PB_2DDrawing_Gradient|#PB_2DDrawing_Outlined)
   Else
   DrawingMode(#PB_2DDrawing_Gradient|#PB_2DDrawing_Outlined|#PB_2DDrawing_XOr)  
   EndIf
   
   ;ConicalGradient(x1,y1, Random(90))
   ;LinearGradient(screen_x*2, screen_y*2,screen_x, screen_y);EllipticalGradient(x1, y1, Random(Screen_X),Random(Screen_Y))
   
   ResetGradientColors()
   GradientColor(0.0, Farbe1)
   If Mode = 1 : GradientColor(0.5, Farbe2) : EndIf
   GradientColor(1.0, Farbe3)
   CircularGradient(x1, y1, Kreise)
   Circle(x1,y1, Radius * Abstand) 
   
   GradientColor(0.0, Farbe4)
   If Mode = 1 : GradientColor(0.5, Farbe5) : EndIf
   GradientColor(1.0, Farbe6)
   CircularGradient(x1, y1, Kreise)
   Circle(x2,y1, (Kreise - Radius + 1) * Abstand) 
   
   StopDrawing() 
     
 Next Radius
 Until Quit

 CloseWindow(0)
 End

EndProcedure

;****************************************************************************************************************

Procedure About()

 MessageRequester("Circles V2.1","    Copyright 2015 by Alexander Diaconu", #PB_MessageRequester_Ok) 

EndProcedure 


;****************************************************************************************************************

; Parameter1.s = ProgramParameter() : Fenster_ID.s
; If Len(Parameter1) > 2 
;  Fenster_ID = Mid(Parameter1,4,Len(Parameter1) - 3)
; Else 
;  Fenster_ID = ProgramParameter()
; EndIf 
; Parameter1 = Mid(Parameter1,2,1)
; 
; If FindString(Parameter1, "s",#PB_Ignore,#PB_String_NoCase) : Run() : EndIf
; If FindString(Parameter1, "c",#PB_Ignore,#PB_String_NoCase) : About() : EndIf

;Parameterabfrage mit Delay
;Repeat :  param.s= ProgramParameter() : Parameter1.s + param.s : Until param.s = "" ; : Debug parameter1.s : End
;If  FindString(Parameter1, "delay=",#PB_Ignore,#PB_String_NoCase)  :  pos = FindString(Parameter1, "delay=",#PB_Ignore,#PB_String_NoCase) : Delay=Val(Mid(Parameter1, pos+6 ))  : EndIf 

Run()
Repeat
PureBasic
ForEver
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Circles2.0

Post by Kwai chang caine »

Hello A.D. :D

After commented this line :wink:

Code: Select all

 ;If Not FileFingerprint("license.txt",#PB_Cipher_CRC32) = "b73ab90e" : End : EndIf
Very nice effect :shock:
Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
Post Reply