Jump to content

Slow Graphic


toonboon
 Share

Recommended Posts

When a lot of seperate dots are painted onto a graphic, and I refresh it the refreshing is quite slow. Is there some way of making this not slow?

I was thinking of saving it to a file and painting the new dots over that image everytime. How would I accomplish something like this?

My code so far, just for recreating the slow load problem.

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

$time = TimerInit()
$gui = GUICreate("", @DesktopWidth+20, @DesktopHeight+20, -10, -10, $WS_POPUP, 0x2000000)
;~ GUISetCursor(16, 1)
GUICtrlCreateGraphic(0, 0, @DesktopWidth+20, @DesktopHeight+20)
GUICtrlSetBkcolour(-1, 0x000000)
GUISetState()
$colour = 0xff0000
GUICtrlSetGraphic(-1, $GUI_GR_colour, $colour, $colour)

For $rept = 1 To 15
    $x = Random(0, @DesktopWidth, 1)
    $y = Random(0, @DesktopHeight, 1)
    $c = 0
    $v = Random(1,60,1)
    $overlay = Random(0,16777215,1)
    $opmin = 100 / (10 * $v)
    For $b = 0 To $v * 10
        $opacity = 100 - $opmin * $b
        For $a = 1 To 360
            $a += $c - 1
            $c = Random(1, $b + 10, 1)
            $pi = 3.14159265358979
            $cos = Cos($pi * ($a / 180))
            $sin = Sin($pi * ($a / 180))
            $col = PixelGetcolour($x + $b * $cos, $y + $b * $sin)
            $colour = Colour($col, $overlay, $opacity)
            GUICtrlSetGraphic(-1, $GUI_GR_colour, $colour, $colour)
            GUICtrlSetGraphic(-1, $GUI_GR_DOT, $x + $b * $cos, $y + $b * $sin)
        Next
    Next
    GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
Next
MsgBox(0, '', '')

Func Colour($base, $over, $op)
    $over = StringTrimLeft(Hex($over), 2)
    $base = StringTrimLeft(Hex($base), 2)
    $1h1 = StringMid($over, 1, 2)
    $1h2 = StringMid($over, 3, 2)
    $1h3 = StringMid($over, 5, 2)
    $2h1 = StringMid($base, 1, 2)
    $2h2 = StringMid($base, 3, 2)
    $2h3 = StringMid($base, 5, 2)

    $1d1 = Dec($1h1)
    $1d2 = Dec($1h2)
    $1d3 = Dec($1h3)
    $2d1 = Dec($2h1)
    $2d2 = Dec($2h2)
    $2d3 = Dec($2h3)

    $Red = ($op * $1d1 + (100 - $op) * $2d1) / 100
    $Green = ($op * $1d2 + (100 - $op) * $2d2) / 100
    $Blue = ($op * $1d3 + (100 - $op) * $2d3) / 100

    Return Dec(StringRight(Hex($Red), 2) & StringRight(Hex($Green), 2) & StringRight(Hex($Blue), 2))
EndFunc   ;==>Colour

[right]~What can I say, I'm a Simplistic person[/right]

Link to comment
Share on other sites

Try to use SetPixel()

Func SetPixel ($handle, $x, $y, $color)
    $dc= DllCall ("user32.dll", "int", "GetDC", "hwnd", $handle)
    $setpixel= DllCall ("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $x, "long", $y, "long", $color)
    $realesedc= DllCall ("user32.dll", "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...