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.12 date: 2022/02/17 10:25:29
user: cg
file: Curve.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

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.

copyright

COPYRIGHT (c) 1996 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

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  computeBounds
return the smallest enclosing rectangle

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:200@200) openAndWaitUntilVisible.
  v transformation:(WindowingTransformation 
                      scale:1 
                      translation:(100@100)).
   
  v paint:Color black.
  v displayLineFrom:(-90@0) to:(90@0).
  v displayLineFrom:(0@-90) to:(0@90).

  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.
  |v c|

  v := (View extent:200@200) openAndWaitUntilVisible.
  v transformation:(WindowingTransformation 
                      scale:1 
                      translation:(100@100)).

  v paint:Color black.
  v displayLineFrom:(-90@0) to:(90@0).
  v displayLineFrom:(0@-90) to:(0@90).

  c := Curve start:(0@20) middle:(40@60) end:(0@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) openAndWaitUntilVisible.

  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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 16:49:25 GMT