Sign in to follow this  
Followers 0
rush4hire

Simple graphic animation..

5 posts in this topic

This might not seem so spectacular, but I'm proud of it so I posted it..

Here is a simple graphic and it will be represented in just letters in small font..

but the thing to note is we have a small amount of data to start with, there are no external files.

The functions make 4 graphics out of one, and if you wanted, you could get 8, but you'd have to figure out how to rotate it at a 45 degree angle.. Which I might do later..

The initial graphic can be gained with a pixel mapping method.

So my next move is to use the GuiCtrlCreateGraphic functions to make a similar graphics with color :whistle:

Where each color can be represented with a single character, and we'll just have a square map to start with and spin it around..

It would make more sense to use an gif, I know, but I can't figure out how to put an animated gif in my gui .. lol .. and I've already invested too much time here to go back!

$begin = TimerInit()
$newchar = ""

$grspeed = 200      ; ms pause between changing pics
$guifont = "Courier New"
;~ $guifont = "Webdings"
; we start with a small graphic which can be created with an 
Global $grtxto[4]
$grtxto[0] = "" & _
"     @@@@@     "& @CRLF & _
"   @@@@@@@@@   "& @CRLF & _
"          @@@  "& @CRLF & _
"           @@@ "& @CRLF & _
"            @@ "& @CRLF & _
"             @@"& @CRLF & _
"             @@"& @CRLF & _
"             @@"& @CRLF & _
"             @@"& @CRLF & _
"@@@@@        @@"& @CRLF & _
"@@@@        @@ "& @CRLF & _
"@@@        @@@ "& @CRLF & _
"@@@@@     @@@  "& @CRLF & _
"@  @@@@@@@@@   "& @CRLF & _
"     @@@@@     "

If $newchar <> "" Then $grtxto[0] = StringReplace($grtxto[0], "@", $newchar)

$grtxto[1] = RotateLeft($grtxto[0])
$grtxto[2] = _StringRev($grtxto[0])
$grtxto[3] = _StringRev($grtxto[1])

Func RotateLeft($s)
    $a = StringSplit($s, @crlf, 1)
    $o = ''
    $sl = StringLen($a[1])
    dim $ao[$sl]
    
    For $i = $a[0] to 1 Step -1 
    $t = StringSplit($a[$i],'')
    For $ii = 0 to $sl-1
        $ao[$ii] &= $t[$ii+1]
    Next
Next
For $b in $ao
    $o &= @CRLF & $b
Next
;~  ; origional method; smaller, but more dangerous..
;~  For $l = 1 to $sl
;~      $o &= @CRLF
;~      For $i = $a[0]-1 to 1 step -1
;~          $o &= StringMid($a[$i], $l, 1)
;~      Next
;~  Next
    Return StringMid($o,3)
EndFunc


Func _StringRev($s)
    $o = ''
  For $i = StringLen($s) to 1 Step -1
      $o &= StringMid($s,$i,1)
  Next
  Return $o
EndFunc

; -- gui stuff
Opt("GUICloseOnESC",1)
Opt("GUIOnEventMode", 1)
$gui = GUICreate("graphtest", 200,200)
GUISetBkColor(0x000000)
$graph = GUICtrlCreateLabel("",20,20,50,50)
GUICtrlSetFont(-1, 1,600,-1,$guifont)
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetTip(-1, "is this tooltip flashing?"&@CRLF&"call 1-800-sry-imnoob..")
$timerinfo = GUICtrlCreateLabel("",10,180,150)
GUICtrlSetColor(-1, 0xffffff)
GUISetState()
GUISetOnEvent(-3, "_exit")
HotKeySet("{esc}","_exit")


Global $cct = 0

GUICtrlSetData($timerinfo, "Done in " & TimerDiff($begin))
While 1
    GUICtrlSetData($graph, $grtxto[$cct])
    $cct +=1
    If $cct > 3 Then $cct = 0
    sleep($grspeed)
WEnd


Func _exit()
    Exit
