npDraw plugin

About this plugin

This plugin allow you to put one or more Draw objects attached on NeoBook rectangles. You can use the canvas of this objects to draw individual pixels, lines, chord, pie, rectangles, rounded rectangles, frames, polygons, cubic Beziers, text and more.

More than 50 actions allowing you to get and set Pen position color, mode, style and width; get and set Brush color, style and bitmap; get and set fonts, even if are not installed on the system. In fact, this plugin allow you to create or modify bitmaps programatically.

Thirparty

This plugin are imposible without the aid of this people:

Thanks a lot!

Plugin actions index

npDrawCreate

Create a new instance of a Draw object and attach it to a NeoBook rectangle object. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawDestroy

Destroy a previously Draw object instance and deattach from their NeoBook rectangle. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawDestroyAll

Destroy all previously Draw objects instances and deattach from their NeoBook rectangles.

↑↑

npDrawGetPenPos

Get the Pen position of the specified Draw object instance. Execute this action to learn the current drawing position of the Pen. This is the starting point of a line drawn by the npDrawLineTo action. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawSetPenPos

Set the Pen position of the specified Draw object instance. Specifies the current drawing position of the Pen. This is the starting point of a line drawn by the npDrawLineTo action. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawGetPenColor

Get the Pen color of the specified Draw object instance. The format of the color is in the NeoBook way: "R,G,B" values. The result variable store the Pen color if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawSetPenColor

Set the Pen color of the specified Draw object instance. The format of the color must be set in the NeoBook way: "R,G,B" values. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawGetPenMode

Get the Pen mode of the specified Draw object instance. The result variable store the current Pen mode or "False" if an error occur. In this case the [LastError] store the error information. The Pen mode can be one of the listed below in npDrawSetPenMode action.

↑↑

npDrawSetPenMode

Set the Pen mode of the specified Draw object instance. Determines how the pen draws lines on the canvas. Below you can see the possible values for Pen mode:

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawGetPenStyle

Get the Pen style of the specified Draw object instance. The result variable store the current Pen style or "False" if an error occur. In this case the [LastError] store the error information. The Pen style can be one of the listed below in npDrawSetPenStyle action.

↑↑

npDrawSetPenStyle

Set the Pen style of the specified Draw object instance. Determines the style in which the pen draws lines. Below you can see the possible values for Pen style:

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawGetPenWidth

Get the Pen width of the specified Draw object instance. The result variable store the Pen width in pixels if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawSetPenWidth

Set the Pen width of the specified Draw object instance. Specifies the width of the pen in pixels. Note the value of Pen width influences which values of Pen style are valid. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawGetBrushColor

Get the Brush color of the specified Draw object intance. The format of the color is in the NeoBook way: "R,G,B" values. The result variable store the Brush color if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawSetBrushColor

Set the Brush color of the specified Draw object instance. The format of the color must be set in the NeoBook way: "R,G,B" values. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawGetBrushStyle

Get the Brush style of the specified Draw object intance. The result variable store the current Brush style or "False" if an error occur. In this case the [LastError] store the error information. The Brush style can be one of the listed below in npDrawSetBrushStyle action.

↑↑

npDrawSetBrushStyle

Set the Brush style of the specified Draw object instance. Determines the pattern of the brush. The Brush style can be one of the following values: bsSolid, bsClear, bsHorizontal, bsVertical, bsFDiagonal, bsBDiagonal, bsCross, bsDiagCross. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawSetBrushBitmap

Set the Brush bitmap of the specified Draw object intance. Specifies an external bitmap image that defines a pattern for the brush. The bitmap image (rather than the Brush style property -see npDrawSetBrushStyle) defines the brush pattern. If the image is larger than eight pixels by eight pixels, only the top left eight-by-eight region is used. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawGetPixel

Get a pixel color of the specified Draw object instance. Get the color on the drawing surface at a specific pixel position. The format of the color is in the NeoBook way: "R,G,B" values. The result variable store the pixel color if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawSetPixel

Set a pixel color of the specified Draw object instance. Change the color of individual pixels on the drawing surface. The format of the color must be set in the NeoBook way: "R,G,B" values. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawArc

Draws an arc on the specified Draw object instance. Draws an arc on the image along the perimeter of the ellipse bounded by the specified rectangle. The arc traverses the perimeter of an ellipse that is bounded by first and second points. The arc is drawn following the perimeter of the ellipse, counterclockwise, from the starting point to the ending point. The starting point is defined by the intersection of the ellipse and a line defined by the center of the ellipse and the third point. The ending point is defined by the intersection of the ellipse and a line defined by the center of the ellipse and the four point.

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawPie

Draws a pie on the specified Draw object instance. Draws a pie-shaped section of the ellipse bounded by the rectangle (first and second points) on the canvas. Use this to draw a pie-shaped wedge on the image. The wedge is defined by the ellipse bounded by the rectangle determined by the first and second points. The section drawn is determined by two lines radiating from the center of the ellipse through the third and four points. The wedge is outlined using the Draw Pen, and filled using Draw Brush.

Note on Windows 9x or Windows ME, the sums X1 + X2 and Y1 + Y2 cannot exceed 32768. Also, the sum X1 + X2 + Y1 + Y2 cannot exceed 32768. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawDraw

Draws a graphic on the specified Draw object instance. Renders the specified image on the canvas at the location given by the specified point. The image can be BMP, ICO, WMF, JPG or PNG. If the image is a bitmap, the bitmap is rendered using the value specified by the npDrawSetCopyMode action. Optionally you can set the argument Transparent to "True" if you want to draw the image in transparent mode: this apply only to BMP images. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawRect

Draws a rectangle on the specified Draw object instance. Draw a rectangle using the Draw Pen and fill it with Draw Brush on the specified rectangle coordinates. To fill a rectangular region without drawing the boundary in the current pen, use npDrawFillRect. To outline a rectangular region without filling it, use npDrawFrameRect or npDrawPolygon. To draw a rectangle with rounded corners, use npDrawRoundRect.

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawRoundRect

Draws a rounded rectangle on the specified Draw object instance. Draw a rounded rectangle using the Draw Pen and fill it with Draw Brush. The rectangle will have edges defined by the three points, but the corners will be shaved to create a rounded appearance. The curve of the rounded corners matches the curvature of an ellipse specified by the third point. To draw an ellipse instead, use npDrawEllipse. To draw a true rectangle, use npDrawRect.

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawStretch

Draws a graphic stretched on a rect in the the specified Draw object instance. Draws the specified on the canvas so that the image fits in the specified rectangle. This may involve changing magnification and/or aspect ratio. To render the image in its natural size, use the npDrawDraw action, instead. The image can be bitmaps, icons, or metafiles. If the image is a bitmap, the bitmap is rendered using the value specified by the npDrawSetCopyMode action. Note if the graphic is an icon, it is not stretched.

Optionally you can set the argument Transparent to "True" if you want to draw the image in transparent mode. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawChord

Create a shape that is defined by an arc and a line that joins the endpoints of the arc. The chord consists of a portion of an ellipse that is bounded by the first and second points. The ellipse is bisected by a line that runs between the three and four points.

The perimeter of the chord runs counter clockwise from the third point, counterclockwise along the ellipse to the four point, and straight back to third point. If the third and four points are not on the surface of the ellipse, the corresponding corners on the chord are the closest points on the perimeter that intersect the line. The outline of the chord is drawn using the value of Draw Pen, and the shape is filled using the value of Draw Brush.

Note on Windows 9x or Windows ME, the sums X1 + X2 and Y1 + Y2 cannot exceed 32768. Also, the sum X1 + X2 + Y1 + Y2 cannot exceed 32768. On NT, the drawing direction can be changed to clockwise using the npDrawSetArcDir action.

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawLineTo

Draws a line on the specified Draw object instance. Draw a line from the current pen position up to, but not including the specified point. This action changes the value of the pen position to the specified point. The line is drawn using the Draw pen. Note if the current pen does not have a style of psSolid, the line is drawn with a background specified by the current Draw brush.

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawTextOut

Draws a text on the specified Draw object instance. Writes a string on the canvas, starting at the specified point, and then updates the pen position to the end of the string. The string will be written using the current value of Draw font (see npDrawSetFont). Use the npDrawTextWidth and npDrawTextHeight actions to determine the space occupied by the text in the image. To write only the text that fits within a clipping rectangle, use npDrawTextRect instead.

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawTextRect

Draws a text rect on the specified Draw object instance. Write a string within a limited rectangular region. Any portions of the string that fall outside the specified rectangle are clipped and don't appear. The upper left corner of the text is placed at the specified point. You can choose one or more of this text format options:

