Beispiel #1
0
from future import standard_library

standard_library.install_aliases()
from chiplotle.geometry.core.coordinatearray import CoordinateArray
from chiplotle.geometry.core.path import Path


class Polygon(Path):
    """A closed path."""

    def __init__(self, points, filled=False):
        Path.__init__(self, points)
        self.filled = filled

    @property
    def _preformat_points(self):
        """Points (coordinates) ready for formatting (conversion to HPGL)."""
        coords = self.points[:]
        coords.append(coords[0])
        return CoordinateArray(coords)


if __name__ == "__main__":
    from chiplotle import io

    p = Polygon([(0, 0), (2000, 0), (1000, 1000), (0, 500)], 0)
    print(p.points)
    print(p._preformat_points)

    io.view(p)
Beispiel #2
0
from chiplotle.geometry.core.transformlock import TransformLock
from chiplotle.geometry.core.shape import _Shape

def lock_group(shapes, lock_transforms):
    t = TransformLock(shapes, lock_transforms)
    return t


## ~~~~~~~~~~~~~~~~~~~~~~~
if __name__ == '__main__':
    from chiplotle.geometry.shapes.square import square
    from chiplotle.geometry.core.group import Group
    from chiplotle.geometry.transforms.rotate import rotate
    from chiplotle.geometry.transforms.offset import offset
    from chiplotle import io
    import math

    r1 = square(100)
    r2 = square(150)
    l = lock_group([r2], ['rotate'])
    g  = Group([r1, l])
    offset(g, (200, 0))
    rotate(g, math.pi / 4)
    io.view(g)
Beispiel #3
0
from chiplotle.geometry.core.transformlock import TransformLock
from chiplotle.geometry.core.shape import _Shape


def lock_group(shapes, lock_transforms):
    t = TransformLock(shapes, lock_transforms)
    return t


## ~~~~~~~~~~~~~~~~~~~~~~~
if __name__ == '__main__':
    from chiplotle.geometry.shapes.square import square
    from chiplotle.geometry.core.group import Group
    from chiplotle.geometry.transforms.rotate import rotate
    from chiplotle.geometry.transforms.offset import offset
    from chiplotle import io
    import math

    r1 = square(100)
    r2 = square(150)
    l = lock_group([r2], ['rotate'])
    g = Group([r1, l])
    offset(g, (200, 0))
    rotate(g, math.pi / 4)
    io.view(g)
Beispiel #4
0
        s1 = shapes.star_outline(100, 100, 4)
        transforms.offset(s1, (300, 0))
        transforms.rotate(s1, -math.pi / 4)
        s2 = shapes.star_outline(100, 100, 6)
        transforms.offset(s2, (300, 0))
        transforms.rotate(s2, -math.pi / 2)
        s3 = shapes.star_outline(100, 100, 9)
        transforms.offset(s3, (300, 0))
        transforms.rotate(s3, -math.pi * 3 / 4)

        tl = TransformLock([s1, s2], ["scale"])
        start = Group([tl, s3])

        mid = copy.deepcopy(start)
        end = copy.deepcopy(start)

        formatters.Pen(3)(start)
        formatters.Pen(2)(mid)
        formatters.Pen(1)(end)
        transforms.scale(mid, 2)
        transforms.scale(end, 3)

        o = shapes.circle(100)
        return Group([start, mid, end, o])

    ## go...
    r = rotation_example()
    s = scale_example()

    io.view(Group([s, r]))
Beispiel #5
0
from chiplotle.geometry.core.coordinatearray import CoordinateArray
from chiplotle.geometry.core.path import Path
from chiplotle.tools.hpgltools.convert_coordinates_to_hpgl_absolute_path import (
    convert_coordinates_to_hpgl_absolute_path,
)


class Polygon(Path):
    """A closed path."""

    def __init__(self, points, filled=False):
        Path.__init__(self, points)
        self.filled = filled

    @property
    def _preformat_points(self):
        """Points (coordinates) ready for formatting (conversion to HPGL)."""
        coords = self.points[:]
        coords.append(coords[0])
        return CoordinateArray(coords)


if __name__ == "__main__":
    from chiplotle import io

    p = Polygon([(0, 0), (2000, 0), (1000, 1000), (0, 500)], 0)
    print p.points
    print p._preformat_points

    io.view(p)