GeneralPathTest.frink


// This class tests the GeneralPath class for drawing curves

g = new graphics

// Draw a letter "P" as in the Snellen eye chart.
p = new filledGeneralPath
p.moveTo[0,0]
p.lineTo[3.5,0]
//p.cubicCurve[4,0, 5,.5, 5,1.5]  // Bowl of the P, drawn in 2 sections
//p.cubicCurve[5,2.5, 4,3, 3,3]
p.circularArc[3.5, 1.5, -180 degrees]
p.lineTo[2,3]
p.lineTo[2,4]
p.lineTo[3,4]
p.lineTo[3,4]
p.lineTo[3,5]
p.lineTo[0,5]
p.lineTo[0,4]
p.lineTo[1,4]
p.lineTo[1,1]
p.lineTo[0,1]
p.close[]

// Jump to the inside of the bowl of the P and draw it.
p.moveTo[2,1]
p.lineTo[3.5,1]
//p.cubicCurve[3.5,1, 4,1, 4,1.5]
//p.cubicCurve[4,2, 3.5,2, 3,2]
p.circularArc[3.5, 1.5, -180 degrees]
p.lineTo[2,2]
p.close[]

g.add[p]

// Draw a letter "O"
p2 = new filledGeneralPath
p2.ellipseSides[6,0,11,5]
p2.ellipseSides[7,1,10,4]
g.add[p2]

// Draw a letter "D"
p3 = new filledGeneralPath
p3.moveTo[12, 0]
p3.lineTo[14.5, 0]
p3.circularArc[14.5, 2.5, -180 deg]
p3.lineTo[12, 5]
p3.lineTo[12, 4]
p3.lineTo[13, 4]
p3.lineTo[13, 1]
p3.lineTo[12, 1]
p3.close[]

// Jump to inside of "D"
p3.moveTo[14,1]
p3.lineTo[14.5, 1]
p3.circularArc[14.5, 2.5, -180 deg]
p3.lineTo[14, 4]
p3.close[]
g.add[p3]

g.show[]
g.write["path.svg", 500, 500]
g.write["path.jpg", 500, 500]
//g.print[]


View or download GeneralPathTest.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 14705 days, 19 hours, 51 minutes ago.