--- a/GraphicsContext.st Wed Apr 23 15:39:31 1997 +0200
+++ b/GraphicsContext.st Wed Apr 23 17:56:30 1997 +0200
@@ -1270,6 +1270,46 @@
self displayOpaqueString:aString from:1 to:(aString size) x:x y:y
!
+displayOpaqueString:aString x:x y:y angle:drawAngle
+ "draw a string along a (possibly non-horizontal) line,
+ drawing both fg and bg pixels.
+ The angle is in degrees, clock-wise, starting with 0 for
+ a horizontal draw.
+ Drawing is done by first drawing the string into a temporary bitmap,
+ which is rotated and finally drawn as usual.
+ NOTICE: due to the rotation of the temporary bitmap, this is a slow
+ operation - not to be used with cillions of strings ..."
+
+ self
+ displayString:aString x:x y:y angle:drawAngle opaque:true
+
+ "
+ |v|
+
+ v := View new.
+ v extent:300@200.
+ v openAndWait.
+ 0 to:360 by:45 do:[:a |
+ v paint:Color black on:Color red.
+ v displayOpaqueString:'hello world' x:100 y:100 angle:a.
+ ].
+ "
+
+ "in contrast to non-opaque draw:
+ |v|
+
+ v := View new.
+ v extent:300@200.
+ v openAndWait.
+ 0 to:360 by:45 do:[:a |
+ v paint:Color black on:Color red.
+ v displayString:'hello world' x:100 y:100 angle:a.
+ ].
+ "
+
+ "Modified: 23.4.1997 / 17:50:23 / cg"
+!
+
displayPoint:aPoint
"draw a pixel"
@@ -1329,7 +1369,72 @@
a horizontal draw.
Drawing is done by first drawing the string into a temporary bitmap,
which is rotated and finally drawn as usual.
- Not yet finished (only multiples of 90 degrees work)."
+ NOTICE: due to the rotation of the temporary bitmap, this is a slow
+ operation - not to be used with cillions of strings ..."
+
+ self
+ displayString:aString x:x y:y angle:drawAngle opaque:false
+
+ "
+ |v|
+
+ v := View new.
+ v extent:300@200.
+ v openAndWait.
+ 0 to:360 by:90 do:[:a |
+ v paint:Color black.
+ v displayString:'hello world' x:100 y:100 angle:a.
+ ].
+ "
+ "
+ |v|
+
+ v := View new.
+ v extent:400@400.
+ v openAndWait.
+ 0 to:360 by:5 do:[:a |
+ v paint:Color black.
+ v displayString:'......... hello' x:200 y:200 angle:a.
+ ].
+ "
+ "
+ |v|
+
+ v := View new.
+ v extent:200@100.
+ v openAndWait.
+ v displayString:'ghello' x:50 y:50 angle:0.
+ v displayString:'ghello' x:50 y:50 angle:45.
+ v displayString:'ghello' x:50 y:50 angle:90.
+ v displayString:'ghello' x:50 y:50 angle:180.
+ v displayString:'ghello' x:50 y:50 angle:270.
+ "
+ "
+ |v|
+
+ v := View new.
+ v extent:200@100.
+ v openAndWait.
+ v displayString:'hello' x:50 y:50 angle:0.
+ v displayString:'hello' x:50 y:50 angle:45.
+ v displayString:'hello' x:50 y:50 angle:90.
+ v displayString:'hello' x:50 y:50 angle:135.
+ v displayString:'hello' x:50 y:50 angle:180.
+ v displayString:'hello' x:50 y:50 angle:225.
+ v displayString:'hello' x:50 y:50 angle:270.
+ "
+
+ "Modified: 23.4.1997 / 17:48:57 / cg"
+!
+
+displayString:aString x:x y:y angle:drawAngle opaque:opaque
+ "common code to draw a string along a (possibly non-horizontal) line.
+ The angle is in degrees, clock-wise, starting with 0 for
+ a horizontal draw.
+ Drawing is done by first drawing the string into a temporary bitmap,
+ which is rotated and finally drawn as usual.
+ NOTICE: due to the rotation of the temporary bitmap, this is a slow
+ operation - not to be used with cillions of strings ..."
|angle tempForm tempImage w h asc desc a xN yN p r nBL nTL nB a1 a2
dX dY sin cos|
@@ -1345,6 +1450,9 @@
].
angle = 0 ifTrue:[
+ opaque ifTrue:[
+ ^ self displayOpaqueString:aString x:x y:y
+ ].
^ self displayString:aString x:x y:y
].
@@ -1382,11 +1490,13 @@
"/ the computation is somewhat more difficult here.
"/ remember: the image has been rotated around its center,
"/ then shifted towards the top-left origin.
+
p := (w@h) / 2.
r := p r.
a := p angle.
sin := angle degreesToRadians sin.
cos := angle degreesToRadians cos.
+
angle < 90 ifTrue:[
dX := desc * sin.
dY := asc * cos.
@@ -1398,15 +1508,17 @@
dY := desc * cos.
xN := x + dX - (tempImage width).
yN := y + dY.
-'..180 ' print. dX print. ' 'print. dY printCR.
] ifFalse:[
angle < 270 ifTrue:[
- dX := asc * sin.
- dY := desc * cos.
-'..270 ' print. dX print. ' 'print. dY printCR.
+ dX := desc * sin.
+ dY := asc * cos.
xN := x - dX - (tempImage width).
yN := y - dY - (tempImage height)
] ifFalse:[
+ dX := asc * sin.
+ dY := desc * cos.
+ xN := x + dX.
+ yN := y + dY - (tempImage height).
]
]
].
@@ -1415,58 +1527,14 @@
]
].
].
- self displayForm:tempImage x:xN y:yN.
-
- "
- |v|
-
- v := View new.
- v extent:300@200.
- v openAndWait.
- 0 to:360 by:90 do:[:a |
- v paint:Color black.
- v displayString:'hello world' x:100 y:100 angle:a.
- ].
- "
- "
- |v|
+ opaque ifTrue:[
+ self displayOpaqueForm:tempImage x:xN y:yN.
+ ] ifFalse:[
+ self displayForm:tempImage x:xN y:yN.
+ ]
- v := View new.
- v extent:300@200.
- v openAndWait.
- 0 to:265 by:5 do:[:a |
- v paint:Color black.
- v displayString:'.........' x:100 y:100 angle:a.
- ].
- "
- "
- |v|
-
- v := View new.
- v extent:200@100.
- v openAndWait.
- v displayString:'ghello' x:50 y:50 angle:0.
- v displayString:'ghello' x:50 y:50 angle:45.
- v displayString:'ghello' x:50 y:50 angle:90.
- v displayString:'ghello' x:50 y:50 angle:180.
- v displayString:'ghello' x:50 y:50 angle:270.
- "
- "
- |v|
-
- v := View new.
- v extent:200@100.
- v openAndWait.
- v displayString:'hello' x:50 y:50 angle:0.
- v displayString:'hello' x:50 y:50 angle:45.
- v displayString:'hello' x:50 y:50 angle:90.
- v displayString:'hello' x:50 y:50 angle:135.
- v displayString:'hello' x:50 y:50 angle:180.
- v displayString:'hello' x:50 y:50 angle:225.
- v displayString:'hello' x:50 y:50 angle:270.
- "
-
- "Modified: 23.4.1997 / 11:21:16 / cg"
+ "Created: 23.4.1997 / 17:47:41 / cg"
+ "Modified: 23.4.1997 / 17:56:10 / cg"
!
fillArcX:x y:y w:w h:h from:startAngle angle:angle
@@ -1773,6 +1841,6 @@
!GraphicsContext class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.56 1997-04-23 09:21:26 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.57 1997-04-23 15:56:30 cg Exp $'
! !
GraphicsContext initialize!