Drawing

The drawing file holds TMufasaBitmap drawing functions to aid drawing onto bitmaps.

The source for this file can be found here <https://github.com/SRL/SRL/blob/master/shared/drawing.simba>.


const __SHADOW_COLOR

Integer constant that stores the shadow color for adding a shadow for text drawing.


TMufasaBitmap.FromClient

procedure TMufasaBitmap.FromClient(Area: TBox);

Copy client to bitmap.


TMufasaBitmap.Clear

procedure TMufasaBitmap.Clear();

Will clear the entire TMufasaBitmap

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.Clear();

TMufasaBitmap.ClearArea

procedure TMufasaBitmap.ClearArea(area: TBox);

Will clear the desired area of the TMufasaBitmap

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.ClearArea(intToBox(5, 5, 10, 10));

TMufasaBitmap.ClearAllBut

procedure TMufasaBitmap.ClearAllBut(Area: TBox);

Will clear the image, except for the given area.


TMufasaBitmap.AvgBrightness

procedure TMufasaBitmap.AvgBrightness();

Returns a value between 0 and 100 that defines how bright the image is.


TMufasaBitmap.PeakBrightness

procedure TMufasaBitmap.PeakBrightness();

Returns the maximum brightness in the image in the range 0..100.


TMufasaBitmap.DrawBox

procedure TMufasaBitmap.DrawBox(box: TBox; fill: boolean; color: TColor);

Draws a TBox onto the TMufasaBitmap

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DrawBox(intToBox(50, 50, 345, 345), false, clLime);

TMufasaBitmap.DrawBox

procedure TMufasaBitmap.DrawBox(pt:TPoint; Radius:UInt32; Fill: Boolean; color: TColor);

Draws a TBox onto the TMufasaBitmap


TMufasaBitmap.DrawBox

procedure TMufasaBitmap.DrawBox(box:TBox; color:TColor = clRed); overload;

Overloaded function, will draw the outline of the “box” and includes a optional color parameter (default red).

Note

  • by Ollybest
  • Last Updated: 19 August 2013 by Ollybest

Example:

bmp.DrawBox(IntToBox(50, 50, 345, 345));

TMufasaBitmap.DrawBox; overload

procedure TMufasaBitmap.DrawBox(x1,y1,x2,y2:Integer; fill:Boolean; color:TColor); overload;

Draws a box using the x1, y1, x2, y2 parameters, will fill if ‘fill’ is set to true using color ‘color’.

Note

  • by Olly
  • Last Updated: 29 October 2013 by Olly

Example:

bmp.DrawBox(Box(50, 50, 345, 345));

TMufasaBitmap.DrawClippedBox

procedure TMufasaBitmap.DrawClippedBox(box: TBox; fill: boolean; color: TColor); overload;

Same as the other TMufasaBitmap.DrawBox but is clipped so it won’t draw off the bounds of the bitmap.

Note

  • by Olly
  • Last Updated: 29 October 2013 by Olly

Example:

image.DrawClippedBox(Box(50, 50, 100, 100), true, clLime);

TMufasaBitmap.DrawBoxes

procedure TMufasaBitmap.DrawBoxes(boxArr: TBoxArray; fill: boolean; color: TColor);

Draws a TBoxArray onto the TMufasaBitmap.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DrawBoxes([Box(10, 10, 20, 20), Box(50, 50, 250, 250),
                 Box(440, 440, 600, 600)], true, clRed);

TMufasaBitmap.DrawBoxes; overload

procedure TMufasaBitmap.DrawBoxes(boxArr: TBoxArray; fill: boolean; colors: TColorArray); overload;

Same as TMufasaBitmap.DrawBoxes() but accepts a extra paramter that allows a color for each box.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DrawBoxes([Box(10, 10, 20, 20), Box(50, 50, 250, 250),
                 Box(440, 440, 600, 600)], true, [clRed, clLime, clOrange]);

TMufasaBitmap.DrawRect

procedure TMufasaBitmap.DrawRect(Rect: TRectangle; color: TColor);

Draws a TRectangle onto the TMufasaBitmap


TMufasaBitmap.DrawPoly

procedure TMufasaBitmap.DrawPoly(Poly: TPointArray; color: TColor);

Draws a polygon onto the TMufasaBitmap


TMufasaBitmap.DrawBitmap

procedure TMufasaBitmap.DrawBitmap(bmp: Integer; pnt: TPoint);

Draws a bitmap onto the TMufasaBitmap at the desired point.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DrawBitmap(bmp, point(50, 50));

TMufasaBitmap.DrawBitmap; overload

function TMufasaBitmap.DrawBitmap(path: string; pt: TPoint): boolean; overload;

