[updates] 14 for 2.9alpha
Adam Bloom
admanb at hotmail.com
Wed Oct 4 17:41:21 UTC 2000
>From: Dan Ingalls <Dan.Ingalls at disney.com>
>Reply-To: squeak at cs.uiuc.edu
>To: "Leandro Caniglia" <caniglia at dm.uba.ar>
>CC: squeak at cs.uiuc.edu
>Subject: Re: [updates] 14 for 2.9alpha
>Date: Tue, 3 Oct 2000 21:36:52 -0700
I'm new to Squeak so this may sound like a stupid question, what does this
program do?
Adam
>
>Remember, you asked for it...
>
>There's really not much to Part I.
>
>Simply define...
>!PolygonMorph methodsFor: 'drawing' stamp: 'di 10/3/2000 09:50'!
>drawArrowOn: aCanvas at: endPoint from: priorPoint
> "Draw a triangle oriented along the line from priorPoint to endPoint."
> | pts |
> pts _ self arrowBoundsAt: endPoint from: priorPoint.
> (self valueOfProperty: #arrowSpec ifAbsent: [5 at 4]) y >= 0
> ifTrue: [aCanvas drawPolygon: pts fillStyle: borderColor]
> ifFalse: [aCanvas drawPolygon: pts fillStyle: Color transparent
> borderWidth: borderWidth+1//2 borderColor: borderColor]! !
>
>This actually gives you transparent arrowheads, because...
>
>When you invoke 'customize arrows', it will record an arrowSpec that has x
>and y values that only make sense in a positive dierection. The negative x
>is already used to say that you want concave bases on your arrows. The
>above solitary change says that if you go negative in y, then it means the
>same about width (which already takes the abs), but that the center should
>be transparent. Voila!
>
>There is a method,
> computeArrowFormAt: endPoint from: priorPoint
>which I thought I would have to change as well, but in fact it is not used
>for drawing, but mainly for bounds and hit testing (conatinsPoint:), in
>which it is fine for it to continue to think that the arrows are opaque.
>
>Now, here is what remains to be done to do the job right (Part II) in my
>opinion...
>If you look at the results with the above change, you will see two main
>problems:
>
> 1. The arrow points look yukky because they are made with wide lines, and
>
> 2. The shaft of the line intrudes into the transparent heart of the
>arrow.
>
>(2) is relatively simple to address. You will find (copied in two places
>-- boo!) code which shortens the last line segment so that it does not
>interfere with the arrow tips at present.
>
>The methods are drawBorderOn: and drawDashedBorderOn:, in each of which you
>will see I have inserted the following ugly logic:
>
> arrows == #none ifFalse:
> ["Shorten line ends so as not to interfere with tip of arrow."
> ((arrows == #back or: [arrows == #both]) and: [p1 = vertices first])
> ifTrue: [v _ p1 - p2.
> d _ Point r: v r - (self borderWidth*3) degrees: v degrees.
> p1i _ (p2 + d) asIntegerPoint].
> ((arrows == #forward or: [arrows == #both]) and: [p2 = vertices last])
> ifTrue: [v _ p2 - p1.
> d _ Point r: v r - (self borderWidth*3) degrees: v degrees.
> p2i _ (p1 + d) asIntegerPoint]].
>
>Your first assignment is to factor these two methods, or at least the above
>code, so that it isn't quadruplicated (it's on my to do list, but you don't
>want to go there...).
>
>Having done that, you need to look in the code for arrowBoundsAt: endPoint
>from: priorPoint, in which it will be revealed exactly where the "base" of
>the arrow is (namely "wingBase"). So the above code needs to be refined so
>that the length of the line ends will be shortened, not just to r - (self
>borderWidth*3), but to end at the windBase. Of course you will have to
>max: with 0, since, on a curve, the last segment may be quite short, so
>lots of this logic may fail. If you make it work for a sharply curved line
>(which will involve interfering with more than the last segment), you get a
>silver star.
>
>OK, so much for the shaft intruding into the heart of the arrow.
> Now how about that ugly shape made with a thick border?
>Here's what I would do...
>
>I would add a special method to the protocol of canvas for arrowheads with
>some sort of flag for transparent centers. In fact you should be able to
>use existing methods to accomplish it, but what has to happen is that you
>need to supply not only the points on the outside of the arrow (already
>available from arrowBoundsAt: endPoint from: priorPoint), but also the
>points on the inside of the arrow (you could probably just scale them all
>about a center), and cause the resulting border to be painted as a shape.
>This will give you sharp exterior points as well as sharp interior points.
>When you're done, you can crow to the Squeak list, and Ned can tackle his
>UML editor. [You don't get to really crow until you verify that it does
>the right thing in Postscript as well as on the screen.]
>
>Have fun!
> - Dan
>
>
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
More information about the Squeak-dev
mailing list
|