|
Class: Bezier
Object
|
+--Geometric
|
+--Bezier
- Package:
- stx:libbasic2
- Category:
- Graphics-Geometry-Objects
- Version:
- rev:
1.9
date: 2022/02/17 10:25:40
- user: cg
- file: Bezier.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
- Author:
- unknown (based upon the PD path package)
Beziers represent parametric cubic curvea.
[instance variables:]
start <Point> startPoint of the curve.
end <Point> endPoint of the curve.
controlPoint1 <Point> control point.
controlPoint2 <Point> control point.
[class variables:]
ScaledFlatness <Integer> curves flatness parameter
class initialization
-
initialize
-
initialize class constants
Usage example(s):
instance creation
-
start: startPoint end: endPoint controlPoint1: controlPoint1 controlPoint2: controlPoint2
-
create & return a new bezier curve
accessing
-
controlPoint1
-
return the first controlPoint
-
controlPoint2
-
return the second controlPoint
-
end
-
return the endPoint
-
start
-
return the startPoint
comparing
-
= anObject
-
return true, if the receiver and the arg represent the same bezier curve
-
hash
-
return an integer useful as hashKey;
redefined, since = is redefined
converting
-
asLine
-
return a line from the startPoint to the endPoint
-
asPolyline
-
return a polygon which approximates the curve
displaying
-
displayFilledOn: aGraphicsContext
-
report an error: cannot be filled.
-
displayStrokedOn: aGraphicsContext
-
display the curve as an outline
private
-
addPointsFromStartX: p1X y: p1Y control1X: p2X y: p2Y control2X: p3X y: p3Y endX: p4X y: p4Y to: aCollection
-
actual workHorse for point computation
-
computePoints
-
compute the points along the bezier - return a collection of points
-
setStart: startPoint end: endPoint controlPoint1: cp1 controlPoint2: cp2
-
queries
-
computeBounds
-
return the reactngle which encloses the curve.
testing
-
outlineIntersects: aRectangle
-
return true, if the curve intersects a rectangle
transforming
-
scaledBy: scaleFactor
-
return a copy of the receiver, which is scaled by some amount
-
translatedBy: amount
-
return a copy of the receiver which is translated (i.e. moved)
by amount, aPoint or Number
bezier:
|v s|
v := (View extent:110@110) openAndWaitUntilVisible.
s := Bezier
start:10@10
end:100@100
controlPoint1:50@50
controlPoint2:10@80.
v paint:Color red.
s displayStrokedOn:v.
v paint:Color black.
v displayPoint:10@10.
v displayPoint:100@100.
v displayPoint:50@50.
v displayPoint:10@80.
|
|