typerig.proxy.objects.base

typerig.proxy.objects.base (version 0.26.0)

# MODULE: Typerig / Proxy / Base (Objects)
# -----------------------------------------------------------
# (C) Vassil Kateliev, 2018-2020        (http://www.kateliev.com)
# (C) Karandash Type Foundry            (http://www.karandash.eu)
#------------------------------------------------------------
# www.typerig.com

Modules

  • fontgate
  • fontlab
  • math
  • PythonQt
  • random
  • typerig.core.objects

Classes

class Coord(typerig.core.objects.point.Point)

# - FL Proxy model -------------------------------------------

Methods

init(self, *argv)



repr(self)



asQPoint(self)



asQPointF(self)



Methods from typerig.core.objects.point.Point

abs(self)



add(self, other)

# -- Operators

and(self, other)

self & other: Used as for Scalar product

div(self, other)



mul(self, other)



neg(self)



or(self, other)

self | other: Used as for Cross product

rdiv = div(self, other)



rmul = mul(self, other)



sub(self, other)



truediv = div(self, other)



angle_to(self, other, add=90)

Angle to another point in radians

diff_to(self, other)



doFlip(self, sign=(True, True))



doSwap(self)

# -- Modifiers

doTransform(self, transform=None)



solve_width(self, y=0)

Get width - find adjacent X by opposite Y

solve_x(self, y)



solve_y(self, x)



Descriptors from typerig.core.objects.point.Point

dict

dictionary for instance variables (if defined)

weakref

list of weak references to the object (if defined)

angle
magnitude
slope
swap
tuple
unit
y_intercept

class Curve(typerig.core.objects.cubicbezier.CubicBezier)



Methods

init(self, *argv)



Methods from typerig.core.objects.cubicbezier.CubicBezier

repr(self)



asList(self)

# -- Modifiers

doSwap(self)



doTransform(self, transform=None)



get_handle_length(self)

Returns handle length and radii from base points.

lerp_first(self, shift)



lerp_last(self, shift)



solve_curvature(self, time)

Find Curvature of on-curve point at given time

solve_derivative(self, time)

Returns point of on-curve point at given time and vector of 1st and 2nd derivative.

solve_distance_end(self, distance, timeStep=0.01)

Returns time at which the given distance to end of bezier is met. 
Probing is executed withing timeStep in range from 0 to 1. The finer the step the preciser the results.

solve_distance_start(self, distance, timeStep=0.01)

Returns time at which the given distance to beginning of bezier is met. 
Probing is executed withing timeStep in range from 0 to 1. The finer the step the preciser the results.

solve_extremes(self)

Finds curve extremes and returns [(extreme_01_x, extreme_01_y, extreme_01_t)...(extreme_n_x, extreme_n_y, extreme_n_t)]

solve_handle_distance_from_base(self, ratio=(0.5, 0.5))

Finds new handle positions for given ratio from base points.

solve_hobby(self, curvature=(0.9, 0.9))

Calculates and applies John Hobby's mock-curvature-smoothness by given curvature - tuple(float,float) or (float)
Based on Metapolator's Hobby Spline by Juraj Sukop, Lasse Fister, Simon Egli

solve_hobby_curvature(self)

Returns current curvature coefficients (complex(alpha), complex(beta)) for 
both handles according to John Hobby's mock-curvature calculation

solve_parallel(self, vector, fullOutput=False)

Finds the t value along a cubic Bezier where a tangent (1st derivative) is parallel with the direction vector.
vector: a pair of values representing the direction of interest (magnitude is ignored).
returns 0.0 <= t <= 1.0 or None

