adding shapes to connectors

Ned Konz ned at bike-nomad.com
Wed Apr 17 20:24:08 UTC 2002


John Hinsley asked about adding arbitrary shapes:

>The important code (essentially I need to flip the open arrow head)
seem to be:

> ^(PolygonMorph vertices: { 0 at 0 . 6 at 15 . 12 at 0  }

> I'd welcome an explanation of what these actually refer to (trying 
to finesse
it isn't working out!).

You could do this:

crowsFootShape
	"NCLineEndConstraintMorph crowsFootShape openInHand"

	^(PolygonMorph vertices: { 0 at 15 . 7 at 0. 13 at 15  }
		color: Color black
		borderWidth: 2
		borderColor: Color black)
			makeOpen;
			rotationCenter: ((9/17)@0.9) asFloatPoint;
			vResizing: #rigid;
			hResizing: #rigid;
			name: 'open arrowhead'

> I've always had problems trying to draw shapes programmatically!

Well, first, you don't have to add them programmatically. Just get an 
image of one any way you want (perhaps just make a sketch of it). 
Make sure that its line weight is the same as the lines you're using.

Then grab the rotate halo on the sketch and move it a little bit but 
don't actually rotate it. The halo should turn light blue. You'll see 
a yellow bulls-eye and a green arrow. Holding down the shift key, 
drag the yellow bulls-eye so it's at the place where you want the 
connector to attach to the shape (at the end of the middle line?). 
Then drag the green arrow so it points in the direction that the 
attached line will go (away from the attachment point).

Then right-button the end of a connector, and say "add arbitrary 
shape" and select your sketch.

Of course, this won't look too good unless it's connected 
perpindicularly. So you may want to change the attachment mode of the 
end to "connect to nearest point"

Or in this case you can just rotate a regular arrowhead. Just make 
sure that you're rotating the actual arrowhead, not the constraint or 
the connector. Play with the rotation center and direction till you 
see what's going on.

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE




More information about the Squeak-dev mailing list