Sign in to follow this  
Followers 0
Skrip

Playing with PixelDraw()

17 posts in this topic

#1 ·  Posted (edited)

Run it for like 30 seconds and watch how much it changes your screen. It's pretty cool.

Or open up paint, expand the canvas to your whole screen, fill in black, then run it.

Play around with the comments too. Uncomment them and run it again.

Global $handle = DLLCall("user32.dll","long","GetDC","hwnd",0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$x = 0
$y = 0
$x2 = @DesktopWidth
$y2 = @DesktopHeight
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
While 1
    For $j = 0 to @DesktopHeight
        For $i = @DesktopWidth to 0 step -1
            PixelDraw($i, $j, Random(0x000000,0xFFFFFF,1))
        Next
    Next
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;~ Do
;~  Do
;~      $x = $x + 1
;~      PixelDraw($x, $y, 0x000000)
    ;PixelDraw($x, $y, Random(0x000000,0xFFFFFF,1)); Uncomment me and comment the line above
;~  Until $x = $x2
;~  $y = $y + 1
;~  $x = 0
;~ Until $y = $y2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;~ While 1
;~  PixelDraw(Random(0, @DesktopWidth, 0), Random(0, @DesktopHeight, 0), Random(0x000000,0xFFFFFF,1))
;~ WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func PixelDraw($XCoord, $YCoord, $Color)
   DllCall("gdi32","long","SetPixel", "long",$handle[0], "long", $XCoord, "long", $YCoord, "long", $Color)
EndFunc
Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites



Yeah Firestorm, :) Perfect, I like it !


My projects : GCS Search 1.07 (GUI Control Styles Search)* Multilingual tool to help about the old scripts, with a dynamic menu.* Easy way to find missing Include files in old scripts downloaded from forums !* Famous Monoceres script added and improved (visual, drag and drop, automatic)* There is an interactive color converter with palettes too, for fun !The best way to start Autoit3 development (for newbies).

Share this post


Link to post
Share on other sites

Wow...Awesome!!

Share this post


Link to post
Share on other sites

very fun.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

i modified this so that it looks like this

While 1
    For $j = 0 to @DesktopHeight
        For $i = @DesktopWidth to 0 step -1
            PixelDraw($i, $j, 0x000000, $hwnd)
        Next
    Next
WEnd
Edited by mmavipc

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

Share this post


Link to post
Share on other sites

What is the fourth aug?


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

Hello my good sirs

wanted to congradulate you on a script well done.

this would make an asom screensaver


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

Hell yeah it would.

mmavipc, I added yours to the OP.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Hell yeah it would.

mmavipc, I added yours to the OP.

I just make a starry night screensaver with this :)

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=starrynight.scr
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <string.au3>
#include <GUIConstantsEx.au3>
#include <windowsconstants.au3>
#include <ScreenCapture.au3>
If $cmdline[0] > 0 Then
    If $cmdline[1] = "/p" Then
        _runpreview($cmdline[2])
    EndIf
