def drawGlyph(g): # needs DrawBot from drawbot_skia.drawbot import BezierPath, drawPath, translate # from drawBot import BezierPath, drawPath, translate bez = BezierPath() g.drawPoints(bez) drawPath(bez) translate(g.width, 0)
def cross(x, y): with db.savedState(): db.fill(None) db.stroke(0) db.strokeWidth(1) db.translate(x, y) # line vertical db.line((u * 2, 0), (u * 2, u * 4)) # line horizontale db.line((0, u * 2), (u * 4, u * 2))
def trame(x, y, s, n, w): r = 0.97 * w step = r / n with db.savedState(): db.fill(None) db.stroke(0) db.strokeWidth(s) db.translate(x, y) for i in range(n): f = i / (n - 1) x = db.sin(2 * pi * 1) * 68 * db.sin(pi * f) circle((x, 0), r) r -= step
def grid(xt, yt, nR): cell_s = (pw - (m*12)) / nR db.translate(xt, yt) for x in range(nR): for y in range(nR): db.stroke(None) db.linearGradient( (0, 0), (0, 500), [(1, 0, 0), (0, 1, 0), (0, 0, 0)], [0, .6, 1] ) c_rect((x * cell_s + cell_s / 2, y * cell_s + cell_s/2), cell_s - u)
# line vertical db.line((u * 2, 0), (u * 2, u * 4)) # line horizontale db.line((0, u * 2), (u * 4, u * 2)) # cross cross(m, m) cross((pw - m * 2), m) cross(m, (ph - m * 2)) cross((pw - m * 2), (ph - m * 2)) # text db.stroke(None) db.fill(0) db.font("Plantin MT Pro", 11) db.text("Une forme molle dessinée à partir de trois points.", (m * 2, m * 3)) db.translate(pw / 2, ph / 2) db.stroke(None) db.fill(1, 0, 0) # draw a unique shape drawShape(pw * 0.5) # central cross cross(m, m) # db.saveImage(str(name) + '.jpg') # db.saveImage(str(name) + '.pdf') db.saveImage('shape_01022021.pdf')