Beispiel #1
0
 def transform(self, ocs: OCSTransform, elevation: float) -> None:
     self.control_points = list(
         ocs.transform_2d_vertex(v, elevation) for v in self.control_points
     )
     self.fit_points = list(
         ocs.transform_2d_vertex(v, elevation) for v in self.fit_points
     )
     if self.start_tangent is not None:
         t = Vec3(self.start_tangent).replace(z=elevation)
         self.start_tangent = ocs.transform_direction(t).vec2
     if self.end_tangent is not None:
         t = Vec3(self.end_tangent).replace(z=elevation)
         self.end_tangent = ocs.transform_direction(t).vec2
Beispiel #2
0
    def transform(self, m: Matrix44) -> 'Text':
        """ Transform TEXT entity by transformation matrix `m` inplace.

        .. versionadded:: 0.13

        """
        dxf = self.dxf
        if not dxf.hasattr('align_point'):
            dxf.align_point = dxf.insert
        ocs = OCSTransform(self.dxf.extrusion, m)
        dxf.insert = ocs.transform_vertex(dxf.insert)
        dxf.align_point = ocs.transform_vertex(dxf.align_point)
        old_rotation = dxf.rotation
        new_rotation = ocs.transform_deg_angle(old_rotation)
        x_scale = ocs.transform_length(Vec3.from_deg_angle(old_rotation))
        y_scale = ocs.transform_length(
            Vec3.from_deg_angle(old_rotation + 90.0))

        if not ocs.scale_uniform:
            oblique_vec = Vec3.from_deg_angle(
                old_rotation + 90.0 - dxf.oblique)
            new_oblique_deg = new_rotation + 90.0 - ocs.transform_direction(
                oblique_vec).angle_deg
            dxf.oblique = new_oblique_deg
            y_scale *= math.cos(math.radians(new_oblique_deg))

        dxf.width *= x_scale / y_scale
        dxf.height *= y_scale
        dxf.rotation = new_rotation

        if dxf.hasattr('thickness'):  # can be negative
            dxf.thickness = ocs.transform_length((0, 0, dxf.thickness),
                                                 reflection=dxf.thickness)
        dxf.extrusion = ocs.new_extrusion
        return self