Demo entry 3511743

MadstopLine

   

Submitted by anonymous on Jan 07, 2016 at 10:28
Language: Smalltalk. Code size: 732 Bytes.

MSLine>>from: startPoint to: endPoint color: lineColor
	"Constructs the subdivided MadstopLine based upon the distance
		between startPoint and endPoint with a given lineColor"
		
	|vertexCollection distanceVector stepVector numberOfSegments|

	distanceVector := endPoint-startPoint.
	stepVector := distanceVector normalized*10.

	numberOfSegments := MadstopLine getNumberOfSegments: distanceVector divider: stepVector.

	vertexCollection := OrderedCollection new.
	vertexCollection add: startPoint.
	1 to: numberOfSegments do:[ :k | vertexCollection add: k*stepVector+startPoint].
	vertexCollection add: endPoint.

	^ MSLine vertices: vertexCollection asArray color: lineColor borderWidth: 5 borderColor: lineColor.

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).