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.5 date: 2003/08/29 17:31:58
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  computeBounds
return the reactngle which encloses the curve.

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

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

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: translation
return a copy of the receiver, which is translated by some amount


Examples:


bezier:
  |v s|

  v := (View extent:110@110) openAndWait.

  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.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 25 Apr 2024 07:01:42 GMT