Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSBezierPathMBS class.

Previous items

NSBezierPathMBS.relativeCurveToPoint(endPoint as NSPointMBS, controlPoint1 as NSPointMBS, controlPoint2 as NSPointMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 12.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Adds a Bezier cubic curve to the receiver's path from the current point to a new location, which is specified as a relative distance from the current point.

endPoint: The destination point of the curve segment, interpreted as a relative offset from the current point.
controlPoint1: The point that determines the shape of the curve near the current point, interpreted as a relative offset from the current point.
controlPoint2: The point that determines the shape of the curve near the destination point, interpreted as a relative offset from the current point.

You must set the path's current point (using the moveToPoint method or through the creation of a preceding line or curve segment) before you invoke this method. If the path is empty, this method raises an NSGenericException exception.

NSBezierPathMBS.relativeLineToPoint(p as NSPointMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 12.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Appends a straight line segment to the receiver's path starting at the current point and moving towards the specified point, relative to the current location.

p: A point whose coordinates are interpreted as a relative offset from the current point.

The destination point is relative to the current point. For example, if the current point is (1, 1) and aPoint contains the value (1, 2), a line segment is created between the points (1, 1) and (2, 3).

You must set the path's current point (using the moveToPoint method or through the creation of a preceding line or curve segment) before you invoke this method. If the path is empty, this method raises an NSGenericException exception.

NSBezierPathMBS.relativeMoveToPoint(p as NSPointMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 12.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Moves the receiver's current point to a new point whose location is the specified distance from the current point.

p: A point whose coordinates are interpreted as a relative offset from the current point.

This method implicitly closes the current subpath (if any) and updates the location of the current point. For example, if the current point is (1, 1) and aPoint contains the value (1, 2), the previous subpath would be closed and the current point would become (2, 3). When closing the previous subpath, this method does not cause a line to be created from the first and last points in the subpath.

You must set the path's current point (using the moveToPoint method or through the creation of a preceding line or curve segment) before you invoke this method. If the path is empty, this method raises an NSGenericException exception.

NSBezierPathMBS.removeAllPoints

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 12.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Removes all path elements from the receiver, effectively clearing the path.
Example
dim b as NSBezierPathMBS = NSBezierPathMBS.bezierPath

b.moveToPoint NSMakePointMBS(10, 10)
b.lineToPoint NSMakePointMBS(290, 290)
MsgBox str(b.elementCount) // 2

b.removeAllPoints
MsgBox str(b.elementCount) // 0

NSBezierPathMBS.setAssociatedPoints(points() as NSPointMBS, index as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 12.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Changes the points associated with the specified path element.

points: An array containing up to three NSPointMBS data types. This parameter must contain the correct number of points for the path element at the specified index. Move, close path, and line segment commands require one point. Curve operations require three points.
index: The index of the path element you want to modify.

You can use this method to change the points associated with a path quickly and without recreating the path. You cannot use this method to change the type of the path element.

The following example shows you how you would modify the point associated with a line path element. The path created by this example results in a path with two elements. The first path element specifies a move to point (0, 0) while the second creates a line to point (100, 100). It then changes the line to go only to the point (50,50) using this method:

Note: If you specify too few points for a path element of type NSCurveToBezierPathElement, the behavior of this method is undefined.

NSBezierPathMBS.setLineDash(pattern() as Double, phase as Double)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 12.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Sets the line-stroking pattern for the receiver.
Example
dim n as new NSImageMBS(300, 300)
dim g as new NSGraphicsMBS(n)

g.setFillColor NSColorMBS.redColor

dim r as NSRectMBS = NSMakeRectMBS(50, 50, 100, 100)
dim b as NSBezierPathMBS = NSBezierPathMBS.bezierPath

b.moveToPoint NSMakePointMBS(10, 10)
b.lineToPoint NSMakePointMBS(290, 290)

dim pattern() as Double
pattern.Append 5
pattern.Append 2
b.setLineDash pattern, 6

g.stroke(b)

g = nil

window1.Backdrop = n.CopyPicture // red line with dash pattern

pattern: An array of floating point values that contains the lengths (measured in points) of the line segments and gaps in the pattern. The values in the array alternate, starting with the first line segment length, followed by the first gap length, followed by the second line segment length, and so on
count: The number of values in pattern.
phase: The offset at which to start drawing the pattern, measured in points along the dashed-line pattern. For example, a phase of 6 in the pattern 5-2-3-2 would cause drawing to begin in the middle of the first gap.

NSBezierPathMBS.transformUsingAffineTransform(transform as Variant)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 12.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Transforms all points in the receiver using the specified transform.
Example
dim bezierPath as NSBezierPathMBS = NSBezierPathMBS.bezierPath
dim transform as NSAffineTransformMBS = NSAffineTransformMBS.transform

bezierPath.moveToPoint NSMakePointMBS(0.0, 0.0)
bezierPath.lineToPoint NSMakePointMBS(100.0, 100.0)

transform.translate(10,10)
bezierPath.transformUsingAffineTransform(transform)

Break // bezierPath.bounds starts now at 10/10

Transform: The transform to apply to the path.

This method applies the transform to the path's points immediately. The following code translates a line from 0,0 to 100,100 to a line from 10,10 to 110,110.

transform must be a NSAffineTransformMBS object.

NSBezierPathMBS.windingRule as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Drawing MBS MacBase Plugin 12.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the winding rule used to fill the receiver's path.

Returns the winding rule for the path. This value may be either NSNonZeroWindingRule or NSEvenOddWindingRule.

This value overrides the default value returned by defaultWindingRule.
For more information on how winding rules affect the appearance of filled paths, see Constants.
(Read and Write computed property)

Previous items

The items on this page are in the following plugins: MBS MacBase Plugin.


💬 Ask a question or report a problem
The biggest plugin in space...