EndFuncoÝ÷ Øw«{l¶©¥ëa¡Ò.±çm¢­¶¬¶©'"·l~º&']r^±ì^r^Â'!Á«&i×­¡·¯z¼jËS+(è¬~Û§$jwp+^#¥z0©¢w­¢­{µÊ%¢¶§vØ^·©®nqëayÊ%¢¼"¶.¶-ßÛ ­ªaÇîËb¢{ºÚ"µÍÛY
Ì
BÎÎÈØZ][ÙH]HÝXÈXYIÌÌÎÂÛØ[  ÌÍÙXY×Ù[HH[SÜ[    ][ÝÛØÜ  ][ÝËJBÎÎÔØÜY[V
ÌBVNÎBÎÎßÎÎÎÔØÜY[V
VN
    ËKHÙH]HÝÞ[X]HÛÛÜÈÛH]]Ò]Ú[ÝÈ[ÈÛÛÌÍÞÝHÎBÌÍÛX^HH
ÌÍÞÝH
ÌBÌÍÛX^H
[H  ÌÍÝ[ÉÌÍÛX^KIÌÍÞÝBÜ  ÌÍÚHHÈXÝ[
    ÌÍÝ[
KLBIÌÍÝ[ÉÌÍÚWOI][ÝР   ][ÝÂ^Ü   ÌÍÚHH    ÌÍÞÝÈ  ÌÍÛX^    ÌÍÜÝH   ÌÍÞÝBIÌÍÞH   ÌÍÝ[Ú[HBÔ^[ÙXÚ
YÜYÚÝÛKÛÛÜËÚYK]X][ÛHËÝWH
B   ÌÍÞÉÌÍØÌWKIÌÍÞÝHH   ][ÝÈ  ][Ý  ÌÍÜÝH   ÌÍØÌWJÌBY  ÌÍÜÝH   ÌÍÛX^H[^]ÛÜUÑ[Ù][X   ÌÍÞ
B^[PÛÜÙJ ÌÍÙXY×Ù[JBÙÐÞ
    ÌÎNÉÌÎNË  ÌÎNÙÛIÌÎNÊB[ÈÙ][X  ÌÍØBBSØØ[  ÌÍÞH ][ÝÉ][ÝÂBQÜ    ÌÍÚHHÈPÝ[
    ÌÍØKLBBBBIÌÍÞ [ÏH    ÌÍØÉÌÍÚWBBS^[UÜ]S[J ÌÍÙXY×Ù[K  ÌÍÞ
B[[Â
1 person likes this

Share this post


Link to post
Share on other sites



cool, looking forward to color and other enhancements

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Nice, looks cool.

Share this post


Link to post
Share on other sites

I'm surprised this works.

Here's a simple pixel method to get pixels

You would have to adjust it for your pic

sleep(4000)
;;; wait till we have our pic ready!
;;;~ 0xE9EDF7 is the 1st pixel in our pic surrounded by black
;~ $temp = PixelSearch(620,380,645,395,0xE9EDF7, 20)
;~ 632/392
;~ InputBox("","",$temp[0] &"/" &$temp[1])
;~ Exit
;~ $temp = PixelSearch(0,0,635,385,15330807, 20)
$xstart = 632;$temp[0]
$ystart = 392;$temp[1]
$xend = $xstart + 15; only a 16 x 16 pixel pic
$yend = $ystart + 15

Global $debug_file = FileOpen("ocr.txt", 1)
Global $pixdic = ObjCreate("Scripting.Dictionary")
$xc = 0
$yc = 0
$c = 0
Global $pooparr[200]
;;;~ We'll create a dictionary with colors as keys and coords as items. And later make map with this.
For $y = $ystart to $yend
    For $x = $xstart to $xend
        $p = PixelGetColor($x, $y)
        $s = ","& $xc & "," &$yc
        If $pixdic.Exists($p) Then
            $pooparr[$pixdic.Item($p)] &= $s
;;;;;;;;  We had a problem with the $pixdic.Item
;;;~            $t = $pixdic.Item($p)
;;;~            $pixdic.Item($p) = $pixdic.Item($p) & $s
;;;~            $pixdic.Item($p) = $t & $s
        Else
            $pooparr[$c] = $s
            $pixdic.Add($p, $c)
            $c +=1
        EndIf
        $xc +=1
    Next
    $yc +=1
    $xc = 0
Next

$o = ''
For $k in $pixdic.Keys
    $o &= @CRLF & Hex($k,6) &"="& $pooparr[$pixdic.Item($k)]
Next
    
FileWrite("pic.txt", StringMid($o,3))
    MsgBox(0,'','done')

oÝ÷ ØýËZ®Ø§­åÉ­zÇ^¥Zbríç"­É^¶­²§³^*.¢§k§v"Ø^ìºèÂÇ«J^­íý²Ø^¢ëiº×ë¢kajÙ¶N¤{+­ç(ìjwméî·«±ªÞ¶±ÉÊxOD^

Now I will work on rotating and flipping the pic

Share this post


Link to post
Share on other sites

I can't believe you can't use GUISetState($var, $SW_SHOW) on these graphics..

You have to recreate the whole graphic, which causes everything on the screen to flash...

Global $grs[4]
#include <GUIConstantsEx.au3>
$begin = TimerInit()
$grspeed = 200      ; ms pause between changing pic

Func Loadpixarr()
    $barr = StringSplit(FileRead("pic.txt"),@CRLF,1)
    Global $pixarr[$barr[0]][2]
    For $i = 0 to $barr[0]-1
        $t = StringSplit($barr[$i+1],"=,",1)
        $pixarr[$i][0] = Dec($t[1])
        $pixarr[$i][1] = StringSplit($t[2],",")
    Next
EndFunc
Loadpixarr()
; -- gui stuff
Opt("GUICloseOnESC",1)
Opt("GUIOnEventMode", 1)
$gui = GUICreate("graphtest", 240,240)
GUISetBkColor(0x000000)
$timerinfo = GUICtrlCreateLabel("",10,180,150)
GUICtrlSetColor(-1, 0xffffff)
GUISetOnEvent(-3, "_exit")
HotKeySet("{esc}","_exit")

GUISetState()

Global $cposx = 0
Global $cposy = 0
Func Makegr1($e, $width, $hight)
;~ $grs[$e] = GUICtrlCreateGraphic(20+($e*20),20+($e*20),$width,$width)
;~ $grs[$e] = GUICtrlCreateGraphic(20,20,$width,$width)
$grs[$e] = GUICtrlCreateGraphic($cposx, $cposy, $width, $width)
$halfwidth = Round($width / 2, 0)
$halfhight = Round($hight / 2, 0)
For $ii = 0 to UBound($pixarr)-1
    $xy = $pixarr[$ii][1]
    GUICtrlSetGraphic( -1, $GUI_GR_COLOR, $pixarr[$ii][0] )
    For $i = 1 to $xy[0]-1 Step 2
        $x = $xy[$i]-$halfwidth
        $y = $xy[$i+1]-$halfhight
        If $e = 1 Then
            $x *= -1
            $y *= -1
        EndIf
        GUICtrlSetGraphic( -1, $GUI_GR_PIXEL, $x+$halfwidth, $y+$halfhight )
    Next
Next
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
EndFunc
Makegr1(0, 16, 16)
Makegr1(1, 16, 16)



Global $cct = 0
GUICtrlSetData($timerinfo, "Done in " & TimerDiff($begin))
While 1
Makegr1($cct, 16, 16)
    
    $cct +=1
    If $cct > 1 Then $cct = 0
;~  GUICtrlSetState($grs[$cct], $GUI_SHOW)
;~  $cct +=1
;~  If $cct > 1 Then $cct = 0
    sleep($grspeed)
    $cposx +=16
    If $cposx > 240 Then
        $cposx = 0
        $cposy += 16
    EndIf
WEnd

Func _exit()
    Exit
EndFunc

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