EndIf
_run()
Func _run()
    WinMinimizeAll()
    Sleep(100)
    $gui = GUICreate("screensaver123456789", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
    _ScreenCapture_Capture("screen.jpg", 0, 0, -1, -1, False)
    $graphic = GUICtrlCreatePic("screen.jpg", 0, 0, @DesktopWidth, @DesktopHeight)
    GUISetCursor(16, 1)
    GUISetState()
    Global $hwnd = DllCall("user32.dll", "long", "GetDC", "hwnd", $gui)
    Dim $int = 0
    $oldmouse = GUIGetCursorInfo()
    For $j = 0 To @DesktopHeight
        For $i = @DesktopWidth To 0 Step -1;
            $int = $int + 1
            _sr()
            $num = Random(0, 255, 1)
            ;ConsoleWrite($num & @crlf)
            $num = _StringToHex($num)
            $num = $num & $num & $num
            $num = Dec($num)
            PixelDraw($i, $j, $num, $hwnd)
            _sr()
            $num = Random(0, 255, 1)
            ;ConsoleWrite($num & @crlf)
            $num = _StringToHex($num)
            $num = $num & $num & $num
            $num = Dec($num)
            _sr()
            $w = Random(0, @DesktopWidth, 0)
            _sr()
            $h = Random(0, @DesktopHeight, 0)
            PixelDraw($w, $h, $num, $hwnd)
            $newmouse = GUIGetCursorInfo()
            If $newmouse[0] <> $oldmouse[0] Or $newmouse[0] <> $oldmouse[0] Then
                Exit
            EndIf
        Next
    Next
    While 1
        _sr()
        $num = Random(0, 255, 1)
        ;ConsoleWrite($num & @crlf)
        $num = _StringToHex($num)
        $num = $num & $num & $num
        $num = Dec($num)
        _sr()
        $w = Random(0, @DesktopWidth, 0)
        _sr()
        $h = Random(0, @DesktopHeight, 0)
        PixelDraw($w, $h, $num, $hwnd)
        $newmouse = GUIGetCursorInfo()
        If $newmouse[0] <> $oldmouse[0] Or $newmouse[0] <> $oldmouse[0] Then
            Exit
        EndIf
    WEnd
EndFunc   ;==>_run
Func _runpreview($hwndd)
    WinMinimizeAll()
    Sleep(100)
    $gui = GUICreate("screensaver123456789", 152, 112, 0, 0, $WS_POPUP, -1, HWnd($hwndd))
    _ScreenCapture_Capture("screen.jpg", 0, 0, -1, -1, False)
    $graphic = GUICtrlCreatePic("screen.jpg", 0, 0, 152, 112)
    GUISetCursor(16, 1)
    GUISetState()
    Global $hwnd = DllCall("user32.dll", "long", "GetDC", "hwnd", $gui)
    Dim $int = 0
    $oldmouse = GUIGetCursorInfo()
    For $j = 0 To 112
        For $i = 152 To 0 Step -1;
            $int = $int + 1
            _sr()
            $num = Random(0, 255, 1)
            ;ConsoleWrite($num & @crlf)
            $num = _StringToHex($num)
            $num = $num & $num & $num
            $num = Dec($num)
            PixelDraw($i, $j, $num, $hwnd)
            _sr()
            $num = Random(0, 255, 1)
            ;ConsoleWrite($num & @crlf)
            $num = _StringToHex($num)
            $num = $num & $num & $num
            $num = Dec($num)
            _sr()
            $w = Random(0, @DesktopWidth, 0)
            _sr()
            $h = Random(0, @DesktopHeight, 0)
            PixelDraw($w, $h, $num, $hwnd)
            $newmouse = GUIGetCursorInfo()
            If $newmouse[0] <> $oldmouse[0] Or $newmouse[0] <> $oldmouse[0] Then
                Exit
            EndIf
        Next
    Next
    While 1
        _sr()
        $num = Random(0, 255, 1)
        ;ConsoleWrite($num & @crlf)
        $num = _StringToHex($num)
        $num = $num & $num & $num
        $num = Dec($num)
        _sr()
        $w = Random(0, @DesktopWidth, 0)
        _sr()
        $h = Random(0, @DesktopHeight, 0)
        PixelDraw($w, $h, $num, $hwnd)
        $newmouse = GUIGetCursorInfo()
        If $newmouse[0] <> $oldmouse[0] Or $newmouse[0] <> $oldmouse[0] Then
            Exit
        EndIf
    WEnd
EndFunc   ;==>_runpreview
Func PixelDraw($XCoord, $YCoord, $Color, $handle)
    DllCall("gdi32", "long", "SetPixel", "long", $handle[0], "long", $XCoord, "long", $YCoord, "long", $Color)
EndFunc   ;==>PixelDraw
Func _sr()
    $time = TimerInit()
    ;$time = TimerDiff($time)
    $time = Round($time)
    SRandom($time)
    ;ConsoleWrite($time & @crlf)
    SRandom(Round((TimerInit() * Random(1234, 3335789) + TimerInit()) / TimerInit()))
EndFunc   ;==>_sr

It makes your screen look like a starry night obviously.

edit:Nice new avatar Firestorm

Edited by mmavipc

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

Share this post


Link to post
Share on other sites

Cool code. I like the effect. And thank you.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

I just make a starry night screensaver with this :)

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=starrynight.scr
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <string.au3>
#include <GUIConstantsEx.au3>
#include <windowsconstants.au3>
#include <ScreenCapture.au3>
If $cmdline[0] > 0 Then
    If $cmdline[1] = "/p" Then
        _runpreview($cmdline[2])
    EndIf
