|
Class: LineSegment
Object
|
+--Geometric
|
+--LineSegment
|
+--Arrow
|
+--Bezier2Segment
- Package:
- stx:libbasic2
- Category:
- Graphics-Geometry-Objects
- Version:
- rev:
1.21
date: 2009/06/06 10:07:44
- user: cg
- file: LineSegment.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
- Author:
- Claus Gittinger
LineSegments represent a line consisting of start and endPoint
(actually, its a vector, since the direction makes a difference when
instances are compared using #=).
Rectangle
Polygon
EllipticalArc
Circle
Spline
Curve
Point
Arrow
ArrowedSpline
GraphicsContext
StrokingWrapper
instance creation
-
from: start to: end
-
return a new lineSegment.
-
with: p1 with: p2
-
return a new lineSegment; the smaller point is taken as startPoint.
accessing
-
end
-
return the endPoint
-
end: aPoint
-
set the endPoint
-
setStart: p1 end: p2
-
set both the startPoint and the endPoint
-
start
-
return the startPoint
-
start: aPoint
-
set the startPoint
-
start: p1 end: p2
-
set both the startPoint and the endPoint.
Obsolete - use setStart:end: for VW compatibility.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
comparing
-
= aLineSegment
-
return true, if the receiver represents the same lineSegment
as the argument, aLineSegment
-
hash
-
return a number useul for hashing.
Redefined, since #= is redefined.
converting
-
asPointArray
-
return an array containing my points.
displaying
-
displayFilledOn: aGC
-
raise an error - a lineSegment cannot be drawn filled
-
displayStrokedOn: aGC
-
display the receiver in the graphicsContext, aGC
printing
-
printOn: aStream
-
queries
-
angle
-
return the receiver's angle (in degrees) in a polar coordinate system.
The angle is counted counter-clock-wise, starting with 0 for a horizontal
line (i.e. 0@0 -> 100@0 has an angle of 0 and 0@0 -> 0@100 has an angle of 90)
usage example(s):
(LineSegment from:0@0 to:100@0) angle
(LineSegment from:0@0 to:100@100) angle
(LineSegment from:0@0 to:0@100) angle
(LineSegment from:0@0 to:-100@100) angle
(LineSegment from:0@0 to:-100@0) angle
(LineSegment from:0@0 to:-100@-100) angle
(LineSegment from:0@0 to:0@-100) angle
|
-
center
-
(LineSegment from:(10@10) to:(20@10)) center
(LineSegment from:(10@10) to:(20@20)) center
-
computeBounds
-
return the smallest enclosing rectangle
-
dist: aPoint
-
the distance of aPoint to this segment
usage example(s):
usage example(s):
usage example(s):
(LineSegment from:(0@0) to:(10@10)) dist:0@0
(LineSegment from:(0@0) to:(10@10)) dist:10@10
(LineSegment from:(0@0) to:(10@10)) dist:11@10
(LineSegment from:(0@0) to:(10@10)) dist:-1@-1
(LineSegment from:(0@0) to:(10@10)) dist:5@5
(LineSegment from:(0@0) to:(10@10)) dist:6@4
(LineSegment from:(0@0) to:(10@10)) dist:5@0
|
-
isHorizontal
-
return true, if I am a horizontal line
-
isVertical
-
return true, if I am a vertical line
-
length
-
return the length of the vector
testing
-
isLineSegment
-
return true, if the receiver is a line segment
transforming
-
scaledBy: amount
-
-
translatedBy: amount
-
low leel use:
|v l|
v := (View extent:100@100) openAndWait.
l := LineSegment from:10@10 to:90@90.
v paint:Color red.
l displayStrokedOn:v.
l setStart:90@10 end:10@90.
v paint:Color blue.
l displayStrokedOn:v.
| as component (automatic redraw):
|v l|
v := View extent:100@100.
l := LineSegment from:10@10 to:90@90.
v addComponent:(StrokingWrapper on:l).
l := LineSegment from:90@10 to:10@90.
v addComponent:((StrokingWrapper on:l) foregroundColor:(Color red)).
v open.
|
|