Sign in to follow this  
Followers 0
dexxa

Graph Drawer

7 posts in this topic

#1 ·  Posted (edited)

i wrote this just for fun. there is absolutely nothing amazing about this program. all basic stuffs.

it draws series of dots on the screen. and there is something wrong with the color sliders.

appreciate feedbacks.

#include "Guiconstants.au3"
;GUIS
;main window
$main = GUICreate("---Drawer---",400,320,850,600)
GUISetState()

;color sliders
$sliderr = GUICtrlCreateSlider (5,75,150,20)
GUICtrlSetLimit(-1,255,0)
GUICtrlSetData($sliderr,0)
$sliderg = GUICtrlCreateSlider (5,95,150,20)
GUICtrlSetLimit(-1,255,0)
GUICtrlSetData($sliderg,0)
$sliderb = GUICtrlCreateSlider (5,115,150,20)
GUICtrlSetLimit(-1,255,0)
GUICtrlSetData($sliderb,0)

$meter = "0x"&Hex(guictrlread($sliderr),2)&Hex(guictrlread($sliderg),2)&Hex(guictrlread($sliderb),2)
;color display
$label = GUICtrlCreateLabel("",10,10,50,50)
GUICtrlSetBkColor($label,$meter)

;color reading
GUICtrlCreateLabel("Red",155,115,25,15)
GUICtrlCreateLabel("Green",155,95,30,15)
GUICtrlCreateLabel("Blue",155,75,25,15)
$reading = GUICtrlCreateLabel($meter, 80,30,50,20)

;button
$butt = GUICtrlCreateButton("Draw", 200,10,190,50)
$exit = GUICtrlCreateButton("Exit", 200,70,190,50)

;lists
GUICtrlCreateLabel("X:", 10,175)
GUICtrlCreateLabel("Y:", 100,175)
$xlist = GUICtrlCreateList("", 25,150, 70, 90)
GUICtrlSetData($xlist, "Sin|Cos|Tan|Cot|Sec|Csc","Sin")
$ylist = GUICtrlCreateList("", 125,150, 70, 90)
GUICtrlSetData($ylist, "Sin|Cos|Tan|Cot|Sec|Csc","Cos")

;inputs why do i use edit???
GUICtrlCreateLabel("Dots:",200,152)
$edit1 = GUICtrlCreateInput("500",235,150,40,20,$ES_NUMBER)
GUICtrlCreateLabel("X Position:",200,175)
$edit2 = GUICtrlCreateInput("500",255,173,30,20,$ES_NUMBER)
GUICtrlCreateLabel("Y Position:",295,175)
$edit3 = GUICtrlCreateInput("500",350,173,30,20,$ES_NUMBER)
GUICtrlCreateLabel("X Radius:",200,199)
$edit4 = GUICtrlCreateInput("75",255,198,30,20,$ES_NUMBER)
GUICtrlCreateLabel("Y Radius:",295,199)
$edit5 = GUICtrlCreateInput("75",350,198,30,20,$ES_NUMBER)
GUICtrlCreateLabel("X Shape:",200,223)
$edit6 = GUICtrlCreateInput("0.1",255,223,30,20)
GUICtrlCreateLabel("Y Shape:",295,223)
$edit7 = GUICtrlCreateInput("0.1",350,223,30,20)

;change 1
$check = GUICtrlCreateCheckbox("",10,250,20,20)
GUICtrlCreateLabel("Change",30,250,50,20)
$combo = GUICtrlCreateCombo("",87,250,70,20)
GUICtrlSetData($combo,"X Position|Y Position|X Radius|Y Radius|X Shape|Y Shape","X Position")
GUICtrlCreateLabel("From", 160,250,50,20)
$inputfrom = GUICtrlCreateInput("100",190,250,30,20)
GUICtrlCreateLabel("To", 225,250,20,20)
$inputto = GUICtrlCreateInput("500",245,250,30,20)
GUICtrlCreateLabel("by", 282,250,20,20)
$inputby = GUICtrlCreateInput("100",300,250,30,20)
GUICtrlCreateLabel("at a time", 340,250,60,20)
;change 2
$check2 = GUICtrlCreateCheckbox("",10,280,20,20)
GUICtrlCreateLabel("Change",30,280,50,20)
$combo2 = GUICtrlCreateCombo("",87,280,70,20)
GUICtrlSetData($combo2,"X Position|Y Position|X Radius|Y Radius|X Shape|Y Shape","Y Position")
GUICtrlCreateLabel("From", 160,280,50,20)
$inputfrom2 = GUICtrlCreateInput("100",190,280,30,20)
GUICtrlCreateLabel("To", 225,280,20,20)
$inputto2 = GUICtrlCreateInput("500",245,280,30,20)
GUICtrlCreateLabel("by", 282,280,20,20)
$inputby2 = GUICtrlCreateInput("100",300,280,30,20)
GUICtrlCreateLabel("at a time", 340,280,60,20)
;GUIS


