ImageTools[Draw] - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Graphics : Image Processing : ImageTools Package : Draw Subpackage : ImageTools/Draw/Poly

ImageTools[Draw]

  

Poly

  

ImageTools:-Draw Poly Primitive

 

Calling Sequence

Parameters

Description

Package Usage

Examples

Compatibility

Calling Sequence

Poly( image, points, color, thickness, round, pattern, fill_color, fill_pattern )

Parameters

image

-

ImageTools:-Image

points

-

{list(list(numeric)), Array, Matrix}

color

-

(optional) see description

thickness

-

(optional) numeric := 1.0

round

-

(optional) truefalse := false

pattern

-

(optional) identical("none", "solid", "dash", "dot", "dashdot", "dashdotdot") := "solid"

fill_color

-

(optional) see description; default is 0.5 (50% gray)

fill_pattern

-

(optional) identical("none", "solid", "horizontal", "vertical", "cross", "forward", "backward", "diagonalCross", "horizontalCylinder", "verticalCylinder", "sphere") := "none"

Description

• 

After first creating an image using ImageTools:-Create, or loading an image with ImageTools:-Read, drawing operations can be performed on it using a number of primitives (functions that draw one kind of object). The first argument to each primitive is the image itself, as returned by Create or Read.

• 

The Poly primitive draws a multi-segment line (polyline) or closed shape (polygon) given a list, Array, or Matrix of points.

• 

The points of the polyline or polygon are specified by the points argument, which must be a list of lists where each sublist contains two numeric values, or an N×2 numeric Array or Matrix. If the first and last points are coincident, then a polygon is drawn, otherwise a polyline is drawn (the distinction is only relevant if a fill pattern is specified).

• 

The color argument controls the polygon's line color and is also used for the color of the lines in the specified pattern.  For the "cylindrical" and "spherical" patterns, the line color is used as the most distant color.

  

The color and fill_color arguments can be specified in one of several forms:

gray

A numeric value between 0 and 1 specifying a shade of gray. The value 0 corresponds to black, and 1 to white.

[r,g,b]

A list of three numeric values between 0 and 1 specifying the red, green, and blue components separately.

[r,g,b,α]

A list of four numeric values between 0 and 1 specifying the red, green, blue, and opacity (alpha) separately. When the opacity is less than 1, the color will be blended with the existing content of the image.

ColorTools:-Color

A value of type ColorTools:-Color.

ColorTools:-Color argument(s)

