In Files

Parent

GraphicsPath

A GraphicsPath object stores a series of lines or curves which define either a line that can be drawn with a Pen, or the outline of a closed shape that can be drawn with any drawing instrument (see the View class for more information about drawing instruments).

When adding new lines or curves to a GraphicsPath, they will be joined with a straight line to any further lines and curves that are added. This continues until the closeFigure method is called. This turns all of the preceding lines and curves into a closed shape - allowing shapes of arbitrary complexity to be created from small sections.

Following a closeFigure call, is is possible to continue adding more lines, curves or closed shapes, so that a GraphicsPath can consist of a compound of multiple shapes.

This allows vector graphics of almost unlimited complexity to be stored as a single object that can be drawn to a View with a simple call to the View's drawPath method.

However, note that shapes are always defined using absolute co-ordinates from the target View's co-ordinate space. They are not like 'sprites' that can easily be moved, scaled or rotated to alter their position.

GraphicsPaths also cannot be "Marshalled" - so cannot be stored within a RubyEdit primitive between sessions. This means that it is not advisable to send them between RubyEdits using Ruby Value connectors, as it could throw an error when the project is loaded, and Ruby attempts to recover the previous connector values.

As well as being drawn to the screen, GraphicsPaths can also be used to define clipping areas for a View, to define CustomLineCap objects, or to define the path for a PathGradientBrush.

Public Class Methods

new → GraphicsPath click to toggle source

Creates a new, empty, GraphicsPath object. Note that no arguments may be passed, the new path is always empty and must be filled with shapes using the instance methods outlined below.

# File GUI_Classes.rb, line 1133
def self.new
  #DUMMY
end

Public Instance Methods

addArc(area, start_angle, sweep_angle) click to toggle source

