Jump to content



Photo

_GDIPlus_GraphicsDrawCurve not drawing with high number of arrays


  • Please log in to reply
3 replies to this topic

#1 PhoenixXL

PhoenixXL

    Be what you are, believe me its always the BEST...

  • Active Members
  • PipPipPipPipPipPip
  • 1,316 posts

Posted 15 June 2012 - 06:32 AM

Here is the Code
AutoIt         
#include <GUIConstantsEx.au3> #include <GDIPlus.au3> _Main() Func _Main()     Local $hGUI, $hGraphic, $aPoints[8][2]     ; Create GUI     $hGUI = GUICreate("GDI+", 400, 300)     ; Draw a cardinal spline     _GDIPlus_Startup()     $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)     $aPoints=_ArrayPoints(10,10,0,0.0001)     _GDIPlus_GraphicsDrawCurve($hGraphic, $aPoints) GUISetState()     ; Loop until user exits     Do     Until GUIGetMsg() = $GUI_EVENT_CLOSE     ; Clean up resources     _GDIPlus_GraphicsDispose($hGraphic)     _GDIPlus_Shutdown() EndFunc   ;==>_Main ;Local $x=_ArrayPoints(10,10,0) Func _ArrayPoints($sHeight,$iX,$iY,$__Add,$sStep=1) Local $sArray[Number(10^(StringLen(StringMid($__Add,StringInStr($__Add,'.',2)+1))+1))+2][2],$__X=$iX,$__Y=$iY $sArray[0][0]=0 If $iY>$sHeight Then   $sStep=-1 Else   $sStep=1 EndIf While 1   If $iY>=$sHeight+$__Add Then ExitLoop   ConsoleWrite('Y:'&$iY)   ConsoleWrite('   X:'&$iX&@CRLF)   $sArray[0][0]+=1   $sArray[$sArray[0][0]][0]=$iX   If $iY< $sHeight/2 Then    $iX=Round($iX+$__Add,Number(StringLen(StringMid($__Add,StringInStr($__Add,'.',2)+1))))   Else    $iX=Round($iX-$__Add,Number(StringLen(StringMid($__Add,StringInStr($__Add,'.',2)+1))))   EndIf   $sArray[$sArray[0][0]][1]=$iY   $iY=Round($iY+$__Add,Number(StringLen(StringMid($__Add,StringInStr($__Add,'.',2)+1)))) WEnd ConsoleWrite('Total Array:'&$sArray[0][0]&@CRLF) Return $sArray EndFunc


Basically i want to make a Figure like
..____
( ____)

to make the curve structure very smooth i made a Function which can make a Array of very fine X Y coordinates using Float numbers

But nothing is showing in the GUI


.................................................................. ___ ........................... ____
When i tried with Integers i got a Figure <___> rather than this ( ____) therefore i was forced to use Floats

Edited by PhoenixXL, 15 June 2012 - 06:39 AM.

PredictText: Predict Text of an Edit Control Like Scite. | Remote Gmail: Execute your Scripts through Gmail. | StringRegExp: Share and learn RegExp. | Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). | Database: An easier approach for _SQ_LITE beginners. | MathsEx: A UDF for Fractions and LCM, GCF/HCF. | FloatingText: An UDF for make your text floating. | Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead.





#2 eukalyptus

eukalyptus

    Adventurer

  • Active Members
  • PipPip
  • 102 posts

Posted 15 June 2012 - 07:28 AM

Hi

first of all you have to use a Pen to draw a curve: _GDIPlus_PenCreate
and you should use a backbuffer-system to keep the graphics on the GUI

GDI+ curves are cardinal splines;
You only have to define 3 Points for your curve

The original DrawCurve-function converts your float-values to integer: "GdipDrawCurveI"
use GdipDrawCurve2 instead:

AutoIt         
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) Global $iWidth = 400 Global $iHeight = 300 _GDIPlus_Startup() Global $hGUI = GUICreate("GDI+", 400, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer) _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2) _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000) Global $hPen_Red = _GDIPlus_PenCreate(0xFFFF0000) Global $hPen_Green = _GDIPlus_PenCreate(0xFF00FF00) Global $tCurve = DllStructCreate("float[6];") DllStructSetData($tCurve, 1, 10, 1) DllStructSetData($tCurve, 1, 10, 2) DllStructSetData($tCurve, 1, 110, 3) DllStructSetData($tCurve, 1, 110, 4) DllStructSetData($tCurve, 1, 10, 5) DllStructSetData($tCurve, 1, 210, 6) DllCall($ghGDIPDll, "uint", "GdipDrawCurve2", "hwnd", $hGfxBuffer, "hwnd", $hPen_Red, "ptr", DllStructGetPtr($tCurve), "int", 3, "float", 0) DllCall($ghGDIPDll, "uint", "GdipDrawCurve2", "hwnd", $hGfxBuffer, "hwnd", $hPen_Green, "ptr", DllStructGetPtr($tCurve), "int", 3, "float", 0.5) _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0) GUIRegisterMsg($WM_PAINT, "WM_PAINT") GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT") GUISetState() While Sleep(100) WEnd Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam) _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0) Return $GUI_RUNDEFMSG EndFunc   ;==>WM_PAINT Func _Exit() _GDIPlus_PenDispose($hPen_Red) _GDIPlus_PenDispose($hPen_Green) _GDIPlus_GraphicsDispose($hGfxBuffer) _GDIPlus_BitmapDispose($hBmpBuffer) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Exit EndFunc   ;==>_Exit


E

#3 UEZ

UEZ

    Never say never

  • MVPs
  • 3,600 posts

Posted 15 June 2012 - 09:04 AM

To complete the "keep the graphics on the GUI" part, add GUISetOnEvent($GUI_EVENT_RESTORE, "WM_PAINT") to the code.

Btw, have a look here: http://www.autoitscript.com/forum/index.php?showtopic=97362

Br,
UEZ

Edited by UEZ, 15 June 2012 - 09:05 AM.

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#4 PhoenixXL

PhoenixXL

    Be what you are, believe me its always the BEST...

  • Active Members
  • PipPipPipPipPipPip
  • 1,316 posts

Posted 15 June 2012 - 12:15 PM

Thnx for the link UEZ thats what I wanted

and

Thnx Eucalyptus for the Script
PredictText: Predict Text of an Edit Control Like Scite. | Remote Gmail: Execute your Scripts through Gmail. | StringRegExp: Share and learn RegExp. | Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). | Database: An easier approach for _SQ_LITE beginners. | MathsEx: A UDF for Fractions and LCM, GCF/HCF. | FloatingText: An UDF for make your text floating. | Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users