def parseTri(node):
    s_tri = node.attributes["faint:tri"].value
    p0, p1, p2 = s_tri.split(" ")
    p0 = [float(v) for v in p0.split(",")]
    p1 = [float(v) for v in p1.split(",")]
    p2 = [float(v) for v in p2.split(",")]
    return ifaint.Tri(p0, p1, p2)
def parse_tri(node):
    """Parses a faint:tri.attribute (used for ellipses)"""
    s_tri = node.attributes["faint:tri"].value
    p0, p1, p2 = s_tri.split(" ")
    p0 = [float(v) for v in p0.split(",")]
    p1 = [float(v) for v in p1.split(",")]
    p2 = [float(v) for v in p2.split(",")]
    return ifaint.Tri(p0, p1, p2)
def apply_matrix(obj_id, props, matrix):
    """Multiplies the Tri of the object, specified by the obj_id, with
    the matrix."""
    tri = props.get_obj_tri(obj_id)
    p0 = tri.p0()
    p1 = tri.p1()
    p2 = tri.p2()
    p0 = multiply_matrix_pt(matrix, p0)
    p1 = multiply_matrix_pt(matrix, p1)
    p2 = multiply_matrix_pt(matrix, p2)
    props.set_obj_tri(obj_id, ifaint.Tri(p0, p1, p2))
def applyCTF(obj_id, props):
    #if str(obj) == "Group":
    #    # Fixme: Why?
    #    return
    tri = props.get_obj_tri(obj_id)
    ctm = tm[-1]
    p0 = tri.p0()
    p1 = tri.p1()
    p2 = tri.p2()
    p0 = matrix_mul(ctm, p0)
    p1 = matrix_mul(ctm, p1)
    p2 = matrix_mul(ctm, p2)
    props.set_obj_tri(obj_id, ifaint.Tri(p0, p1, p2))  # ifaint necessary?
Exemplo n.º 5
0
def parse_polygon_as_rect(node, state):
    """Skewed Faint-rectangles are saved as polygons (marked with
    faint:type="rect").

    """
    state = state.updated(node)
    rect_id = state.props.Rect(
        (0, 0, 1, 1), state.settings
    )  # Fixme: Pass Tri to props.rect instead of defaulting like this
    p0, p1, p3, p2 = pairs(parse_points(node.get('points')))
    del p3
    state.props.set_obj_tri(rect_id, ifaint.Tri(p0, p1, p2))
    state.transform_object(rect_id)
    return rect_id
def parsePolygonNode(node):
    points = node.attributes['points'].value.strip()
    points = points.replace(" ", ",")  # Fixme
    vals = [float(coord) for coord in points.split(',') if len(coord) > 0]

    if node.hasAttribute(
            'faint:type') and node.attributes["faint:type"].value == "rect":
        return [
            "rect",
            ifaint.Tri((vals[0], vals[1]), (vals[2], vals[3]),
                       (vals[6], vals[7])),
            getSettings(node),
            parseNodeTransform(node)
        ]

    return ["polygon", vals, getSettings(node), parseNodeTransform(node)]
def mul_matrix_tri(m, tri):  # pylint:disable=invalid-name
    """Multiples the matrix with the tri. Returns a new tri."""
    return ifaint.Tri(mul_matrix_pt(m, tri.p0()), mul_matrix_pt(m, tri.p1()),
                      mul_matrix_pt(m, tri.p2()))
def parse_faint_tri_attr(node):
    """Parses a faint:tri attribute from the node"""
    tri_str = node.get(ns_faint("tri"))
    p0, p1, p2 = pairs(parse_points(tri_str))
    return ifaint.Tri(p0, p1, p2)