_Kurt Posted November 6, 2007 Posted November 6, 2007 (edited) I'm currently very frustrated, I've looked over the helpfiles examples several times and played around with it, but I can't seem to be able to create a quarter-circle:Am I missing the obvious here?Thanks,Kurt Edited November 6, 2007 by _Kurt Awaiting Diablo III..
Nahuel Posted November 6, 2007 Posted November 6, 2007 I know it can be done with the Bezier type.. I'm just not patient enough to play with the parameters: expandcollapse popup#include <GUIConstants.au3> $MAXGr=7 Global $a[$MAXGr+1] ; 0 and $MAXGr entries not used to allow GUICtrlDelete result Global $child, $del GUICreate("My Main", -1,-1,100,100) $del1=GuiCtrlCreateButton("Delete", 50,200, 50) GUISetState() CreateChild() $i=1 $inc=1 ;$i=5 ; uncomment to delete starting from last define Graphic control ;$inc=-1 Do $msg = GUIGetMsg() if $msg= $del1 then Del() if $msg= $del then GuiCtrlDelete($a[$i]) $i = $i+$inc if $i <0 OR $i>$MAXGr then exit EndIf Until $msg=$GUI_EVENT_CLOSE Func Del() GuiDelete($child) CreateChild() EndFunc Func CreateChild() $child=GUICreate("My Draw") $del=GuiCtrlCreateButton("Delete", 50,165, 50) ;~ $a[1]=GuiCtrlCreateGraphic(20, 50, 100,100) ;~ GUICtrlSetBkColor(-1,0xffffff) ;~ GUICtrlSetColor(-1,0) ;~ GUICtrlSetGraphic(-1,$GUI_GR_BEZIER, 120,100, 200,20, 200,100) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0xff0000,0xff0000) ;~ GUICtrlSetGraphic(-1,$GUI_GR_PIE, 50,50, 40,30,270) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x00ff00,0xffffff) ;~ GUICtrlSetGraphic(-1,$GUI_GR_PIE, 58,50, 40,-60,90) ;~ GUICtrlSetGraphic(-1,$GUI_GR_ELLIPSE, 100,100, 50,80) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x00ff00,0xc0c0ff) ;~ GUICtrlSetGraphic(-1,$GUI_GR_RECT, 350,200, 50,80) ;~ GuiCtrlCreateLabel("label", 65, 100, 30) ;~ GUICtrlSetColor(-1,0xff) ;~ $a[2]=GuiCtrlCreateGraphic(220, 10, 100,100) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0, 0xff) ;~ GUICtrlSetGraphic(-1,$GUI_GR_PIE, 50,50, 40,30,270) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x00ff00,0xffffff) ;~ GUICtrlSetGraphic(-1,$GUI_GR_PIE, 58,50, 40,-60,90) ;~ $a[3]=GuiCtrlCreateGraphic(220, 110, 100,100) ;~ GUICtrlSetBkColor(-1,0xf08080) ;~ GUICtrlSetColor(-1,0xff) ;~ GUICtrlSetGraphic(-1,$GUI_GR_HINT, 1) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0xff00) ;~ GUICtrlSetGraphic(-1,$GUI_GR_RECT, 50,50, 80,80) ;~ $a[4]=GuiCtrlCreateGraphic(20, 200, 80,80) ;~ GUICtrlSetBkColor(-1,0xffffff) ;~ GUICtrlSetGraphic(-1,$GUI_GR_HINT, 1) ;~ GUICtrlSetGraphic(-1,$GUI_GR_MOVE, 10,10) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0xff) ;~ GUICtrlSetGraphic(-1,$GUI_GR_LINE, 30,40) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0xff00) ;~ GUICtrlSetGraphic(-1,$GUI_GR_LINE, 70,70) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0xff0000) ;~ GUICtrlSetGraphic(-1,$GUI_GR_LINE, 10,50) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0xffff00) ;~ GUICtrlSetGraphic(-1,$GUI_GR_LINE, 10,10) ;~ $a[5]=GuiCtrlCreateGraphic(150, 10, 50,50) ;~ GUICtrlSetBkColor(-1,0xa0ffa0) ;~ GUICtrlSetGraphic(-1,$GUI_GR_MOVE, 20,20) ; start point ;~ ; it is better to draw line and after point ;~ ; to avoid to switch color at each drawing ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x0000ff) ;~ GUICtrlSetGraphic(-1,$GUI_GR_DOT, 30,30) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0) ;~ GUICtrlSetGraphic(-1,$GUI_GR_LINE, 20,40) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0xff0000) ;~ GUICtrlSetGraphic(-1,$GUI_GR_DOT, 25,25) ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0) ;~ GUICtrlSetGraphic(-1,$GUI_GR_LINE, 40,40) ;~ GUICtrlSetGraphic(-1,$GUI_GR_DOT, 30,40) $a[6]=GuiCtrlCreateGraphic(110, 260, 230,130) ;~ GUICtrlSetColor(-1,0) ; to display a balck border line ;~ GUICtrlSetBkColor(-1,0xc0c0ff) ;~ GUICtrlSetGraphic(-1,$GUI_GR_HINT, 3) ; to display control lines and end points ;~ GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0, 0xff); fill in blue GUICtrlSetGraphic(-1,$GUI_GR_MOVE, 120,20) ; start point GUICtrlSetGraphic(-1,$GUI_GR_BEZIER, 120,100, 200, 20, 200,100);x,y,x1,y1,x2,y2 ;~ GUICtrlSetGraphic(-1,$GUI_GR_BEZIER+$GUI_GR_CLOSE, 100,40, 40,100, 40,20) ;~ GUICtrlSetGraphic(-1,$GUI_GR_LINE, 60,30) ; start point GuiSetState() EndFunc
_Kurt Posted November 6, 2007 Author Posted November 6, 2007 (edited) Yes, I know all that, I don't understand the Bezier type parameters.I tried fiddling around with the parameters but still, can't figure it out. KurtEDIT: Also, I know I could use $GUI_GR_PIE and cover up the rest with some labels, but I know there's some way to do this the right way. Edited November 6, 2007 by _Kurt Awaiting Diablo III..
Nahuel Posted November 6, 2007 Posted November 6, 2007 Well... this is my last try. It does what you want, but I insist that this can be done doing a Bezier courve. Anyway.. #include <GUIConstants.au3> #include <Math.au3> GUICreate("Form1", 329, 243, 237, 155) $g= GUICtrlCreateGraphic(38, 22, 261, 185) $radius=50 $h=50;Center x $k=50;Center y $start=0;Start angle $end=90;End angle For $i = $start to $end $X = $h - sin(_Radian($i))*$radius $Y = $k - cos(_Radian($i))*$radius GUICtrlSetGraphic($g,$GUI_GR_PIXEL,$x,$y) Next GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Note: The bigger the radius is, the uglier the graph looks. To fix that, you'll need to add a 'step' and a number <1 (Like, 0.5) But the smaller this number is, the slower it will be...
_Kurt Posted November 6, 2007 Author Posted November 6, 2007 Thank you very much Nahuel. I was having a hard time figuring out the bezier. but this is alot more simple. Kurt Awaiting Diablo III..
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now