Same as TMufasaBitmap.DrawBitmap but will load a bitmap from a file specified by the paramter “path”, will return if succesful or not.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DrawBitmap('simba/scripts/foo.png', point(11, 11));

TMufasaBitmap.DrawCross

procedure TMufasaBitmap.DrawCross(pt: TPoint; size: Integer; color: TColor);

Draws a cross on the TMufasaBitmap at the TPoint pt with the desired size.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DrawCross(Point(200, 200), 4, clLime);

TMufasaBitmap.DrawEllipse

procedure TMufasaBitmap.DrawEllipse(const pnt: TPoint; const xRadius, yRadius: Integer; const fill: boolean; const color: TColor);

Draws an ellipse on the TMufasaBitmap defined by ‘pnt’, ‘xRadius’, and ‘yRadius’. If ‘fill’ is true it will fill the ellipse, otherwise it draws just the border.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DrawEllipse(point(500, 500), 20, 50, true, clLime);

TMufasaBitmap.DrawCircle

procedure TMufasaBitmap.DrawCircle(pnt: TPoint; radius: Integer; fill: boolean; color: TColor);

Draws a circle on the TMufasaBitmap defined by ‘pnt’ and ‘radius’. If ‘fill’ is true it will fill the circle, otherwise it draws just the border.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DrawCircle(point(500, 500), 50, false, clLime);

TMufasaBitmap.DrawPolygon

procedure TMufasaBitmap.DrawPolygon(polygonPnts: TPointArray; color: TColor);

Draws a line between all the points(polygonPnts) to draw a polygon-like shape on the TMufasaBitmap.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DrawPolygon([point(10, 10), point(100, 100), point(500, 500), point(230, 555)], clLime);

TMufasaBitmap.DrawClippedText

procedure TMufasaBitmap.DrawClippedText(txt: string; pt: TPoint; font: string; shadow: boolean; color: TColor);

Same as drawText, but is clipped so it won’t draw off the bounds of the bitmap.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DrawClippedText('hello world!', point(55, 55), 'StatChars', true, clLime);

TMufasaBitmap.DrawTextArray

procedure TMufasaBitmap.DrawTextArray(txtArr: TStringArray; pts: TPointArray; font: string; shadow: boolean; color: TColor);

Draws an array of text on the TMufasaBitmap, each index in the textArr will be be drawn at the same point in the pnt array.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.drawTextArray(['hello', 'world'], [point(50, 50), point(100, 111)], bigchars, false, clBlue);

TMufasaBitmap.DrawTextLines

procedure TMufasaBitmap.DrawTextLines(txtArr: TStringArray; pnt: TPoint; font: string; shadow: boolean; color: TColor);

Draws text onto the TMufasaBitmap, each index in the txtArr is put on a different line.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.drawTextLines(['olly', 'is', 'the', 'best', ':D'], point(2, 2), statChars, false, clRed);

TMufasaBitmap.Debug

procedure TMufasaBitmap.Debug();

Will display the TMufasaBitmap in Simba’s debug image form. Note: will only work if the bitmap is managed by Simba

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

Image.Debug();
// or for a non TMufasaBitmap
GetMufasaBitmap(bitmap).Debug();

TMufasaBitmap.DebugEx

procedure TMufasaBitmap.DebugEx(SetManaged: Boolean=True; MinSize: Int32=128); constref;

Will display the TMufasaBitmap in Simba’s debug image form. Note that if the bitmap isn’t managed by Simba it will be added if SetManaged is True. Alterantive parameter MinSize is used to better display small images.

Example:

pascal::
Image.DebugEx(); // or for a non TMufasaBitmap GetMufasaBitmap(bitmap).DebugEx();

TMufasaBitmap.UpdateDebugImage

procedure TMufasaBitmap.UpdateDebugImage();

Will update Simba’s debug image form with the current image.


TMufasaBitmap.DebugTPA

procedure TMufasaBitmap.DebugTPA(tpa: TPointArray; drawPoints: boolean = true);

Will debug a TPointArray onto the TMufasaBitmap, parameter drawPoints is a optional parameter and by default is enabled, if enabled it will draw the points in the array.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DebugTPA(tpa);

TMufasaBitmap.DebugATPA

procedure TMufasaBitmap.DebugATPA(const ATPA: T2DPointArray);

Will debug a T2DPointArray onto the TMufasaBitmap.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DebugATPA(ATPA);

TMufasaBitmap.DebugDTM

procedure TMufasaBitmap.DebugDTM(dtm: Integer; area: TBox; color: TColor);

Will search for the dtm in the desired area, drawing a cross at each point that is found.

Note

  • by Ollybest
  • Last Updated: 19 July 2013 by Ollybest

Example:

image.DebugDTM(myDTM, mainScreen.getBounds(), clRed);