- Offizieller Beitrag
Hallo
Also.. ich wollte mit huggy ein programm schreiben (ich schreibe, er unterhält mich^^) was Lineare funktionen usw grafisch darstellen kann.. Nur stehe ich momentan aufm schlauch (fehlt mir wohl das mathematische denken^^)
So, wie mach ich das aber jetzt?^^ also die rechnung war kein problem ( f(x)=x+5 usw..) einfach mit Execute und stringreplace, aber wie stell ich dies grafisch dar? also die differenzen in einer kurve? hatte ne for schleife drin, die funktionierte aber irgendwie nicht -.- die funktion _IntToPixel stimmt überhaupt noch nicht (wegen plus und minus feldern usw) aber wie krieg ich zummindest ne kurve hin?
Spoiler anzeigen
#include <GUIConstants.au3>
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]GUICreate("", 500, 500)
$gra = GUICtrlCreateGraphic(10, 10, 480, 480)
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlSetGraphic($gra, $GUI_GR_PENSIZE, 2)
GUICtrlSetGraphic($gra, $GUI_GR_COLOR, 0)
GUICtrlSetGraphic($gra, $GUI_GR_MOVE, 480 / 2, 470)
GUICtrlSetGraphic($gra, $GUI_GR_LINE, 480 / 2, 10)
GUICtrlSetGraphic($gra, $GUI_GR_MOVE, 470, 480 / 2)
GUICtrlSetGraphic($gra, $GUI_GR_LINE, 10, 480 / 2)
GUICtrlSetGraphic($gra, $GUI_GR_PENSIZE, 1)
GUICtrlSetGraphic($gra, $GUI_GR_COLOR, 0)
_CreateGraphicSteps(10, 10, 10, 460, 460)
GUISetState()
_func("x+1", 5, 6)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _func($Fx, $x1, $x2)
Local $func1, $func2
$func1 = Execute(StringReplace($Fx, "x", $x1))
$func2 = Execute(StringReplace($Fx, "x", $x2))
GUICtrlSetGraphic($gra,$GUI_GR_REFRESH)
MsgBox(0, "", "F(x1)=" & $func1 & @LF & "F(x2)=" & $func2)
EndFunc ;==>_func
Func _CreateGraphicSteps($iPixels, $iX, $iY, $iWidth, $iHeigth)
For $x = $iX To $iWidth + $iPixels Step $iPixels
;~ ConsoleWrite($x & @CRLF)
GUICtrlSetGraphic($gra, $GUI_GR_MOVE, $x, ($iWidth / 2) + 5)
GUICtrlSetGraphic($gra, $GUI_GR_LINE, $x, ($iWidth / 2) + 15)
Next
For $y = $iY To $iHeigth+$iPixels Step $iPixels
GUICtrlSetGraphic($gra, $GUI_GR_MOVE, ($iHeigth / 2) + 5,$y)
GUICtrlSetGraphic($gra, $GUI_GR_LINE, ($iHeigth / 2) + 15,$y )
Next
EndFunc ;==>_CreateGraphicSteps
Func _IntToPix($iInt,$iInt2,$iPixels)
;Das stimmt 100%ig noch nich aber ich wills zuminddest so zum laufen bringen das es eine kurve darstellt
GUICtrlSetGraphic($gra,$GUI_GR_DOT,$iInt * $iPixels,$iInt * $iPixels)
EndFunc
Wäre super wenn mir jemmand helfen könnte
Mfg Spider