generalPathMatch.frink

Download or view generalPathMatch.frink in plain text format


g = new graphics

// Inlet
cy = -12 cm
cx = -2.5 cm
drawRoundedRectangle[g, cx, cy, 27.4 mm, 19.8 mm, 5.0 mm]
d = 3.4mm
drawCircleWithCross[g, cx+20 mm, cy, d]
drawCircleWithCross[g, cx-20 mm, cy, d]
g.text["Inlet", cx, cy]

g.write["match.svg", 8 in, 9 in]

drawCross[g is graphics, cx, cy] :=
{
   g.line[cx-2 mm, cy, cx+2mm, cy]
   g.line[cx, cy-2mm, cx, cy+2mm]
}

drawCircleWithCross[g is graphics, cx, cy, diameter] :=
{
   drawCross[g, cx, cy]
   g.drawEllipseCenter[cx, cy, diameter, diameter]
}

drawRoundedRectangle[g is graphics, cx, cy, width, height, r] :=
{
   hw = width/2
   hh = height/2
   cxr = cx+hw-r
   cxl = cx-hw+r
   cyb = cy+hh-r
   cyt = cy-hh+r
   left = cx - hw
   right = cx + hw
   top = cy - hh
   bottom = cy + hh

   // Draw curved area to cut out in gray
   g.color[0.7,0.7,0.7]
   gp = new filledGeneralPath
   gp.moveTo[cxl, top]
   gp.lineTo[cxr, top]
   gp.circularArc[cxr,cyt,-90 deg]
   gp.lineTo[right, cyb]
   gp.circularArc[cxr,cyb,-90 deg]
   gp.lineTo[cxl, bottom]
   gp.circularArc[cxl, cyb, -90 deg]
   gp.lineTo[left,cyt]
   gp.circularArc[cxl,cyt,-90 deg]
   gp.close[]
   g.add[gp]

   g.color[0,0,0]
   g.drawRectCenter[cx,cy,width,height]
   g.drawEllipseCenter[cxl,cyt,2r,2r]
   drawCross[g,cxl,cyt]
   g.drawEllipseCenter[cxr,cyt,2r,2r]
   drawCross[g,cxr,cyt]
   g.drawEllipseCenter[cxl,cyb,2r,2r]
   drawCross[g,cxl,cyb]
   g.drawEllipseCenter[cxr,cyb,2r,2r]
   drawCross[g,cxr,cyb]
}


Download or view generalPathMatch.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 20139 days, 6 hours, 51 minutes ago.