eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Bezier':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Bezier


Inheritance:

   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)

Description:


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 protocol:

class initialization
o  initialize
initialize class constants

Usage example(s):

     Bezier initialize

instance creation
o  start: startPoint end: endPoint controlPoint1: controlPoint1 controlPoint2: controlPoint2
create & return a new bezier curve


Instance protocol:

accessing
o  controlPoint1
return the first controlPoint

o  controlPoint2
return the second controlPoint

o  end
return the endPoint

o  start
return the startPoint

comparing
o  = anObject
return true, if the receiver and the arg represent the same bezier curve

o  hash
return an integer useful as hashKey;
redefined, since = is redefined

converting
o  asLine
return a line from the startPoint to the endPoint

o  asPolyline
return a polygon which approximates the curve

displaying
o  displayFilledOn: aGraphicsContext
report an error: cannot be filled.

o  displayStrokedOn: aGraphicsContext
display the curve as an outline

private
o  addPointsFromStartX: p1X y: p1Y control1X: p2X y: p2Y control2X: p3X y: p3Y endX: p4X y: p4Y to: aCollection
actual workHorse for point computation

o  computePoints
compute the points along the bezier - return a collection of points

o  setStart: startPoint end: endPoint controlPoint1: cp1 controlPoint2: cp2

queries
o  computeBounds
return the reactngle which encloses the curve.

testing
o  outlineIntersects: aRectangle
return true, if the curve intersects a rectangle

transforming
o  scaledBy: scaleFactor
return a copy of the receiver, which is scaled by some amount

o  translatedBy: amount
return a copy of the receiver which is translated (i.e. moved)
by amount, aPoint or Number


Examples:


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.


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Thu, 21 Nov 2024 15:04:41 GMT