Hi Community
Das hier präsentierte Skript ist lediglich eine Spielerei von mir und NOCH NICHT FERTIG !
Weitere Features (und zum Schluss natürlich Zeilen Optimierung) kommen noch dazu.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
UPDATE 31.10.18 (Version 1.2):
- Die Gui ist nun im OnEvent Modus
- Die Variablendeklaration wurde überarbeitet, evtl. noch verbesserungswürdig (Vorschläge erwünscht)
- Das "sizinig" ist etwas grösser, aber noch nicht fertig optimiert
- Der Parameter "bias" sorgt für eine definierte "Verschiebung" der Kurve, was coole "Surfaces" erzeugen kann
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
UPDATE 05.11.18 (Version 1.3):
- Button "RAND" hinzugefügt:
Initialisiert neue "random" Settings"
- Checkbox "SBS" (StepByStep) hinzugefügt:
Wenn nicht angewählt, berechnet es 50 Schritte ($calc_forward) im Voraus und bildet diese danach ab.
Jedoch fehlt immer der Zwischenschritt, welcher nicht gezeichnet wird (wirkt Skizzenhaft, wird jedoch noch behoben)
- Slider "Fading" hinzugefügt (momentan mithilfe von "graphicsclear" um eine Vorstellung zu bekommen, wird evtl. noch optimiert)
- Slider "Speed" hinzugefügt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AUSBLICK:
- Farbenhandling
- Beschriftungen im Skript (Nachvollziehbar) nachtragen
- Speichern von Bildern, Settings
- Laden von Settings
- Zeilenoptimierung
- Variablennamen Optimierung
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Falls das Skript bei jemandem Probleme macht, getestet habe ich es bisher nur auf meinem Laptop:
- HP-Omen
- Intel(R) Core(TM) i5-7300HQ
CPU @ 2.50GHz (4 Kerne)
- 8.00 GB RAM
- 64-Bit,
- 1920x1080
V 1.3:
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; ~~~~~~~~~~~~~ GDI+ CarmiBrush ~~~~~~~~~~~~~~~~~~~~~~~
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Language: English
; Author: "o2candoo"
; Version: 1.3
; ----------------------------------------------------------------------------
#Region Includes
#include <GUIConstantsEx.au3>
#include <ColorConstantS.au3>
#include <WindowsConstants.au3>
#include <Color.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
#EndRegion
#Region Declarations
;~ Gui attributes
Global $wWidth = 800
Global $wHeight = 600
Global $wCenter_x = $wWidth / 2
Global $wCenter_y = $wHeight / 2
Global $center_x = @DesktopWidth/2
Global $center_y = @DesktopHeight/2
;~ Environment attributes
Global $processi = 3.141592653589793
;~ Colors
Global $col
Global $colClear = 0xFFFFFFFF
Global $fading_max = 1
Global $fading = 0
;~ leg attributes
Global $fix_x = $wCenter_x
Global $fix_y = $wCenter_y
Global $rotation[3]
$rotation[1] = 1
$rotation[2] = -1
;~ Leg variables
_LegVar(5)
;~ Initialize leg variables
Global $data_count, $values[10000], $xHist, $yHist
_Initializer()
;~ Process variables
Global $process = 2
Global $calc_forward = 50
Global $xses[$calc_forward+1], $yses[$calc_forward+1]
$start = -1
#EndRegion
#Region Gui
;~ Main
$hGui = GUICreate("Main", $wWidth, $wHeight, $center_x-($wWidth/2), $center_y-($wHeight/2),-2147483648)
GUISetBkColor($COLOR_WHITE)
;~ Infolabels
Global $lengthlabel[$quantity+1]
$lengthlabel_pos = 5
For $i = 1 To $quantity
$text = String($i) & ":" & @CRLF & _
"l = " & @TAB & $length[$i] & @CRLF & _
"step = " & @TAB & $step[$i] & @CRLF
$lengthlabel[$i] = GUICtrlCreateLabel($text, 10, $lengthlabel_pos, 70, 50)
GUICtrlSetFont($lengthlabel[$i], 7)
$lengthlabel_pos += 40
Next
;~ Buttons
$b_start = GUICtrlCreateButton("START", $wWidth-70, 10, 60, 50)
GUICtrlSetFont($b_start, 12)
GUICtrlSetOnEvent(-1, "StartPressed")
$b_clear = GUICtrlCreateButton("CLEAR", $wWidth-70, 65, 60, 50)
GUICtrlSetFont($b_clear, 12)
GUICtrlSetOnEvent(-1, "ClearPressed")
$b_rand = GUICtrlCreateButton("RAND", $wWidth-70, 120, 60, 50)
GUICtrlSetFont($b_rand, 12)
GUICtrlSetOnEvent(-1, "RandPressed")
;~ Slider Fading
GUICtrlCreateLabel("Fading", 10, $wHeight-150, 70, 30)
GUICtrlSetFont(-1, 16)
$s_Fade = GUICtrlCreateSlider(10, $wHeight-120, 70, 30)
GUICtrlSetLimit(-1, 20)
GUICtrlSetData(-1, 0)
;~ Slider Speed
GUICtrlCreateLabel("Speed", 10, $wHeight-80, 70, 30)
GUICtrlSetFont(-1, 16)
$s_Speed = GUICtrlCreateSlider(10, $wHeight-50, 70, 30)
GUICtrlSetLimit(-1, 250)
GUICtrlSetData(-1, 250)
;~ Checkboxes
$cb_sbs = GUICtrlCreateCheckbox("SBS", $wWidth-80, $wHeight-120, 50, 30)
$cb_legs = GUICtrlCreateCheckbox("legs", $wWidth-80, $wHeight-80, 50, 30)
$cb_hist = GUICtrlCreateCheckbox("Hist", $wWidth-80, $wHeight-40, 50, 30)
GUICtrlSetState(-1, $GUI_CHECKED)
;~ Gui State
GUISetState(@SW_SHOW)
#EndRegion
#Region ### START GDI+ ###
;~ Startup
_GDIPlus_Startup()
;~ Graphics
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
;~ Bitmaps
$hGraphicBitmap = _GDIPlus_BitmapCreateFromGraphics($wWidth, $wHeight, $hGraphic)
$hHistoryBitmap = _GDIPlus_BitmapCreateFromScan0($wWidth, $wHeight)
$hLegBitmap = _GDIPlus_BitmapCreateFromScan0($wWidth, $wHeight)
;~ Buffers
$hBuffer = _GDIPlus_ImageGetGraphicsContext($hGraphicBitmap)
$hHistoryBuffer = _GDIPlus_ImageGetGraphicsContext($hHistoryBitmap)
$hLegBuffer = _GDIPlus_ImageGetGraphicsContext($hLegBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 4)
_GDIPlus_GraphicsSetSmoothingMode($hHistoryBuffer, 4)
_GDIPlus_GraphicsSetSmoothingMode($hLegBuffer, 4)
_GDIPlus_GraphicsClear($hBuffer, 0xFFFFFFFF)
_GDIPlus_GraphicsClear($hHistoryBuffer, 0xFFFFFFFF)
_GDIPlus_GraphicsClear($hLegBuffer, 0xFFFFFFFF)
;~ Pens
Global $hPen[$quantity+1]
For $i = 1 To $quantity
$hPen[$i] = _GDIPlus_PenCreate(0xFFFF0000, 5)
Next
$hPenHist = _GDIPlus_PenCreate(0xFF000000, 2)
#EndRegion ### END GDI+ ###
#Region EventMode
Opt("GUICoordMode", 2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
#EndRegion
#Region Loop
While 1
If $start = 1 Then
_Calc()
_Draw()
EndIf
Sleep(250-GUICtrlRead($s_Speed))
WEnd
#EndRegion
#Region Functions
Func _LegVar($q = 5)
Global $quantity = $q
Global $length[$quantity+1]
Global $x[$quantity+1], $y[$quantity+1], $alpha[$quantity+1], $step[$quantity+1]
EndFunc
Func _Initializer($s = 4, $m = 20, $b = 0.1)
;~ Variables
Local $series = $s
Local $max = $m
Local $bias = $b
;~ Possible values == Series
$data_count = Round($max/$series, 0)
For $i = 1 To $data_count
$values[$i] = $i * $series
Next
;~ Initialize leg Variables (Normal)
For $i = 1 To $quantity
$alpha[$i] = 270
$length[$i] = Round(Random(20,100), 0)
If $i = 1 Then
$x[$i] = $fix_x + ($length[1] * cos(($processi*$alpha[1])/180))
$y[$i] = $fix_y + ($length[1] * sin(($processi*$alpha[1])/180))
$step[$i] = ($values[Round(Random(1, $data_count), 0)]) * $rotation[Round(Random(1, 2), 0)]
Else
$x[$i] = $x[$i-1] + ($length[$i] * cos(($processi*$alpha[$i])/180))
$y[$i] = $y[$i-1] + ($length[$i] * sin(($processi*$alpha[$i])/180))
$step[$i] = ($values[Round(Random(1, $data_count), 0)] + $bias) * $rotation[Round(Random(1, 2), 0)]
EndIf
Next
;~ Initialize leg Variables (Hist)
$xHist = $x[$quantity]
$yHist = $y[$quantity]
EndFunc
Func _Calc()
If _IsChecked($cb_sbs) Then
;~ Hist
$xHist = $x[$quantity]
$yHist = $y[$quantity]
;~ Normal
For $i = 1 To $quantity
$alpha[$i] += $step[$i]
If $i = 1 Then
$x[$i] = $fix_x + ($length[$i] * cos(($processi*$alpha[$i])/180))
$y[$i] = $fix_y + ($length[$i] * sin(($processi*$alpha[$i])/180))
Else
$x[$i] = $x[$i-1] + ($length[$i] * cos(($processi*$alpha[$i])/180))
$y[$i] = $y[$i-1] + ($length[$i] * sin(($processi*$alpha[$i])/180))
EndIf
Next
Else
For $j = 1 To $calc_forward
;~ Hist
$xses[$j] = $x[$quantity]
$yses[$j] = $y[$quantity]
;~ Normal
For $i = 1 To $quantity
$alpha[$i] += $step[$i]
If $i = 1 Then
$x[$i] = $fix_x + ($length[$i] * cos(($processi*$alpha[$i])/180))
$y[$i] = $fix_y + ($length[$i] * sin(($processi*$alpha[$i])/180))
Else
$x[$i] = $x[$i-1] + ($length[$i] * cos(($processi*$alpha[$i])/180))
$y[$i] = $y[$i-1] + ($length[$i] * sin(($processi*$alpha[$i])/180))
EndIf
Next
Next
EndIf
EndFunc
Func _Draw()
If _IsChecked($cb_sbs) Then
_GDIPlus_GraphicsDrawImageRect($hLegBuffer, $hHistoryBitmap, 0, 0, $wWidth, $wHeight)
;~ legs
If _IsChecked($cb_legs) Then
For $i = 1 To $quantity
If $i = 1 Then
_GDIPlus_GraphicsDrawLine($hLegBuffer, $fix_x, $fix_y, $x[$i], $y[$i], $hPen[$i])
Else
_GDIPlus_GraphicsDrawLine($hLegBuffer, $x[$i-1], $y[$i-1], $x[$i], $y[$i], $hPen[$i])
EndIf
Next
EndIf
;~ Hist
If _IsChecked($cb_hist) Then
_GDIPlus_GraphicsDrawLine($hHistoryBuffer, $xHist, $yHist, $x[$quantity], $y[$quantity], $hPenHist)
EndIf
_GDIPlus_GraphicsDrawImageRect($hBuffer, $hHistoryBitmap,0, 0, $wWidth, $wHeight)
_GDIPlus_GraphicsDrawImageRect($hBuffer, $hLegBitmap,0, 0, $wWidth, $wHeight)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hGraphicBitmap, 80, 0, $wWidth-160, $wHeight)
Else
If $fading = $fading_max Then
$colFade = "0x" & StringTrimLeft(Hex(GUICtrlRead($s_Fade)), 6) & "FFFFFF"
ClearPressed($colFade)
$fading = 0
Else
$fading += 1
EndIf
_GDIPlus_GraphicsDrawImageRect($hLegBuffer, $hHistoryBitmap, 0, 0, $wWidth, $wHeight)
For $i = 1 To ($calc_forward-1)
_GDIPlus_GraphicsDrawLine($hHistoryBuffer, $xses[$i], $yses[$i], $xses[$i+1], $yses[$i+1], $hPenHist)
Next
_GDIPlus_GraphicsDrawImageRect($hBuffer, $hHistoryBitmap,0, 0, $wWidth, $wHeight)
_GDIPlus_GraphicsDrawImageRect($hBuffer, $hLegBitmap,0, 0, $wWidth, $wHeight)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hGraphicBitmap, 80, 0, $wWidth-160, $wHeight)
EndIf
EndFunc
Func _IsChecked($idControlID)
Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc ;==>_IsChecked
Func _Exit()
For $i = 1 To $quantity
_GDIPlus_PenDispose($hPen[$i])
Next
_GDIPlus_PenDispose($hPenHist)
_GDIPlus_GraphicsDispose($hBuffer)
_GDIPlus_GraphicsDispose($hHistoryBuffer)
_GDIPlus_GraphicsDispose($hLegBuffer)
_GDIPlus_BitmapDispose ($hGraphicBitmap)
_GDIPlus_BitmapDispose ($hHistoryBitmap)
_GDIPlus_BitmapDispose ($hLegBitmap)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
Exit
EndFunc
#EndRegion
#Region Event Functions
Func SpecialEvents()
Select
Case @GUI_CtrlId = $GUI_EVENT_CLOSE
GUIDelete()
_Exit()
EndSelect
EndFunc
Func StartPressed()
$start *= -1
If $start = -1 Then
GUICtrlSetData($b_start, "START")
Else
GUICtrlSetData($b_start, "STOP")
EndIf
EndFunc
Func ClearPressed($col)
If Not $col Then
$col = $colClear
Else
$col = $col
EndIf
_GDIPlus_GraphicsClear($hBuffer, $col)
_GDIPlus_GraphicsClear($hHistoryBuffer, $col)
_GDIPlus_GraphicsClear($hLegBuffer, $col)
_GDIPlus_GraphicsDrawImageRect($hBuffer, $hHistoryBitmap,0, 0, $wWidth, $wHeight)
_GDIPlus_GraphicsDrawImageRect($hBuffer, $hLegBitmap,0, 0, $wWidth, $wHeight)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hGraphicBitmap, 80, 0, $wWidth-160, $wHeight)
EndFunc
Func RandPressed()
_Initializer()
For $i = 1 To $quantity
$text = String($i) & ":" & @CRLF & _
"l = " & @TAB & $length[$i] & @CRLF & _
"step = " & @TAB & $step[$i] & @CRLF
GUICtrlSetData($lengthlabel[$i], $text)
Next
$start = -1
GUICtrlSetData($b_start, "START")
EndFunc
#EndRegion
Alles anzeigen
Vielen Dank im Voraus für Eure Hilfe.