;DRAWER DLL CALLERS
$handle = ""
$DCdll = DllOpen("user32.dll")
$GDIdll = DllOpen("gdi32.dll")
$dc= DllCall ($DCdll, "int", "GetDC", "hwnd", $handle)
;DRAWER DLL CALLERS


$done = 0
While 1
    $msg = GUIGetMsg()
    
    $meter = "0x"&Hex(guictrlread($sliderr),2)&Hex(guictrlread($sliderg),2)&Hex(guictrlread($sliderb),2)
    GUICtrlSetBkColor($label,"0x"&Hex(guictrlread($sliderb),2)&Hex(guictrlread($sliderg),2)&Hex(guictrlread($sliderr),2))
    GUICtrlSetData($reading,$meter)
    sleep(35)
    
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    ElseIf $msg = $butt Then;draws
    ;increment part
        If GUICtrlRead($check) = $GUI_CHECKED Or GUICtrlRead($check2) = $GUI_CHECKED Then
            If GUICtrlRead($inputfrom) = "" Or GUICtrlRead($inputto) = "" Or GUICtrlRead($inputby) = "" And GUICtrlRead($check) = $GUI_CHECKED Then
                MsgBox(0,"Error","Must Enter Values")
                Exit
            EndIf
            If GUICtrlRead($inputfrom2) = "" Or GUICtrlRead($inputto2) = "" Or GUICtrlRead($inputby2) = "" And GUICtrlRead($check2) = $GUI_CHECKED Then
                MsgBox(0,"Error","Must Enter Values")
                Exit
            EndIf
            
        If GUICtrlRead($check) = $GUI_CHECKED Then
            $whattochange = Guictrlread($combo)
            If $whattochange = "X Position" Then
                $object = $edit2
            ElseIf $whattochange = "Y Position" Then
                $object = $edit3
            ElseIf $whattochange = "X Radius"Then
                $object = $edit4
            ElseIf $whattochange = "Y Radius" Then
                $object = $edit5
            ElseIf $whattochange = "X Shape" Then
                $object = $edit6
            ElseIf $whattochange = "Y Shape" Then
                $object = $edit7
            EndIf
            $from = GUICtrlRead($inputfrom)
            $to = GUICtrlRead($inputto)
            $step = guictrlread($inputby)
            If $from > $to Then
                $step = -$step
            EndIf   
            $count = ($from - $to)/$step
            $i = $from
        EndIf
        
        If GUICtrlRead($check2) = $GUI_CHECKED  Then
            $whattochange2 = GUICtrlRead($combo2)
            If $whattochange2 = "X Position" Then
                $object2 = $edit2
            ElseIf $whattochange2 = "Y Position" Then
                $object2 = $edit3
            ElseIf $whattochange2 = "X Radius"Then
                $object2 = $edit4
            ElseIf $whattochange2 = "Y Radius" Then
                $object2 = $edit5
            ElseIf $whattochange2 = "X Shape" Then
                $object2 = $edit6
            ElseIf $whattochange2 = "Y Shape" Then
                $object2 = $edit7
            EndIf
            $from2 = GUICtrlRead($inputfrom2)
            $to2 = GUICtrlRead($inputto2)
            $step2 = guictrlread($inputby2)
            If $from2 > $to2 Then
                $step2 = -$step2
            EndIf   
            $count2 = ($from2 - $to2)/$step2
            $j = $from2
        EndIf
        If GUICtrlRead($check) = $GUI_CHECKED And GUICtrlRead($check2) = $GUI_CHECKED Then          
            If $count <= $count2 Then
                $count = $count2
            EndIf
        EndIf
        
        If $count < 0 Then
            $count = -$count
        EndIf

            while $count >= 0
                draw($meter)                                                                        
                If GUICtrlRead($check) = $GUI_CHECKED Then
                    GUICtrlSetData($object,$i)
                    $i = $i + $step
                EndIf
            
                If GUICtrlRead($check2) = $GUI_CHECKED Then
                    GUICtrlSetData($object2,$j)
                    $j = $j + $step2
                EndIf
                
                $count = $count - 1
                    
            WEnd
            
        Else;increment part ends
            draw($meter)
        EndIf
        
    ElseIf $msg = $exit Then
        $realesedc= DllCall ($DCdll, "int", "ReleaseDC", "hwnd", 0,  "int", $dc[0])
        Exit
    EndIf
