curvatureVisualizer

Tools to visualize the curvature of Bezier segments.

Math formulas converted from Drawing better looking curves.

makeCurvatureCombSegment(segment, steps, scale=1000)
makeCurvatureCombGlyph(glyph, steps, scale)
class SegmentCurvatureVisualizer(ctx)

An object to visualize the curvature of a Bezier segment.

curvatureDraw = False
curvatureColor = (1, 0, 0)
curvatureLineDash = (2, 2)
curvatureStrokeWidth = 1
curvatureCombDraw = True
curvatureCombColor = (0, 1, 0)
curvatureCombSteps = 50
curvatureCombScale = 2500
curvatureCombStrokeWidth = 1
curvatureCombStrokeWidth2 = 2
handlesDraw = False
handlesColor = (0, 0, 1)
handlesLineDash = (2, 2)
handlesStrokeWidth = 2
tangentDraw = False
tangentColor = (0, 0, 1)
tangentLineDash = (2, 2)
tangentStrokeWidth = 1
curveDraw = False
curveColor = (0,)
curveStrokeWidth = 3
pointsDraw = False
pointsColor = (0,)
pointsRadius = 4
linesAtTDraw = False
linesAtTColor = (1, 0, 0)
linesAtTLineDash = (2, 2)
linesAsTStrokeWidth = 1
__init__(ctx)

Initialize the object for a given context.

Parameters

ctx (module) – A drawing context (drawBot or mojo.drawingTools).

draw(segment, t=None)

Draw the curvature visualization for a Bezier segment and a given ratio.

Parameters
  • segment (RSegment) – A Bezier segment.

  • t (float) – The ratio for a point in the segment.

class CurvatureVisualizer(ctx)

An object to visualize the curvature of a BezierPath.

import drawbot
from hTools3.modules.curvatureVisualizer import CurvatureVisualizer

B = BezierPath()
B.oval(512, 360, 300, 300)
B.text('g', font='IBMPlexMono-Bold', fontSize=720)

g = CurrentGlyph()
if g:
    g = g.copy()
    g.scaleBy(0.6)
    g.moveBy((450, 0))
    g.draw(B)

translate(50, 250)
fill(1, 1, 0, 0.5)
stroke(0, 1, 1)
strokeWidth(4)
drawPath(B)

V = CurvatureVisualizer(drawBot)
V.visualizer.curvatureCombSteps = 20
V.visualizer.curvatureCombScale = 1500
V.visualizer.curvatureCombColor = 1, 0, 1
V.draw(B)
__init__(ctx)

Initialize the object for a given context.

setParameters(parameters)

Set object attributes from a parameters dict.

draw(bezierPath, t=None)

Draw the curvature visualization for a given Bezier path.

Parameters

bezierPath – A BezierPath object.