Jump to content

Recommended Posts

Posted

Hello,

This is my GdiPlus Canvas script. 
It should make Graphic or Game Programming with AutoIt easier (at least for the beginners). 

The idea is to open a Canvas (or graphics/screen) to be drawn on. 
This solution is "Include and forget" - you just need to include it and the script will handle the unloading of the images, fonts and other gdi handles when you end  your script.
(p.s. only those created by the script, not the ones you create outside the provided functions)

You can load, save, images, clipboard content and screenshots,  draw lines, circles, Text and other things on them or on the Canvas.

The command set and idea is heavily based on the BlitzBasic3d language, and mimics it's behavior.
When you set a color, all drawings will use that color, until changed.
Drawing on a image instead of the canvas is, as well, possible by setting the image as the active buffer.

Included in the 7zip file are many examples, tests and help files.
Help is available as .txt, pdf, Png, RTF and as autoit script.
Here is the command list available:

Color  RGB  GetColor  PenSize  Plot  Line  Rect  Circle  Ellipse  Pie  Polygon
DrawImage DrawImageSize  DrawImageZoom  DrawAnimImage  SetAnimImage  DrawImageFlip DrawRotate
BlendMode
Flip Cls 
SetBuffer  BackBuffer  ImageBuffer  SaveImage  LoadImage  CreateImage  CloneImage
ScreenShotImage  FreeImage  ImageToClipboard  CanvasToClipboard  ClipboardToImage  
AppTitle
ImageWidth  ImageHeight  AnimWidth  AnimHeight  CanvasWidth  CanvasHeight  CanvasDrawWidth  CanvasDrawHeight
Rand Text
Print              (as in Qbasic/GwBasic text display routine. )
SetFont  FontStyle  LoadFont  FreeFont  FontSize  FontName  
MouseX  MouseY  MouseRX  MouseRY  MouseGX  MouseGY  MouseZ  GetMouseCoords
KeyDown 
Window  Canvas  SetCanvas  SetGuiStyle  SetGuiExStyle  
GuiHWND  Debug
GetSaveNameDialog  GetLoadNameDialog
SetProcessDpiAwareness

Here is an example program using this Include. It is a Pendulum from Rosettacode.org :
 

#include "..\GDIP_Canvas.au3"
#NoTrayIcon

Opt("GUIOnEventMode", 1)

Window("Pendulum from Rosettacode", 640, 400, 0, 30)
GUISetBkColor(0x606060, $hgui)
Canvas(640, 400, 0, 0)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

;https://rosettacode.org/wiki/Animate_a_pendulum
Const $PI = 3.141592920
Global $theta, $g, $l, $accel, $speed, $px, $py, $bx, $by
$theta = $PI/2
$g = 9.81
$l = 1
$speed = 0
$px = 320
$py = 10

$deg=180/$Pi

While 1
    $bx=$px+$l*300*Sin($theta*$deg)
    $by=$py-$l*300*Cos($theta*$deg)
    Cls()
    Line ($px,$py,$bx,$by)
    Ellipse ($bx-12,$by-12,25,25,1)
    $accel=$g*Sin($theta*$deg)/$l/100
    $speed=$speed+$accel/100
    $theta=$theta+$speed
    Print ("Pendulum",0,350)
    Print ("Press ESC key to quit",0,372)
    Flip(30)
WEnd


Func SpecialEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
    EndSelect
EndFunc   ;==>SpecialEvents



Have fun !

GDICanvas-release01.7z

Some of my script sourcecode  ,  Gdi+ Canvas

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...