Adds a chord of an ellipse or circle to the path. (i.e. a small section of an ellipse or circle's outline). If the method call was preceded by adding other lines or curves, a line is also added from the previous end point to the start of the new arc.

The area argument specifies the position and size of the whole ellipse before it is 'sliced' into a segment. This should be an Array containing four float values...

[x-position, y-position, width, height]

The section of the ellipse to draw is given by the remaining two arguments...

  • start_angle Measured in degrees, clock-wise from the x-axis.

  • sweep-angle Measured in degrees, clock-wise from the start angle.

The end point will be remembered and will be joined to the next addition to the path, unless the closeFigure method is called to begin adding a new shape.

# File GUI_Classes.rb, line 1345
def addArc
  #DUMMY
end
addBeziers(points) click to toggle source

Adds a series of Bezier curves that pass through a series of points, and also have 'control points' that describe the amount of curvature. If the method call was preceded by adding other lines or curves, a line is also added from the previous end point to the start of the new beziers.

The series of points is given as a Array. Each Array item should be a two-element array giving the [x, y] position of a point...

  • The first point is the start point of the curve.

  • From then on, every third point is a point through which the curve passes.

  • Each 'pass-through' point is separated by two 'control points'

The end point will be remembered and will be joined to the next addition to the path, unless the closeFigure method is called to begin adding a new shape.

Bezier curves are too complex to describe in full here, please refer to the user guide (p.155) and the many on-line resources that are available.

# File GUI_Classes.rb, line 1396
def addBeziers
  #DUMMY
end
addClosedCurve(points) click to toggle source
addClosedCurve(points, tension)

Adds a closed curved shape that passes through a series of points representing its outline.

The series of points is given as a Array. Each Array item should be a two-element array giving the [x, y] position of a point through which the shape's outline will pass.

[ [x1, y1], [x2, y2], [x3, y3], ... ]

If the Float tension is given, it determines how smoothly the curve bends around the given points. A value of zero will simply draw straight lines between the points. Higher values will give a more rounded shape. If not given, the default setting of 0.5 is used, which generally gives a nice smooth shape without extending too far away from the screen area that the points define.

# File GUI_Classes.rb, line 1306
def addClosedCurve
  #DUMMY
end
addCurve(points) click to toggle source
addCurve(points, tension)

Adds a curve which passes through a series of points. If the method call was preceded by adding other lines or curves, a line is also added from the previous end point to the start of the new curve.

The series of points is given as a Array. Each Array item should be a two-element array giving the [x, y] position of a point through which the curve will pass.

[ [x1, y1], [x2, y2], [x3, y3], ... ]

The last point will be remembered and will be joined to the next addition to the path, unless the closeFigure method is called to begin adding a new shape.

If the Float tension is given, it determines how smoothly the curve bends around the given points. A value of zero will simply draw straight lines between the points. Higher values will give a more rounded shape. If not given, the default setting of 0.5 is used, which generally gives a nice smooth shape without extending too far away from the screen area that the points define.

# File GUI_Classes.rb, line 1372
def addCurve
  #DUMMY
end
addEllipse(area) click to toggle source

Adds a closed ellipse or circle to the path. The size of the ellipse is given as an Array, which should have four Float values, measured in grid units...

[x_position, y_position, width, height]

This defines a rectangular 'box' into which the ellipse will be fitted, with its major and minor axes aligned with the drawing axes.

# File GUI_Classes.rb, line 1252
def addEllipse
  #DUMMY
end
addLine(start_point, end_point) click to toggle source

Adds a straight line between two points. If the method call was preceded by adding other lines or curves, a line is also added from the previous end point to the start of the new line.

Each point is given as a two element Array...

[x-position, y-position]
# File GUI_Classes.rb, line 1320
def addLine
  #DUMMY
end
addLines(points) click to toggle source

Adds a series of lines that join a sequence of points on the view - rather like a 'dot-to-dot' picture book. If the method call was preceded by adding other lines or curves, a line is also added from the previous end point to the start of the new line.

The series of points is given as a Array. Each Array item should be a two-element array giving the [x, y] position of a point to be joined by straight lines.

[ [x1, y1], [x2, y2], [x3, y3], ... ]

The end point will be remembered and will be joined to the next addition to the path, unless the closeFigure method is called to begin adding a new shape.

# File GUI_Classes.rb, line 1416
def addLines
  #DUMMY
end
addPath(GraphicsPath, connect) click to toggle source

Incorporates the given GraphicsPath into this one. The connect argument determines whether the given path should be joined with the current data (i.e. joining lines and curves end to end), or should be added as a separate shape. Pass 'true' to join the shapes, or 'false' to keep them separate.

# File GUI_Classes.rb, line 1228
def addPath
  #DUMMY
end
addPie(area, start_angle, sweep_angle) click to toggle source

Adds a segment of an ellipse or circle to the path. The area argument specifies the position and size of the whole ellipse before it is 'sliced' into a segment. This should be an Array containing four float values...

[x-position, y-position, width, height]

The section of the ellipse to add is given by the remaining two arguments...

  • start_angle Measured in degrees, clock-wise from the x-axis.

  • sweep-angle Measured in degrees, clock-wise from the start angle.

# File GUI_Classes.rb, line 1269
def addPie
  #DUMMY
end
addPolygon(points) click to toggle source

Adds a closed polygon from a series of points representing its outline. Points are always joined by straight sides.

The series of points is given as a Array. Each Array item should be a two-element array giving the [x, y] position of a corner of the polygon...

[ [x1, y1], [x2, y2], [x3, y3], ... ]
# File GUI_Classes.rb, line 1283
def addPolygon
  #DUMMY
end
addRectangle(area) click to toggle source

Adds a closed rectangle to the path. The rectangle to add is given as an Array, which should have four Float values, measured in grid units...

[x_position, y_position, width, height]
# File GUI_Classes.rb, line 1239
def addRectangle
  #DUMMY
end
closeFigure() click to toggle source

call-seq

closeFigure

If you have already drawn some lines or curves to a GraphicsPath object, calling closeFigure will join the start and end points to turn the path into a closed shape that can be filled by a Brush.

Note that they will always be joined with a straight line, so if you need a shape with a continuous flowing outline you should either use the addClosedCurve method, or ensure that the start point and end point are in the same place (they would not be joined automatically in this case).

If other elements are added to the path following a closeFigure call, a new, independent shape is added to the path.

# File GUI_Classes.rb, line 1152
def closeFigure
  #DUMMY
end
getBounds → Array click to toggle source

Return an Array containing four Floats...

[x-position, y-position, width, height]

These values define the smallest rectangular area, measured in 'grid' units, into which the GraphicsPath will fit.

# File GUI_Classes.rb, line 1215
def getBounds
  #DUMMY
end
getPathData → Array click to toggle source

Retrieves all of the current line and curve data from the GraphicsPath object. Internally, this data is all stored as bezier curves, as they are able to describe any of the other types of shape and line. Closed sections of a shape occur when an end point and start point share the same co-ordinates. This may allow the data in a GraphicsPath to be stored in Array form, and then restored by passing the Array to the addBeziers method of a new GraphicsPath object.

# File GUI_Classes.rb, line 1433
def getPathData
  #DUMMY
end
isOutlineVisible(point, Pen) → true/false click to toggle source
isOutlineVisible(point, Pen, View) → true/false

Tests whether the outline of the GraphicsPath, when drawn with the given pen, would include the given point. The point is given as a two element Array...

[x_position, y_position]

If a View is also given, this will be used to adjust the test to account for the current zoom and grid size.

Returns true if the point is within the outline, otherwise false.

# File GUI_Classes.rb, line 1203
def isOutlineVisible
  #DUMMY
end
isVisible(point) → true/false click to toggle source
isVisible(point, View) → true/false

Tests whether the given point is within the screen area covered by the GraphicsPath. The point is given as a two element Array...

[x_position, y_position]

If a View is also given, this will be used to adjust the test to account for the current zoom and grid size.

Returns true if the point is within the shape, otherwise false.

# File GUI_Classes.rb, line 1187
def isVisible
  #DUMMY
end
widen(Pen) click to toggle source
widen(Pen, View)

If the GraphicsPath contains one or more closed shapes, calling this method will expand the size of the path. The amount to expand by is determined by the width of the given Pen object.

If a View is also given, this will be used to adjust the expansion to take account of the current zoom and grid size settings for the view.

This can be useful if you intend to use the isVisible method to test the mouse position, ensuring that both the GraphicPath's fill and outline are taken into account.

# File GUI_Classes.rb, line 1171
def widen
  #DUMMY
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.