szatira Posted March 24, 2006 Share Posted March 24, 2006 Hi, I'm new to autoit and I'm trying to get the mouse to do a "butterfly curve" (and to draw it on a canvas I'd just click the mouse manually).http://mathworld.wolfram.com/ButterflyCurve.htmlI came up with the following code but it doesn't work. Would anyone be able to help me?Thanks. #include <math.au3>HotKeySet("{ESC}", "esc")Global Const $PI = 3.1415926535897932384626433832795dim $tdim $exprfor $theta = 0 to 24* $PI$t = _Radian($theta)$expr = Exp(Cos($t)) -2 * Cos(4 * $t) - Sin($t / 12) ^5$x = 400 + Cos($t) * $expr$y = 400 + Sin($t) * $exprMouseMove($x, $y, 0)NextFunc esc()Exit 0EndFunc Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 24, 2006 Moderators Share Posted March 24, 2006 If I remember correctly szatira, greenmachine did something like this a while back (don't count on my memory ) and posted it in the scripts and scraps forum. Try looking for his name and narrowing down the search in advanced (more options) mode in the search function pointed at the scripts and scraps forum (maybe titles only?). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
CyberSlug Posted March 24, 2006 Share Posted March 24, 2006 (edited) The problem is your values are too similar: (400.718281828459, 400) (400.722629675212, 400.0126135479) (400.735641885078, 400.025689180697) (400.757224693478, 400.039684464603) (400.78722257975, 400.055047965292) (400.825419391715, 400.07221483943) (400.871539908322, 400.091602535568) (400.925251828746, 400.113606639517) (400.98616817313, 400.138596898209) I added a scaling factor (multiplied by 100) so that the x coord varies between 200 and 700 and similarly for the y coord. #include <math.au3> HotKeySet("{ESC}", "esc") Global Const $PI = 3.1415926535897932384626433832795 dim $t dim $expr for $theta = 0 to 924* $PI;ALSO MAKE THE LOOP GO LONGER $t = _Radian($theta) $expr = Exp(Cos($t)) -2 * Cos(4 * $t) - Sin($t / 12) ^5 $x = 400 + 100* Cos($t) * $expr $y = 400 + 100* Sin($t) * $expr ConsoleWrite($x & "," & $y & @LF);Use for debugging with SciTE MouseMove($x, $y, 1) Next Func esc() Exit 0 EndFunc Edited March 24, 2006 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
greenmachine Posted March 25, 2006 Share Posted March 25, 2006 It looks like you guys used the polar formula to do your calculations... I decided to use the parametric equations, and came up with this: Global Const $e = 2.71828182845904523536 Opt ("WinTitleMatchMode", 2) If Not WinExists ("Paint") Then Run ("mspaint.exe") EndIf WinActivate ("Paint") WinWaitActive ("Paint") WinSetState ("Paint", "", @SW_MAXIMIZE) Sleep (500) $t = 0 $x = @DesktopWidth/2 - 100*(Sin ($t) * ($e ^ (Cos ($t)) - 2*Cos(4 * $t) + Sin($t/12))) $y = (@DesktopHeight/2 + 75) - 100*(Cos ($t) * ($e ^ (Cos ($t)) - 2*Cos(4 * $t) + Sin($t/12))) MouseMove ($x, $y, 1) MouseDown ("primary") For $t = 0 To 75.4 Step .01 $x = @DesktopWidth/2 - 100*(Sin ($t) * ($e ^ (Cos ($t)) - 2*Cos(4 * $t) + Sin($t/12))) $y = (@DesktopHeight/2 + 75) - 100*(Cos ($t) * ($e ^ (Cos ($t)) - 2*Cos(4 * $t) + Sin($t/12))) MouseMove ($x, $y, 1) Next MouseUp ("primary") When you run it, it draws in Paint (for the full drawing, screen resolution needs to be 1024x768 or higher, and paint needs to have all toolbars hidden). The end result for me was: Link to comment Share on other sites More sharing options...
szatira Posted March 25, 2006 Author Share Posted March 25, 2006 Thank you guys very much. This has been very helpful, I can't believe I completely disregarded the scaling of the drawing, haha. Link to comment Share on other sites More sharing options...
greenmachine Posted March 25, 2006 Share Posted March 25, 2006 Here's another one I came up with based off the rose formation ( http://mathworld.wolfram.com/Rose.html )Global Const $PI = 3.1415926535897932384626433832795 Global Const $e = 2.71828182845904523536 Opt ("WinTitleMatchMode", 2) If Not WinExists ("Paint") Then Run ("mspaint.exe") EndIf WinActivate ("Paint") WinWaitActive ("Paint") WinSetState ("Paint", "", @SW_MAXIMIZE) $a = 300 $n = $e $t = 0 $r = $a * Sin ($n * $t) $x = @DesktopWidth/2 - ($r * Cos ($t)) $y = (@DesktopHeight/2) - ($r * Sin ($t)) MouseMove ($x, $y, 1) MouseDown ("primary") For $t = 0 To 71*$PI Step $PI/64 $r = $a * Sin ($n * $t) $x = @DesktopWidth/2 - ($r * Cos ($t)) $y = (@DesktopHeight/2) - ($r * Sin ($t)) MouseMove ($x, $y, 1) Next MouseUp ("primary") Link to comment Share on other sites More sharing options...
Lakes Posted March 25, 2006 Share Posted March 25, 2006 (edited) I was messing with this stuff years ago (a Long! time ago) on an Atari 800, (or was it on the Amiga?, I forget now..) I even had my programs printed in the Page6 Magazine and received a cheque for, er.. £6 think! Edited March 25, 2006 by Lakes 2015 - Still no flying cars, instead blankets with sleeves. Link to comment Share on other sites More sharing options...
RazerM Posted March 25, 2006 Share Posted March 25, 2006 these are really cool guys My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
theguy0000 Posted March 25, 2006 Share Posted March 25, 2006 wow how do you guys figure out the formulas and whatnot to use for this... The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
greenmachine Posted March 25, 2006 Share Posted March 25, 2006 wow how do you guys figure out the formulas and whatnot to use for this...Did you see the links? Did you go to the pages? They have the equations there. Link to comment Share on other sites More sharing options...
slightly_abnormal Posted March 25, 2006 Share Posted March 25, 2006 Did you see the links? Did you go to the pages? They have the equations there.holy crap.. those are freaking awesome! go right ahead and make some more, greenmachine! Link to comment Share on other sites More sharing options...
greenmachine Posted March 25, 2006 Share Posted March 25, 2006 holy crap.. those are freaking awesome! go right ahead and make some more, greenmachine! Sure, if anyone wants me to make another one, just find a good looking one and give me the link (or the equation). I'll convert it and turn it into a script and post it here. Link to comment Share on other sites More sharing options...
Lakes Posted March 26, 2006 Share Posted March 26, 2006 Sure, if anyone wants me to make another one, just find a good looking one and give me the link (or the equation). I'll convert it and turn it into a script and post it here. And you can draw on a GUI.. expandcollapse popup#include <GUIConstants.au3> ; == GUI generated with Koda ==); $Graphics = GUICreate("Graphics Test", 600, 600, 192, 125) GuiCtrlCreateGraphic(-1, -1, 600,600) $X = 300 $Y = 300 $Size = 300 $Wid = $Size $Hgt = $Size $Col = 0xffffff $Col1 = 0x000000 GUICtrlSetGraphic(-1,$GUI_GR_PENSIZE, 1) GUICtrlSetGraphic(-1,$GUI_GR_MOVE, $Size,$Size) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, $Col,0) _DrawGraphic(0.05) GUICtrlSetGraphic(-1,$GUI_GR_MOVE, $Size,$Size) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, $Col1,0) _DrawGraphic(1) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Func _DrawGraphic($Step) For $R1 = 1 to 360 step $Step $Px = (Sin($R1)*$Size) + $X $Py = (Cos($R1)*$Size) + $Y GUICtrlSetGraphic(-1,$GUI_GR_MOVE, $X,$Y) GUICtrlSetGraphic(-1,$GUI_GR_LINE, $Px,$Py) Next EndFunc Enjoy! 2015 - Still no flying cars, instead blankets with sleeves. Link to comment Share on other sites More sharing options...
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