Jump to content

GUICtrlCreateLine?


Recommended Posts

i've been trying to create a function to draw a line between two points, but with no success. here is what i have so far:

#include <GUIConstants.au3>

Func GUICtrlCreateLine($x1, $y1, $x2, $y2)
  For $a = $y1 to $y2 step 5
    For $b = $x1 to $x2 step 5
      GUICtrlCreateLabel("", $a, $b, 5, 5, 0x1000)
    Next
  Next
EndFunc

GUICreate("")
GUICtrlCreateLine(0, 0, 50, 70)
GUISetState()

sleep(5000)

if you try it out it only creates a grid...

someone please help! :)

Link to comment
Share on other sites

Global $edge
Func _GUICtrlCreateEdge($x, $y, $width, $height, $color)
    $edge= GUICtrlCreateLabel("", $x, $y, $width, $height, 0x1000)
    GUICtrlSetBkColor($edge, $color)
EndFunc

GUICreate("Edge demo")
_GUICtrlCreateEdge(10, 10, 10, 100, 0x00FF00)
GUISetState()
While 1
$get = GUIGetMsg()
If $get = -3 then exit
WEnd

should work..

EDIT: gaforst you beat me to it! :) hehe :D

Edited by layer
FootbaG
Link to comment
Share on other sites

that was the post that i was looking at when i got the idea for this. i just realized then that there was no function to make a line between two pionts such as on a TI-83+ graphing calculator:

point 0, 1

point 4, 5

the graph would be:

00000

\0000

0\000

00\00

000\0

Do you people see what i'm saying now?

Link to comment
Share on other sites

hello,

I think that in your case, it's an equation : y=a*x+b

#include <GUIConstants.au3>

Func GUICtrlCreateLine($x1, $y1, $x2, $y2)
  $coeff_line=($y2-$y1)/($x2-$x1)
  $p=$y2-$coeff_line*$x2
  For $a = $x1 to $x2 step 5
      GUICtrlCreateLabel("", $a, $a*$coeff_line+$p, 5, 5,0x1000)
  Next
EndFunc

GUICreate("")
GUICtrlCreateLine(0, 0, 50, 70)
GUISetState()

sleep(5000)

Is it ?

Link to comment
Share on other sites

hello,

I think that in your case, it's an equation : y=a*x+b

#include <GUIConstants.au3>

Func GUICtrlCreateLine($x1, $y1, $x2, $y2)
  $coeff_line=($y2-$y1)/($x2-$x1)
  $p=$y2-$coeff_line*$x2
  For $a = $x1 to $x2 step 5
      GUICtrlCreateLabel("", $a, $a*$coeff_line+$p, 5, 5,0x1000)
  Next
EndFunc

GUICreate("")
GUICtrlCreateLine(0, 0, 50, 70)
GUISetState()

sleep(5000)

Is it ?

<{POST_SNAPBACK}>

That could also be done with _GUICtrlCreateEdge...
FootbaG
Link to comment
Share on other sites

wow, that is perfect thank you!

here is a slightly modified version of that script:

#include <GUIConstants.au3>

Func GUICtrlCreateLine($x1, $y1, $x2, $y2)
  $coeff_line = ( $y2-$y1 ) / ( $x2-$x1 )
  $p = $y2 - ( $coeff_line * $x2 )
  For $a = $x1 to $x2 step 1
    GUICtrlCreateLabel("", $a, ( $a * $coeff_line ) + $p, 1, 1,0x1000)
  Next
EndFunc

GUICreate("")
GUICtrlCreateLine(0, 0, 100, 300)
GUICtrlCreateLine(50, 300, 300, 20)
GUISetState()

sleep(5000)

thank you again, this could be a very big breakthrough in autoit! :)

EDIT: i'll post it in scripts and scraps

Edited by erifash
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...