# Solving the dot product of cubic beziers first derivate to the vector given B'(t) x V. Two vectors are perpendicular if their dot product is zero. 
# So if you could find the (1) perpendicular of V it will be collinear == tangent of the curve so the equation to be solved is:
# B'(t) x V(x,y) = 0; -(a*t^2 + b*t + c)*x + (g*t^2 + h*t + i)*y = 0 solved for t, where a,b,c are coefs for X and g,h,i for Y B'(t) derivate of curve
# 
# Inspired by answer given by 'unutbu' on the stackoverflow question: http://stackoverflow.com/questions/20825173/how-to-find-a-point-if-any-on-quadratic-bezier-with-a-given-tangent-direction
# Recoded and recalculated for qubic beziers. Used 'Rearrange It' app at http://www.wolframalpha.com/widgets/view.jsp?id=4be4308d0f9d17d1da68eea39de9b2ce was invaluable.
#
# DOTO: Fix calculation optimization error - will yield false positive result in cases #1 and #2 if vector is 45 degrees

solve_point(self, time)

Find point on cubic bezier at given time

solve_proportional_handles(self, proportion=0.3)

Equalizes handle length to given float(proportion)

solve_slice(self, time)

Returns two segments representing cubic bezier sliced at given time. 
Output: list [(Start), (Start_BCP_out), (Slice_BCP_in), (Slice), (Slice_BCP_out), (End_BCP_in), (End)] of tuples (x,y)

solve_tunni(self)

Make proportional handles keeping curvature and on-curve point positions 
Based on modified Andres Torresi implementation of Eduardo Tunni's method for control points

Descriptors from typerig.core.objects.cubicbezier.CubicBezier

dict

dictionary for instance variables (if defined)

weakref

list of weak references to the object (if defined)

height
line
points
tuple
width
x
x_max
y
y_max

class Line(typerig.core.objects.line.Line)



Methods

init(self, *argv)



asQLineF(self)



asQPoint(self)



Methods from typerig.core.objects.line.Line

add(self, other)



and(self, other)



div(self, other)



mul(self, other)



repr(self)



rmul = mul(self, other)



sub(self, other)



doSwap(self)

# -- Modifiers

doTransform(self, transform=None)



intersect_line(self, other_line)

Find intersection point (X, Y) for two lines.
Returns (None, None) if lines do not intersect.

lerp(self, time)



lerp_xy(self, time_x, time_y)



shift(self, dx, dy)

Shift coordinates by dx, dy

solve_point(self, time)

Find point on the line at given time

solve_slice(self, time)

Slice line at given time

solve_x(self, y)

Solve line equation for X coordinate.

solve_y(self, x)

Solve line equation for Y coordinate.

Descriptors from typerig.core.objects.line.Line

dict

dictionary for instance variables (if defined)

weakref

list of weak references to the object (if defined)

angle
diff_x
diff_y
height
length
points
slope
tuple
width
x
x_max
y
y_intercept

Get the Y intercept of a line segment

y_max

class Vector(typerig.core.objects.line.Vector)



Methods

init(self, *argv)



asQLineF(self)



asQPoint(self)



Methods from typerig.core.objects.line.Vector

repr(self)



getAngle(self)



getSlope(self)

# - Getters

Descriptors from typerig.core.objects.line.Vector

angle
slope
x
y

Methods from typerig.core.objects.line.Line

add(self, other)



and(self, other)



div(self, other)



mul(self, other)



rmul = mul(self, other)



sub(self, other)



doSwap(self)

# -- Modifiers

doTransform(self, transform=None)



intersect_line(self, other_line)

Find intersection point (X, Y) for two lines.
Returns (None, None) if lines do not intersect.

lerp(self, time)



lerp_xy(self, time_x, time_y)



shift(self, dx, dy)

Shift coordinates by dx, dy

solve_point(self, time)

Find point on the line at given time

solve_slice(self, time)

Slice line at given time

solve_x(self, y)

Solve line equation for X coordinate.

solve_y(self, x)

Solve line equation for Y coordinate.

Descriptors from typerig.core.objects.line.Line

dict

dictionary for instance variables (if defined)

weakref

list of weak references to the object (if defined)

diff_x
diff_y
height
length
points
tuple
width
x_max
y_intercept

Get the Y intercept of a line segment

y_max