Exemplo n.º 1
0
    def _curveToOne(self, pt1, pt2, pt3):
        x0, y0 = self._getCurrentPoint()

        db.fill(None)
        db.stroke(r.random(), r.random(), r.random(), 1)
        db.strokeWidth(self.width)

        # db.newPath()
        db.moveTo((x0, y0))
        db.curveTo(pt1, pt2, pt3)
        db.drawPath()

        self.pointsList.append(pt3)
Exemplo n.º 2
0
def drawArrow(e, view, xs, ys, xt, yt, onText=1, startMarker=False, endMarker=False):
    u"""Draw curved arrow marker between the two points.
    TODO: Add drawing of real arrow-heads, rotated in the right direction."""
    fms = e.css('flowMarkerSize')
    fmf = e.css('flowCurvatureFactor')
    if onText == 1:
        c = e.css('flowConnectionStroke2', NO_COLOR)
    else:
        c = e.css('flowConnectionStroke1', NO_COLOR)
    setStrokeColor(c, e.css('flowConnectionStrokeWidth'))
    if startMarker:
        setFillColor(e.css('flowMarkerFill', NO_COLOR))
        oval(xs - fms, ys - fms, 2 * fms, 2 * fms)
    xm = (xt + xs)/2
    ym = (yt + ys)/2
    xb1 = xm + onText * (yt - ys) * fmf
    yb1 = ym - onText * (xt - xs) * fmf
    xb2 = xm - onText * (yt - ys) * fmf
    yb2 = ym + onText * (xt - xs) * fmf
    # Arrow head position
    arrowSize = 12
    arrowAngle = 0.4
    angle = atan2(xt-xb2, yt-yb2)
    hookedAngle = radians(degrees(angle)-90)
    ax1 = xt - cos(hookedAngle+arrowAngle) * arrowSize
    ay1 = yt + sin(hookedAngle+arrowAngle) * arrowSize
    ax2 = xt - cos(hookedAngle-arrowAngle) * arrowSize
    ay2 = yt + sin(hookedAngle-arrowAngle) * arrowSize
    newPath()
    setFillColor(None)
    moveTo((xs, ys))
    curveTo((xb1, yb1), (xb2, yb2), ((ax1+ax2)/2, (ay1+ay2)/2)) # End in middle of arrow head.
    drawPath()

    #  Draw the arrow head.
    newPath()
    setFillColor(c)
    setStrokeColor(None)
    moveTo((xt, yt))
    lineTo((ax1, ay1))
    lineTo((ax2, ay2))
    closePath()
    drawPath()
    if endMarker:
        oval(xt - fms, yt - fms, 2 * fms, 2 * fms)
Exemplo n.º 3
0
import drawBot
drawBot.size(200, 200)

drawBot.newPath()
drawBot.moveTo((20, 20))
drawBot.lineTo((20, 100))
drawBot.lineTo((100, 100))
drawBot.lineTo((100, 180))
drawBot.curveTo((150, 180), (180, 150), (180, 100))
drawBot.lineTo((180, 20))
drawBot.closePath()

drawBot.moveTo((40, 40))
drawBot.lineTo((160, 40))
drawBot.curveTo((160, 65), (145, 80), (120, 80))
drawBot.lineTo((40, 80))
drawBot.closePath()

drawBot.fill(0.5, 0, 0)
drawBot.stroke(None)
drawBot.strokeWidth(10)
drawBot.drawPath()
Exemplo n.º 4
0
import drawBot
drawBot.size(200, 200)

drawBot.newPath()
drawBot.moveTo((20, 20))
drawBot.lineTo((20, 100))
drawBot.lineTo((100, 100))
drawBot.lineTo((100, 180))
drawBot.curveTo((150, 180), (180, 150), (180, 100))
drawBot.lineTo((180, 20))

drawBot.fill(1, 0, 0)
drawBot.stroke(0)
drawBot.strokeWidth(10)
drawBot.drawPath()

drawBot.closePath()

drawBot.fill(None)
drawBot.stroke(1)
drawBot.translate(40, 15)
drawBot.scale(0.7)
drawBot.lineCap("round")
drawBot.lineJoin("round")

drawBot.drawPath()
Exemplo n.º 5
0
 def bezier(self, cp0, cp1, end):
     ctx.curveTo((cp0.x, cp0.y), (cp1.x, cp1.y), (end.x, end.y))
Exemplo n.º 6
0
import drawBot
drawBot.size(200, 200)

drawBot.newPath()
drawBot.moveTo((20, 20))
drawBot.lineTo((20, 100))
drawBot.lineTo((100, 100))
drawBot.lineTo((100, 180))
drawBot.curveTo((150, 180), (180, 150), (180, 100))
drawBot.lineTo((180, 50))
drawBot.qCurveTo((180, 20), (150, 20))

drawBot.fill(1, 0, 0)
drawBot.stroke(0)
drawBot.strokeWidth(10)
drawBot.drawPath()

drawBot.closePath()

drawBot.fill(None)
drawBot.stroke(1)
drawBot.translate(40, 15)
drawBot.scale(0.7)
drawBot.lineCap("round")
drawBot.lineJoin("round")

drawBot.drawPath()