Jump to content
Sign in to follow this  
jaberwacky

Would This Make A Cool Screen Saver?

Recommended Posts

jaberwacky

It's a buggy, ugly, and nasty proof of concept at this stage. Tell me what ya'll think.

newest version

Worked out the double buffer by looking at these examples by UEZ: (http://www.autoitscript.com/forum/index.php?showtopic=87200&st=0&p=625623&#entry625623)

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;~ #include <HandyFunctions.au3>
#include <array.au3>

HotKeySet("{ESC}", "_terminate")

OnAutoItExitRegister("_endGDI")

Global $DW = @DesktopWidth, $DH = @DesktopHeight, $penWidth = 5, $penColor, $brushColor
Global $X, $Y, $color, $circleWidth = 1000, $radius = $circleWidth / 2, $XYBound = $penWidth + 5

Global $GUI = GUICreate("ScreenSaver", $DW, $DH, 0, 0, $WS_POPUP)

GUISetState()

_GDIPlus_Startup()

Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($GUI)
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($DW, $DH, $hGraphics)
Global $backBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Global $hPen = _GDIPlus_PenCreate(0x77000000, $penWidth)
Global $hBrush = _GDIPlus_BrushCreateSolid()

;~ _GDIPlus_GraphicsClear($backBuffer)

Do
    $color = _Color()
    $brushColor = _Color()

    $X = Random($XYBound, $DW - $XYBound, 1)
    $Y = Random($XYBound, $DH - $XYBound, 1)

    If $X < $Y Then
        $circleWidth = $DH - $Y
    Else
        $circleWidth = $DW - $X
    EndIf

    For $i = $penWidth To $circleWidth Step $penWidth
        _drawCircle()
;~      Sleep(1)
    Next

    For $i = $circleWidth To $penWidth Step -$penWidth
        _drawCircle()
;~      Sleep(1)
    Next
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Exit

Func _drawCircle()
    _GDIPlus_GraphicsClear($backBuffer, $color)
    _GDIPlus_BrushSetSolidColor($hBrush, $brushColor)
    _GDIPlus_PenSetColor($hPen, $brushColor)
    _GDIPlus_GraphicsFillEllipse($backBuffer, $X, $Y, $i, $i, $hBrush)
    _GDIPlus_GraphicsDrawEllipse($backBuffer, $X, $Y, $i, $i, $hPen)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $DW, $DH)
EndFunc ;==>_drawCircle

Func _Color()
    Local $hexColor = "0xFF" & Hex(Random(0, 255, 1) & Random(0, 255, 1) & Random(0, 255, 1), 6)

    If $hexColor = 0xFF000000 Then
        _Color()
    Else
        Return $hexColor
    EndIf
EndFunc ;==>_backGroundColor

Func _endGDI()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    _terminate()
EndFunc ;==>_endGDI

Func _terminate()
    Exit (0)
EndFunc ;==>_terminate
Edited by jaberwocky6669

Share this post


Link to post
Share on other sites
somdcomputerguy
C:\Users\Public\screensavertest.au3(6,10) : ERROR: can't open include file <HandyFunctions.au3>

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
somdcomputerguy

It runs fine now.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
AdmiralAlkex
  • The circle flickers to much, it hurts my eyes. Take a look at the GDI+ scripts that float around and see what they do to avoid that.
  • What MvGulik said. It's pretty annoying with the quick color jumps, some fading would be nice.
Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×