If use tfModifyString the result variable store the string which finally is draw on the canvas. In other case the result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawEllipse

Draws an ellipse on the specified Draw object instance. Use this action to draw a circle or ellipse on the canvas. If the bounding rectangle is a square, a circle is drawn. The ellipse is outlined using the value of Draw pen, and filled using the value of Draw brush. Note on Windows 9x or Windows ME, the sums X1 + X2 and Y1 + Y2 cannot exceed 32768. Also, the sum X1 + X2 + Y1 + Y2 cannot exceed 32768.

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawPolygon

Draws a polygon on the specified Draw object instance. Draws a series of lines on the canvas connecting the points passed in and closing the shape by drawing a line from the last point to the first point. Use this action to draw a closed, many-sided shape on the canvas, using the value of Draw pen. After drawing the complete shape, this action fills the shape using the value of Draw brush.

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawPolyline

Draws a polyline on the specified Draw object instance. Use this action to connect a set of points on the canvas. If you specify only two points, this action draws a single line. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawPolyBezier

Draws cubic Bezier curves on the specified Draw object instance. Use this action to draw cubic Bezier curves using the endpoints and control points specified by the points argument. The first curve is drawn from the first point to the fourth point, using the second and third points as control points. Each subsequent curve in the sequence needs exactly three more points: the ending point of the previous curve is used as the starting point, the next two points in the sequence are control points, and the third is the ending point. This action draws lines by using the current pen.

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawFillRect

Fills the specified rectangle on the specified Draw object instance. Use this action to fill a rectangular region using the current brush. The region is filled including the top and left sides of the rectangle, but excluding the bottom and right edges. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawFrameRect

Draws a frame rect on the specified Draw object instance. Use this action to draw a 1 pixel wide border around a rectangular region. FrameRect does not fill the interior of the rectangle with the Brush pattern. To draw a boundary using the Pen instead, use the npDrawPolygon action. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawFloodFill

Fills an area of the specified Draw object instance using the current Draw object instance brush. Use this action to fill a possibly non-rectangular region of the image with the value of brush. The boundaries of the region to be filled are determined by moving outward from the specified point until a color boundary involving the specified color is encountered. The point determine the coordinates on the canvas where filling starts. Color is the color that defines the boundary of the region to fill. Its interpretation depends on the value of Style. Style specifies whether the region is defined by all pixels with the same value as Color (fsBorder), or all points with a different value (fsSurface).

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawCopyRect

Transfer a part of a Draw object instance to another Draw object instance. Use this action to transfer part of the image on another Draw object instance to the image of the specified Draw object instance. Destiny rect specifies the rectangle on the canvas where the source image will be copied. The Source Draw specifies the canvas with the source image. Source rect specifies a rectangle bounding the portion of the source canvas that will be copied. The portion of the source canvas is copied using the mode specified by npDrawGetCopyMode.

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawGetCopyMode

Get the Copy Mode of the specified Draw object instance. See npDrawTextRect to know the possible values returned by this action. The result variable store the current copy mode if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawSetCopyMode

Set the Copy Mode of the specified Draw object instance. Set the copy mode to affect the way graphical images are drawn onto the canvas. The copy mode is used when copying an image from another canvas using the npDrawCopyRect action. The copy mode is also used by Draw objects when they draw themselves to another. Use copy mode to achieve a variety of affects when rendering an image. Achieve special effects like merged images and making parts of a bitmap transparent by combining multiple images with different copy modes.

The possible copy mode can be one of the following:

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawGetFont

Get the font of the specified Draw object instance. The result variable store the currently stablished font in a NeoBook way, for example: "Verdana|16|8,0,0|Bold+Underline+Strikeout", or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawSetFont

Set the font of the specified Draw object instance. Specify the name of an installed font in order to use with actions like npDrawTextOut or npDrawTextRect. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawSystemFonts

Get a list with the installed system fonts. The result variable store a NeoBook array (zero indexed) with the names of the installed fonts. The result count variable store the number of items on the result variable array.

↑↑

npDrawFontExists

Find if a font is available to be use on Draw objets. Specify the name of a font in order to find if is available to be use on the Draw object. The font can be one of the installed on the system. The result variable store "True" if the font is available to use, or "False" when not, or if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawCreateRect

Create a Rect value from the specified coordinates. Some actions on this plugin require a "rect" argument. With this action you can create a rect to be passed on such actions. A rect is conformed by an "Left", "Top", "Right", "Bottom" and have this form: "Top,Left,Right,Bottom", for example: "12,14,100,200". You can use this action or directly pass this kind of values to the actions who require a rect value. The result variable store a rect value, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawCreatePoint

Create a Point value from the specified coordinates. Some actions on this plugin require a "point" argument. With this action you can create a point to be passed on such actions. A point is conformed by an X and a Y coordinates and have this form: "X,Y", for example: "12,14". You can use this action or directly pass this kind of values to the actions who require a point value. The result variable store a point value, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawSaveBitmap

Save to a file the bitmap of the specified Draw object instance. Specify the bitmap file path to store the image. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawGetArcDir

Get the current arc direction using on the specified Draw object instance. See also npDrawSetArcDir. The result variable store one of this values: AD_COUNTERCLOCKWISE orAD_CLOCKWISE, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawSetArcDir

Set the current arc direction using on the specified Draw object instance. The possible values for the arc direction can be:

↑↑

npDrawTextWidth

Use this action to determine the length a string will occupy in the image. This indicates whether a given string will fit in the available space. Other graphical elements in the image such as lines or additional strings can be positioned to accommodate the width of the text. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawTextHeight

Use this action to determine the height a string will occupy in the image. Other elements in the image such as lines, boxes, or additional lines of text can be positioned to accommodate the height of the text. This action returns the height of the font, the ascenders and the descenders, not the actual height of the specified string. If the height of the font is negative, then text height is calculated by summing the absolute value of the font's height with the internal leading of the font; otherwise, the text height is equals to the height of the font.

The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npDrawScreenPPI

Retrieve the Screen Pixels Per Inch value of the current screen device. The result variable store the desired value.

↑↑

npDrawScreenDPI

Retrieve the Screen Dot Per Inch value of the current screen device. The horizontal variable store the horizontal DPI, and the vertical variable store the vertical DPI.

↑↑

npDrawIsSolidColor

Find if the specified Draw object bitmap is only of the supplied color. For example, specify the white color ("255,255,255") to check if specified Draw object is enterely white or not. The result variable store "True" if the Draw object color is enterely in the specified color or "False" when not. If an error occur the [LastError] contain additional information.

↑↑

npOnDrawClick

Set a publication subroutine to be executed when the Draw click event is fired. The rectangle variable store the rectangle in which the click has made. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npOnDrawDblClick

Set a publication subroutine to be executed when the Draw double click event is fired. The rectangle variable store the rectangle in which the double click has made. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npOnDrawMouseDown

Set a publication subroutine to be executed when the Draw mouse down event is fired. The rectangle variable store the rectangle in which the mouse down has made. The button variable can contain one the values: mbLeft, mbMiddle or mbRight. The X variable store the mouse X position, and the Y variable the Y mouse position. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npOnDrawMouseMove

Set a publication subroutine to be executed when the Draw mouse move event is fired. The rectangle variable store the rectangle in which the mouse move has made. The X variable store the mouse X position, and the Y variable the Y mouse position. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

npOnDrawMouseUp

Set a publication subroutine to be executed when the Draw mouse up event is fired. The rectangle variable store the rectangle in which the mouse up has made. The button variable can contain one the values: mbLeft, mbMiddle or mbRight. The X variable store the mouse X position, and the Y variable the Y mouse position. The result variable store "True" if everything is OK, or "False" if an error occur. In this case the [LastError] store the error information.

↑↑

Action errors subroutine

All the NeoPlugins deal with errors in the same way that NeoBook does: when the plugin found an action error the [LastError] variable store information about the error, so you can take care about this variable when execute an action.

But all the NeoPlugins also incorporate an advanced way to deal with possible action errors. You can define a subroutine named OnNeoPluginActionError in order to be executed when some action error are found and you can use this variables inside:

Note that this error handling subroutine are shared for all the NeoPlugins, so you no need to specify a subroutine for every plugin you use in your publication because the same subroutine are recognized and automagically used by every NeoPlugin. Below you can view a sample of this subroutine code:

:OnNeoPluginActionError
  AlertBox "NeoPlugin Error" "Error [LastError] in plugin: [PluginName]"
Return

Also note that the use of this NeoPlugins error handling subroutine is completelly optional. You can continue using the [LastError] variable as usual and even use the both methods at the same time.

↑↑