WEnd

Func draw($meter)
;DRAWER SETTING AREAS
    $color = $meter
    $x = 0
    $y = 0
    $loopcounter = 0
    $xaxi = GUICtrlRead($edit2)
    $yaxi = guictrlread($edit3)
    $revolution = GUICtrlRead($edit1)
    $xdiameter = GUICtrlRead($edit4)
    $ydiameter = GUICtrlRead($edit5)
    $xshape = GUICtrlRead($edit6)
    $yshape = guictrlread($edit7)

;read x list
    $xtemp = GUICtrlRead($xlist)
    If $xtemp = "Sin" Then
        $xtemp = 1
    ElseIf $xtemp = "Cos" Then
        $xtemp = 2
    ElseIf $xtemp = "Tan" Then
        $xtemp = 3
    ElseIf $xtemp = "Cot" Then
        $xtemp = 4
    ElseIf $xtemp = "Sec" Then
        $xtemp = 5
    ElseIf $xtemp = "Csc" Then
        $xtemp = 6
    ElseIf $xtemp = 0 Then
        MsgBox(0,"Error", "Must select a fuction for x")
        Return
    EndIf
;read y list
    $ytemp = GUICtrlRead($ylist)
    If $ytemp = "Sin" Then
        $ytemp = 1
    ElseIf $ytemp = "Cos" Then
        $ytemp = 2
    ElseIf $ytemp = "Tan" Then
        $ytemp = 3
    ElseIf $ytemp = "Cot" Then
        $ytemp = 4
    ElseIf $ytemp = "Sec" Then
        $ytemp = 5
    ElseIf $ytemp = "Csc" Then
        $ytemp = 6
    ElseIf $ytemp = 0 Then
        MsgBox(0,"Error", "Must select a fuction for y")
        Return
    EndIf
    While 1
        $xvalue = selectfunc($xtemp, $x)
        $yvalue = selectfunc($ytemp, $y)
        $setpixel= DllCall ($GDIdll, "long", "SetPixel", "long", $dc[0], "long", $xdiameter*$xvalue+$xaxi, "long", $ydiameter*$yvalue+$yaxi, "long", $color)
;~              MouseMove($xdiameter*$xvalue+$xaxi,$ydiameter*$yvalue+$yaxi,2)
        $x = $x + $xshape
        $y = $y + $yshape
;~      ToolTip($x&","&$y,1000,900)
;~      ToolTip($loopcounter,1000,900)
        If $loopcounter > $revolution Then
            ExitLoop
        EndIf
        $loopcounter = $loopcounter + 1
    WEnd
    
EndFunc

Func selectfunc($choice,$value)
    If $choice = 1 Then
        Return Sin($value)
    ElseIf $choice = 2 Then
        Return Cos($value)
    ElseIf $choice = 3 Then
        Return Tan($value)
    ElseIf $choice = 4 Then
        Return 1/Tan($value)
    ElseIf $choice = 5 Then
        Return 1/Cos($value)
    ElseIf $choice = 6 Then
        Return 1/Sin($value)
    EndIf
EndFunc
Edited by dexxa

Share this post


Link to post
Share on other sites



Hi,

nice but i dont like it if it's drawed on the desktop. Could you change your script that it is drawed in a MsgBox or something like that?

Maybe with a Checkbox where you can choose if you want it in Msgbox or on desktop.

Regards


--------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote]

Share this post


Link to post
Share on other sites

well i will try to do that. but what i really want to do is make it work like a TI83. you put y = sin(x) and it draws the graph. but i have to convert the express into a real equation. i am wonder if autoit has stack or some string manipulation that can manipulate char by char.

Share this post


Link to post
Share on other sites

this doesnt do anything for me, it just shows up in the taskbar and thats it??


[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

i just tested it with my pc at work and it worked fine. no beta required. preferably win xp.

and may i add that the most fun you can have with this script is to change around the change values make it draw a few circles

P.S. for the two changes. dont change the same thing like two x position. youre asking for trouble if you do. ill fix it later

Edited by dexxa

Share this post


Link to post
Share on other sites

i just tested it with my pc at work and it worked fine. no beta required. preferably win xp.

and may i add that the most fun you can have with this script is to change around the change values make it draw a few circles

P.S. for the two changes. dont change the same thing like two x position. youre asking for trouble if you do. ill fix it later

OK, it did work. What happend is that the gui appeared off the screen.

Thanks this is cool


[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

thats cool, now throw in the ability for me to type in some trinomials and ill give u $5, really, not really, but really.

P.S. nice sig zerocool, i have never heard of Windows Visa


50% of the time, it works all the time

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