Download or view GeneralPathExamples.frink in plain text format
// Demonstrates and tests drawing curves.
// This renders the images used in the documentation of GeneralPath.
drawCubicWithEndpoints[p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y] :=
{
g1 = new graphics
// Draw endpoints
g1.color[0,0,1]
g1.fillRectCenter[p1x,p1y, .2,.2]
g1.fillRectCenter[p2x,p2y, .2,.2]
// Draw control points
g1.color[.5,.5,.5]
g1.fillRectCenter[c1x,c1y,.2,.2]
g1.fillRectCenter[c2x,c2y,.2,.2]
// Draw control lines
g1.color[.7,.7,.7]
g1.line[p1x,p1y,c1x,c1y]
g1.line[p2x,p2y,c2x,c2y]
// Draw the cubic curve
g1.color[0,0,0]
gp = new GeneralPath
gp.moveTo[p1x,p1y]
gp.cubicCurve[c1x,c1y, c2x,c2y, p2x,p2y]
g1.add[gp]
// g1.font["SansSerif", "plain", 1]
// g1.text["Cubic B\u00e9zier curve", 5, -6]
g1.show[]
g1.write["cubic.svg",500,400]
g1.write["cubic.png",300,200]
g1.write["cubic.jpg",500,400]
g1.write["cubic.html",500,400]
// g1.print[]
}
// Quadratic curve example
drawQuadraticWithEndpoints[p1x, p1y, c1x, c1y, p2x, p2y] :=
{
g1 = new graphics
// Draw endpoints
g1.color[0,0,1]
g1.fillRectCenter[p1x,p1y, .2,.2]
g1.fillRectCenter[p2x,p2y, .2,.2]
// Draw control points
g1.color[.5,.5,.5]
g1.fillRectCenter[c1x,c1y,.2,.2]
// Draw control lines
g1.color[.7,.7,.7]
g1.line[p1x,p1y,c1x,c1y]
g1.line[p2x,p2y,c1x,c1y]
// Draw the cubic curve
g1.color[0,0,0]
gp = new GeneralPath
gp.moveTo[p1x,p1y]
gp.quadratic[c1x,c1y, p2x,p2y]
g1.add[gp]
// g1.font["SansSerif", "plain", 1]
// g1.text["Cubic B\u00e9zier curve", 5, -6]
g1.show[]
g1.write["quadratic.svg",500,400]
g1.write["quadratic.png",300,150]
g1.write["quadratic.jpg",500,400]
g1.write["quadratic.html",500,400]
// g1.print[]
}
drawCubicWithEndpoints[0,0, 3,3, 6,-5, 10,1]
drawQuadraticWithEndpoints[0,0, 2,4, 10,1]
Download or view GeneralPathExamples.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 20143 days, 11 hours, 28 minutes ago.