eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Curve':

Home

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

Class: Curve


Inheritance:

   Object
   |
   +--Geometric
      |
      +--Curve

Package:
stx:libbasic2
Category:
Graphics-Geometry-Objects
Version:
rev: 1.8 date: 2009/06/06 10:12:21
user: cg
file: Curve.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


A Curve is a conic section determined by three points
that interpolates the first and the third and is tangent to the angle formed
by the three points at the first and third points.


Related information:

    Rectangle
    Polygon
    EllipticalArc
    Circle
    Spline
    Point
    LineSegment
    ArrowedSpline
    Arrow
    GraphicsContext
    StrokingWrapper
    FillingWrapper

Class protocol:

instance creation
o  from: startPoint to: endPoint through: middlePoint
return a new curve, passing through the three given points

o  start: startPoint middle: middlePoint end: endPoint
return a new curve, passing through the three given points

o  with: startPoint with: middlePoint with: endPoint
return a new curve, passing through the three given points


Instance protocol:

accessing
o  end
return the endPoint

o  start
return the startPoint

o  start: p1 middle: p2 end: p3
set the startPoint, middlePoint and the endPoint

converting
o  asPointArray
return an array containing my points.

o  asPolygon
return a polygon, approximating the spline

displaying
o  displayFilledOn: aGC
draw the receiver as a filled curve in a graphicsContext, aGC

o  displayStrokedOn: aGC
draw the receiver as a unfilled curve in a graphicsContext, aGC

helpers
o  computeLineSegments
compute the lines which approxiamte this curve

queries
o  bounds
return the smallest enclosing rectangle

usage example(s):

     (Curve from:10@10 to:50@100 through:50@50) bounds   
     (Curve from:10@10 to:50@100 through:100@50) bounds 

testing
o  canBeFilled
return true, if the receiver can be drawn as a filled geometric.
Always true here.


Examples:


filled & unfilled:
  |v c|

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

  c := Curve start:(20@20) middle:(80@80) end:(20@80).

  v paint:Color blue.
  c displayFilledOn:v.

  v paint:Color red.
  c displayStrokedOn:v.
with a grid (for demonstration):
  |v c|

  v := (View extent:200@100) openAndWait.

  v lineStyle:#dashed.
  v displayLineFrom:(20@0) to:(20@200).
  v displayLineFrom:(180@0) to:(180@200).

  v displayLineFrom:(0@20) to:(200@20).
  v displayLineFrom:(0@80) to:(200@80).

  v lineStyle:#solid.
  c := Curve start:(20@20) middle:(180@80) end:(20@80).

  v paint:Color blue.
  c displayFilledOn:v.

  v paint:Color red.
  c displayStrokedOn:v.

  v paint:(Color black).
  v displayLineFrom:(20@20) to:(180@80).
  v displayLineFrom:(20@80) to:(180@80).



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Tue, 23 Apr 2024 07:01:36 GMT