Any form accepted by the ColorTools:-Color constructor, such as a string giving a color name (e.g. "red", palette and color name (e.g. "Niagara DarkOrchid"), or palette and color number (e.g. "Nautical 1"). Two argument forms are accepted as well, but then it is necessary to always use the keyword form of the color argument, since otherwise the two arguments will be interpreted as two separate arguments to the drawing primitive. For example, color=("HSV",[0.5,0.6,0.6]).

• 

The thickness argument specifies the apparent thickness of the line, measured in pixels. Because of anti-aliasing, the number of pixels used to render the line at any point may be more than this, but the line will appear to be of the specified thickness.

  

Line segments are drawn from point to point, with half of the thickness falling on either side of the zero-width mathematical line between the two points.

• 

If the round argument is specified as true, then the segment ends will be rounded, and the specified end-points will be the centers of those rounded ends, i.e., the segment will extend by half its thickness in all directions from the end-points.  By default, each line segment ends exactly at the specified coordinates, and for a thickness noticeably larger than 1, the ends of the segment will be perpendicular to the segment itself.

• 

The pattern argument can be used to draw lines with one of a fixed number of patterns. The default pattern, solid, draws solid lines. The other available patterns are:

  

"dash"

  

"dot"

  

"dashdot"

  

"dashdotdot"

  

"none"

• 

The fill_pattern argument specifies how a polygon is to be filled. The default is "none", indicating that only the outline will be drawn. If "solid" is specified, then the polygon will be completely filled with the color specified by fill_color. The other possible fill patterns are:

  

"horizontal" - horizontal lines

  

"vertical" - vertical lines

  

"cross" - horizontal and vertical lines

  

"forward" - forward diagonal lines

  

"backward" - backward diagonal lines

  

"diagonalCross" - forward and backward diagonal lines

  

"horizontalCylinder" - shading giving a horizontal cylindrical appearance

  

"verticalCylinder" - shading giving a vertical cylindrical appearance

  

"sphere" - shading giving a spherical appearance

• 

When drawing a polygon that is to be filled (as specified by fill_pattern), then the fill_color argument specifies the color it is to be filled with. In the case of a non-solid fill pattern, this will be the background color of the pattern.

• 

The options beginning with color are best provided as keyword equations, but can also be provided as positional arguments starting in the 3rd position as declared in the calling sequence above.

Package Usage

• 

This function is part of the ImageTools:-Draw package, so it can be used in the short form Poly(..) only after executing the command with(ImageTools:-Draw). However, it can always be accessed through the long form of the command by using ImageTools:-Draw:-Poly(..).

Examples

withImageTools:

withImageTools:-Draw:

Thin polyline.

imgCreate240,320,channels=3,background=white:

Polyimg,32,32,100,180,220,60,288,208,color=0.25

Embedimg

Filled polygon.

imgCreate240,320,channels=3,background=white:

Polyimg,32,32,100,180,288,208,220,60,126,86,32,32,color=0.25,thickness=1,round=true,pattern=solid,fill_color=0.9,1,0.8,fill_pattern=solid

Embedimg

Very thin and thick polylines.

imgCreate240,320,channels=3,background=white:

Polyimg,32,32,68,180,188,60,256,208,color=0.25,thickness=0.5,round=true

Polyimg,64,32,100,180,220,60,288,208,color=0.25,thickness=4,round=true

Embedimg

Round vs. square segment ends, and color transparency.

imgCreate240,320,channels=3,background=white:

Polyimg,32,32,68,180,188,60,256,208,color=1,0,0,0.9,thickness=8,round=false

Polyimg,64,32,100,180,220,60,288,208,color=0,0.66,0,0.9,thickness=8,round=true

Embedimg

Polyline pattern examples.

imgCreate100,200,channels=3,background=white:

Polyimg,5,10,195,12.5,195,25,color=0,thickness=2,pattern=dash

Polyimg,195,25,195,25,20,25,color=0,thickness=2,pattern=dot

Polyimg,20,25,50,40,195,40,195,55,color=0,thickness=2,pattern=dashdot

Polyimg,195,55,5,55,5,10,color=0,thickness=2,pattern=dashdotdot

Embedimg

Fill pattern examples.

imgCreate240,180,channels=3,background=white:

Polyimg,5,5,55,5,55,55,5,55,5,5,color=0,fill_color=0.9,1,0.8,fill_pattern=horizontal

Polyimg,65,5,115,5,115,55,65,55,65,5,color=0,fill_color=0.9,1,0.8,fill_pattern=vertical

Polyimg,125,5,175,5,175,55,125,55,125,5,color=0,fill_color=0.9,1,0.8,fill_pattern=cross

Polyimg,5,65,55,65,55,115,5,115,5,65,color=0,fill_color=0.9,1,0.8,fill_pattern=forward

Polyimg,65,65,115,65,115,115,65,115,65,65,color=0,fill_color=0.9,1,0.8,fill_pattern=backward

Polyimg,125,65,175,65,175,115,125,115,125,65,color=0,fill_color=0.9,1,0.8,fill_pattern=diagonalCross

Polyimg,5,125,55,125,55,175,5,175,5,125,color=0,fill_color=0.9,1,0.8,fill_pattern=horizontalCylinder

Polyimg,65,125,115,125,115,175,65,175,65,125,color=0,fill_color=0.9,1,0.8,fill_pattern=verticalCylinder

Polyimg,125,125,175,125,175,175,125,175,125,125,color=0,fill_color=0.9,1,0.8,fill_pattern=sphere

Embedimg

Compatibility

• 

The ImageTools[Draw][Poly] command was introduced in Maple 2018.

• 

For more information on Maple 2018 changes, see Updates in Maple 2018.

See Also

ImageTools

ImageTools:-Draw:-Circle

ImageTools:-Draw:-Line

ImageTools:-Draw:-SolidRectangle

ImageTools:-Draw:-Text

ImageTools:-Draw:-TextSize