Download or view GeneralPathClipTest.frink in plain text format
// 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.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.
/* The version below works except for in the HTMLRenderer because of the
stupid non-zero winding rule. (Other renderers implement even-odd winding
rule.)
Have to kludge it to work around the lack of even-odd winding rule by
drawing in the opposite direction.
*/
/*p.moveTo[2,1]
p.lineTo[3.5,1]
p.circularArc[3.5, 1.5, -180 degrees]
p.lineTo[2,2]*/
// Alternate version that works with stupid non-zero winding rule
p.moveTo[2,2]
p.lineTo[3.5,2]
p.circularArc[3.5, 1.5, 180 degrees]
p.lineTo[2,1]
p.close[]
g.add[p]
// Draw a letter "O". Note that this works in the HTML5 renderer and its
// stupid non-zero winding rule because Frink has tried to kludge a workaround
// that alternates the drawing direction of ellipses so that you have a hope
// of rendering properly. I shall repeat again that HTML5 will be a stupid
// failure if it doesn't allow the even-odd winding rule for paths and
// self-intersecting polygons.
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.saveClip[]
g.clip[p3]
for y = 0 to 5 step 1/2
g.fillRectSides[0, y, 22, y+1/4]
g.restoreClip[]
p4 = new filledGeneralPath
p4.ellipseSides[18,0,21,5]
p4.ellipseSides[19,1,20,4]
//g.clip[p4]
g.add[p4]
g.show[]
g.write["path.svg", 500, 500]
g.write["path.jpg", 500, 500]
g.write["path.html", 500, 500]
browse["path.html"]
browse["path.svg"]
//g.print[]
Download or view GeneralPathClipTest.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 20217 days, 15 hours, 5 minutes ago.