|
Class: LineSegment
Object
|
+--Geometric
|
+--LineSegment
|
+--Arrow
|
+--Bezier2Segment
- Package:
- stx:libbasic2
- Category:
- Graphics-Geometry-Objects
- Version:
- rev:
1.31
date: 2023/08/10 13:11:36
- user: alkurz
- file: LineSegment.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
LineSegments represent a line consisting of start and endPoint
(actually, its a vector, since the direction makes a difference when
instances are compared using #=).
copyrightCOPYRIGHT (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.
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
-
endPoint: 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) **
-
startPoint: aPoint
-
set the startPoint
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
Usage example(s):
|v|
v := View new openAndWaitUntilVisible.
(LineSegment from:10@10 to:50@50) displayStrokedOn:v
|
printing
-
printOn: aStream
-
(comment from inherited method)
append a user printed representation of the receiver to aStream.
The format is suitable for a human - not meant to be read back.
The default here is to output the receiver's class name.
BUT: this method is heavily redefined for objects which
can print prettier.
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.
That is the length of a line perpendicular to the line segment,
which hits aPoint.
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
(LineSegment from:(0@0) to:(10@0)) dist:5@0
(LineSegment from:(0@0) to:(10@0)) dist:5@1
(LineSegment from:(0@0) to:(10@0)) dist:5@3
(LineSegment from:(0@0) to:(10@0)) dist:5@-3
(LineSegment from:(0@0) to:(0@10)) dist:5@5
(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
-
roundedToNearestIntegerPoint
-
return a copy of the receiver, where all points are rounded to ly on the nearest integer coordinate
-
scaledBy: amount
-
(comment from inherited method)
return a copy of the receiver, which is scaled by the argument, a point or number
-
transformedBy: transformation
-
return a copy of the receiver, which is transformed using aMatrix
-
translatedBy: amount
-
return a copy of the receiver which is translated (i.e. moved)
by amount, aPoint or Number
low leel use:
|v l|
v := (View extent:100@100) openAndWaitUntilVisible.
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.
|
|