EndIf
_run()
Func _run()
    WinMinimizeAll()
    Sleep(100)
    $gui = GUICreate("screensaver123456789", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
    _ScreenCapture_Capture("screen.jpg", 0, 0, -1, -1, False)
    $graphic = GUICtrlCreatePic("screen.jpg", 0, 0, @DesktopWidth, @DesktopHeight)
    GUISetCursor(16, 1)
    GUISetState()
    Global $hwnd = DllCall("user32.dll", "long", "GetDC", "hwnd", $gui)
    Dim $int = 0
    $oldmouse = GUIGetCursorInfo()
    For $j = 0 To @DesktopHeight
        For $i = @DesktopWidth To 0 Step -1;
            $int = $int + 1
            _sr()
            $num = Random(0, 255, 1)
            ;ConsoleWrite($num & @crlf)
            $num = _StringToHex($num)
            $num = $num & $num & $num
            $num = Dec($num)
            PixelDraw($i, $j, $num, $hwnd)
            _sr()
            $num = Random(0, 255, 1)
            ;ConsoleWrite($num & @crlf)
            $num = _StringToHex($num)
            $num = $num & $num & $num
            $num = Dec($num)
            _sr()
            $w = Random(0, @DesktopWidth, 0)
            _sr()
            $h = Random(0, @DesktopHeight, 0)
            PixelDraw($w, $h, $num, $hwnd)
            $newmouse = GUIGetCursorInfo()
            If $newmouse[0] <> $oldmouse[0] Or $newmouse[0] <> $oldmouse[0] Then
                Exit
            EndIf
        Next
    Next
    While 1
        _sr()
        $num = Random(0, 255, 1)
        ;ConsoleWrite($num & @crlf)
        $num = _StringToHex($num)
        $num = $num & $num & $num
        $num = Dec($num)
        _sr()
        $w = Random(0, @DesktopWidth, 0)
        _sr()
        $h = Random(0, @DesktopHeight, 0)
        PixelDraw($w, $h, $num, $hwnd)
        $newmouse = GUIGetCursorInfo()
        If $newmouse[0] <> $oldmouse[0] Or $newmouse[0] <> $oldmouse[0] Then
            Exit
        EndIf
    WEnd
EndFunc   ;==>_run
Func _runpreview($hwndd)
    WinMinimizeAll()
    Sleep(100)
    $gui = GUICreate("screensaver123456789", 152, 112, 0, 0, $WS_POPUP, -1, HWnd($hwndd))
    _ScreenCapture_Capture("screen.jpg", 0, 0, -1, -1, False)
    $graphic = GUICtrlCreatePic("screen.jpg", 0, 0, 152, 112)
    GUISetCursor(16, 1)
    GUISetState()
    Global $hwnd = DllCall("user32.dll", "long", "GetDC", "hwnd", $gui)
    Dim $int = 0
    $oldmouse = GUIGetCursorInfo()
    For $j = 0 To 112
        For $i = 152 To 0 Step -1;
            $int = $int + 1
            _sr()
            $num = Random(0, 255, 1)
            ;ConsoleWrite($num & @crlf)
            $num = _StringToHex($num)
            $num = $num & $num & $num
            $num = Dec($num)
            PixelDraw($i, $j, $num, $hwnd)
            _sr()
            $num = Random(0, 255, 1)
            ;ConsoleWrite($num & @crlf)
            $num = _StringToHex($num)
            $num = $num & $num & $num
            $num = Dec($num)
            _sr()
            $w = Random(0, @DesktopWidth, 0)
            _sr()
            $h = Random(0, @DesktopHeight, 0)
            PixelDraw($w, $h, $num, $hwnd)
            $newmouse = GUIGetCursorInfo()
            If $newmouse[0] <> $oldmouse[0] Or $newmouse[0] <> $oldmouse[0] Then
                Exit
            EndIf
        Next
    Next
    While 1
        _sr()
        $num = Random(0, 255, 1)
        ;ConsoleWrite($num & @crlf)
        $num = _StringToHex($num)
        $num = $num & $num & $num
        $num = Dec($num)
        _sr()
        $w = Random(0, @DesktopWidth, 0)
        _sr()
        $h = Random(0, @DesktopHeight, 0)
        PixelDraw($w, $h, $num, $hwnd)
        $newmouse = GUIGetCursorInfo()
        If $newmouse[0] <> $oldmouse[0] Or $newmouse[0] <> $oldmouse[0] Then
            Exit
        EndIf
    WEnd
EndFunc   ;==>_runpreview
Func PixelDraw($XCoord, $YCoord, $Color, $handle)
    DllCall("gdi32", "long", "SetPixel", "long", $handle[0], "long", $XCoord, "long", $YCoord, "long", $Color)
EndFunc   ;==>PixelDraw
Func _sr()
    $time = TimerInit()
    ;$time = TimerDiff($time)
    $time = Round($time)
    SRandom($time)
    ;ConsoleWrite($time & @crlf)
    SRandom(Round((TimerInit() * Random(1234, 3335789) + TimerInit()) / TimerInit()))
EndFunc   ;==>_sr

It makes your screen look like a starry night obviously.

edit:Nice new avatar Firestorm

waited 15 minits. still not done. any way to speed it up?

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

waited 15 minits. still not done. any way to speed it up?

I don't know about his code. But the reason the other codes posted are slow, is because it needs to set each pixel at a time...and that takes awhile. I don't know any way to speed 'em up.

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

waited 15 minits. still not done. any way to speed it up?

The reason it's slow is becuase of 2 or 3 things things

1. it has to graph each pixel individually

2. it has to calculate a random seed

3.your desktop resoulotion is too big.


[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

2. it has to calculate a random seed

Why do you constantly provide a new seed? It is hardly required to have "real" random numbers, as opposed to having speed. The in-built random function works good enough for your purpose.

Edit: If you were wondering why it is so slow, there are a number of reasons. Look at the following comparison:

From:

$int = $int + 1
            _sr()
            $num = Random(0, 255, 1)
            ;ConsoleWrite($num & @crlf)
            $num = _StringToHex($num)
            $num = $num & $num & $num
            $num = Dec($num)
            PixelDraw($i, $j, $num, $hwnd)
            _sr()
            $num = Random(0, 255, 1)
            ;ConsoleWrite($num & @crlf)
            $num = _StringToHex($num)
            $num = $num & $num & $num
            $num = Dec($num)
            _sr()
            $w = Random(0, @DesktopWidth, 0)
            _sr()
            $h = Random(0, @DesktopHeight, 0)
            PixelDraw($w, $h, $num, $hwnd)
            $newmouse = GUIGetCursorInfo()
            If $newmouse[0] <> $oldmouse[0] Or $newmouse[0] <> $oldmouse[0] Then
                Exit
            EndIfoÝ÷ Ù:ºÚ"µÍ ÌÍÛ[HH[ÛJJBÉÌÍÛ[HHÔÝ[ÕÒ^
    ÌÍÛ[JBBBIÌÍÛ[HH^
    ÌÍÛ[KB   ÌÍÛ[HH   ÌÍÛ[H    [È ÌÍÛ[H    [È ÌÍÛ[BBBBÉÌÍÛ[HHXÊ   ÌÍÛ[JBBBBBBNÐÛÛÛÛUÜ]J  ÌÍÛ[H    [ÈÜBBBB^[]Ê  ÌÍÚK ÌÍÚ  ÌÍÛ[K    ÌÍÚÛ
BÉÌÍÛ[HH[ÛJJBÐÛÛÛÛUÜ]J   ÌÍÛ[H    [ÈÜBÉÌÍÛ[HHÔÝ[ÕÒ^
    ÌÍÛ[JBBBNÉÌÍÛ[HH^
    ÌÍÛ[KBÉÌÍÛ[HH    ÌÍÛ[H    [È ÌÍÛ[H    [È ÌÍÛ[BÉÌÍÛ[HHXÊ  ÌÍÛ[JB   ÌÍÝÈH[ÛJÚÝÜÚYJB    ÌÍÚH[ÛJÚÝÜZYÚJB^[]Ê    ÌÍÝË    ÌÍÚ  ÌÍÛ[K    ÌÍÚÛ
BBBB    ÌÍÛ]Û[ÝÙHHÕRQÙ]ÝÛÜ[Ê
BYÜÔ  ÌÍÛ]Û[ÝÙVÌH  ÉÝÈ  ÌÍÛÛ[ÝÙVÌH[^][Y
Edited by Manadar

Share this post


Link to post
Share on other sites

I don't know about his code. But the reason the other codes posted are slow, is because it needs to set each pixel at a time...and that takes awhile. I don't know any way to speed 'em up.

i geuss if theres no way to speed it up, then this will have to do. how do you make it a screensaver? i couldnt find a thread about how to make screensavers ( only ones showing off there screen savors )


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

i geuss if theres no way to speed it up, then this will have to do. how do you make it a screensaver? i couldnt find a thread about how to make screensavers ( only ones showing off there screen savors )

Manadar's code speeds up that screensaver script. But the way the pixel is drawn (one by one) is the slow part.. I don't think there is a way to speed it up.

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

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  
Followers 0