Ejemplo n.º 1
0
def main(args, width=30000, height=20000, left=0, right=30000, bottom=0, top=20000):
    pen_count = args.pen_count

    print("width: %d height: %d" % (width, height))

    # start in a random spot
    plot = abstract_masterpiece(top, bottom, left, right, height, width, pen_count)
    if args.output is None or args.view:
        io.view(plot)
    if args.output is not None:
        output_name, extension = os.path.splitext(args.output)
        io.export(plot, output_name, fmt=extension[1:])
Ejemplo n.º 2
0
    rads_incr = segmentation_map[segmentation_mode.lower()]()
    rads = start_angle
    arc = []
    while rads < end_angle:
        coord = Coordinate(math.cos(rads), math.sin(rads))
        coord = coord * Coordinate(width / 2.0, height / 2.0)
        rads += rads_incr
        arc.append(coord)
    ## NOTE: this is better than using rads <= end_angle since
    ## the equality does not always work as expected with floats
    ## due to rounding.
    last = Coordinate(math.cos(end_angle), math.sin(end_angle))
    last *= Coordinate(width / 2.0, height / 2.0)
    arc.append(last)
    return Path(arc)


## RUN DEMO CODE

if __name__ == '__main__':
    from chiplotle.tools import io
    from chiplotle.geometry.core.group import Group

    gr = Group()
    for radius in range(100, 1000, 10):
        ae = arc_ellipse(radius, radius * 2, 0, math.pi / 2, 5, 'arc')
        gr.append(ae)

    io.view(gr)
Ejemplo n.º 3
0
from chiplotle.geometry.core.coordinate import Coordinate
from chiplotle.geometry.core.path import Path
from chiplotle.geometry.core.group import Group


def cross(width, height):
    '''Draws a cross shape.

    - `width` is the length of the horizontal line.
    - `height` is the length of the vertical line..
    '''

    l1 = Path([Coordinate(-width / 2.0, 0), Coordinate(width / 2.0, 0)])
    l2 = Path([Coordinate(0, -height / 2.0), Coordinate(0, height / 2.0)])
    return Group([l1, l2])


## RUN DEMO CODE

if __name__ == '__main__':
    from chiplotle.tools import io
    from chiplotle.geometry.core.path import Path
    e = cross(100, 200)
    print e.format
    io.view(e)
Ejemplo n.º 4
0
from chiplotle.geometry.core.coordinate import Coordinate
from chiplotle.geometry.transforms.transformvisitor import TransformVisitor


def offset(shape, value):
    '''In place offsetting.

    - `shape` is the shape to be rotated.
    - `value` is the offset value. Can be a scalar or an (x, y) coordinate.
    '''
    if isinstance(value, (list, tuple)):
        value = Coordinate(*value)

    def offset(coords, value):
        return coords + value

    t = TransformVisitor(offset)
    t.visit(shape, value)


## RUN DEMO CODE
if __name__ == "__main__":
    from chiplotle.geometry.shapes.rectangle import rectangle
    from chiplotle.tools import io
    r0 = rectangle(1000, 400)
    r1 = rectangle(1000, 400)
    r2 = rectangle(1000, 400)
    offset(r1, (0, 1500))
    offset(r2, (100, 200))
    io.view(Group([r0, r1, r2]))
Ejemplo n.º 5
0
from chiplotle.geometry.core.path import Path
from chiplotle.tools.mathtools import polar_to_xy
import math
import random


def random_walk_polar(steps, step_size=500):
    """Random Walk. Border is a circle"""

    the_points = []
    two_pi = math.pi * 2

    for i in range(steps):
        A = random.random() * two_pi
        r = step_size
        xy = polar_to_xy((r, A))
        the_points.append(xy)

    return Path(the_points)


## RUN DEMO CODE

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

    rw = random_walk_polar(1000)
    assert isinstance(rw, Path)
    # print rw.format
    io.view(rw)
Ejemplo n.º 6
0
    by Johan Gielis.

    - `points_count` is the total number of points to compute.
    - `travel` is the length of the outline drawn in radians.
        3.1416 * 2 is a complete cycle.
    '''
    travel = travel or (math.pi * 2)

    ## compute points...
    phis = [i * travel / point_count
        for i in range(int(point_count * percentage))]
    points = [superformula(a, b, m, n1, n2, n3, x) for x in phis]

    ## scale and transpose...
    path = [ ]
    for x, y in points:
        x *= width
        y *= height
        path.append(Coordinate(x, y))

    return Path(path)


## RUN DEMO CODE

if __name__ == '__main__':
    from chiplotle.tools import io
    from chiplotle.geometry.core.path import Path
    e = supershape(100, 120, 5, 3.3, 2, 3, b=0.75, travel = 4*math.pi)
    io.view(e)
Ejemplo n.º 7
0
    return result


## RUN DEMO CODE

if __name__ == "__main__":
    from chiplotle.geometry.core.group import Group
    from chiplotle.geometry.transforms.offset import offset
    from chiplotle.geometry.transforms.rotate import rotate
    from chiplotle.tools import io

    # one of each main spiral type
    s1 = spiral_archimedean(500, wrapping_constant=1)

    s2 = spiral_archimedean(500, wrapping_constant=2, direction="ccw")
    offset(s2, (0, -1000))

    # these two are long, so we'll rotate them and move them to the side
    # of the others
    s3 = spiral_archimedean(1800, wrapping_constant=-1, direction="ccw")
    rotate(s3, math.pi * 1.5)
    offset(s3, (650, 400))
    s4 = spiral_archimedean(1500, wrapping_constant=-2, direction="ccw")
    rotate(s4, math.pi * 0.6)
    offset(s4, (1000, -1100))

    g = Group([s1, s2, s3, s4])

    io.view(g)
Ejemplo n.º 8
0
from chiplotle.tools.mathtools import polar_to_xy
import math
import random


def random_walk_polar(steps, step_size=500):
    '''Random Walk. Border is a circle'''

    the_points = []
    two_pi = math.pi * 2

    for i in range(steps):
        A = random.random() * two_pi
        r = step_size
        xy = polar_to_xy((r,A))
        the_points.append(xy)

    return Path(the_points)


## RUN DEMO CODE

if __name__ == '__main__':
    from chiplotle.tools import io

    rw = random_walk_polar(1000)
    assert isinstance(rw, Path)
    #print rw.format
    io.view(rw)

Ejemplo n.º 9
0
from future import standard_library

standard_library.install_aliases()
from chiplotle.geometry.core.polygon import Polygon
from chiplotle.geometry.shapes.arc_circle import arc_circle
import math


def fan(radius, start_angle, end_angle, height, segments=100, filled=False):
    """A Fan is a slice of a donut seen from above
    (when you can see the hole in the middle).

    All angles are assumed to be in radians."""
    if start_angle > end_angle:
        end_angle += math.pi * 2

    arc1 = arc_circle(radius - height / 2, start_angle, end_angle, segments)
    arc2 = arc_circle(radius + height / 2, start_angle, end_angle, segments)
    points = list(arc1.points) + list(reversed(arc2.points))
    return Polygon(points)


## RUN DEMO CODE

if __name__ == "__main__":
    from chiplotle.tools import io
    import math

    f = fan(1000, math.pi / 4, math.pi / 4 * 3, 500, 30)
    io.view(f)
Ejemplo n.º 10
0
               end_angle,
               segments=100,
               segmentation_mode='2PI'):
    '''
   Constructs an arc from a circle with the given radius,
   and number of segments. Arc goes from start_angle to end_angle,
   both of which are in radians.

      - `segmentation_mode` : '2PI' or 'arc'. The first segments
         the whole circle into the given number of segments,
         the second segments the arc.
   '''
    radius = radius * 2.0
    return arc_ellipse(radius, radius, start_angle, end_angle, segments,
                       segmentation_mode)


## RUN DEMO CODE

if __name__ == '__main__':
    from chiplotle.tools import io

    gr = Group()

    for radius in range(100, 1000, 100):
        ac = arc_circle(radius, 1.0, math.pi)
        assert isinstance(ac, Path)
        gr.append(ac)

    io.view(gr, 'png')
Ejemplo n.º 11
0
from chiplotle.tools.mathtools.rotate_2d import rotate_2d
from chiplotle.geometry.transforms.transformvisitor import TransformVisitor


def rotate(shape, angle, pivot=(0, 0)):
    """In place rotation.

    - `shape` is the shape to be rotated.
    - `angle` is the angle (in radians) of rotation.
    - `pivot` is the center of rotation. Must be a Coordinate or (x, y) pair.
    """

    def rotate(coords, angle, pivot=pivot):
        return rotate_2d(coords, angle, pivot)

    t = TransformVisitor(rotate)
    t.visit(shape, angle, pivot)


## RUN DEMO CODE
if __name__ == "__main__":
    from chiplotle.geometry.shapes.rectangle import rectangle
    from chiplotle.tools import io

    r1 = rectangle(1000, 400)
    r2 = rectangle(1000, 400)
    r3 = rectangle(2000, 900)
    rotate(r1, 3.14 / 4)
    rotate(r2, 3.14 / 4, (500, 500))
    io.view(Group([r1, r2, r3]))
Ejemplo n.º 12
0
from chiplotle.geometry.shapes.rectangle import rectangle
from chiplotle.geometry.core.group import Group

def frame(width, height, inset):
    '''A frame (rectangle within a rectangle) with a width, height, and inset.

    - `width` is the width of the frame.
    - `height` is the height of the frame.
    - `inset` is the distance to inset the inner rectangle from the outer.
    '''

    r1 = rectangle(width, height)
    r2 = rectangle(width - (inset * 2), height - (inset * 2))
    return Group([r1, r2])



## RUN DEMO CODE
if __name__ == '__main__':
    from chiplotle.tools import io

    f1 = frame(1000, 500, inset = 20)
    io.view(f1)
Ejemplo n.º 13
0
from chiplotle.geometry.core.coordinate import Coordinate
from chiplotle.geometry.transforms.transformvisitor import TransformVisitor

def offset(shape, value):
    '''In place offsetting.

    - `shape` is the shape to be rotated.
    - `value` is the offset value. Can be a scalar or an (x, y) coordinate.
    '''
    if isinstance(value, (list, tuple)):
        value = Coordinate(*value)

    def offset(coords, value):
        return coords + value

    t = TransformVisitor(offset)
    t.visit(shape, value)


## RUN DEMO CODE
if __name__ == "__main__":
    from chiplotle.geometry.shapes.rectangle import rectangle
    from chiplotle.tools import io
    r0 = rectangle(1000, 400)
    r1 = rectangle(1000, 400)
    r2 = rectangle(1000, 400)
    offset(r1, (0, 1500))
    offset(r2, (100, 200))
    io.view(Group([r0, r1, r2]))

Ejemplo n.º 14
0
from chiplotle.geometry.shapes.ellipse import ellipse
from chiplotle.geometry.core.group import Group
from chiplotle.geometry.core.path import Path

def donut(width, height, inset, segments = 100):
    '''
        A donut (ellipse within ellipse) with a width, height, inset, segments.

        segments is how many lines should be used to draw ellipse. More
        segments create a smoother ellipse, but will take longer to draw.

        inset is the distance to inset the inner ellipse from the outer.

        The donut is drawn with the current pen location as the center.
        offset may be used to shift this around, for example, to draw from
        the lower, left corner.
    '''

    e1 = ellipse(width, height, segments)
    e2 = ellipse(width - (inset * 2), height - (inset * 2), segments)
    return Group([e1, e2])


## RUN DEMO CODE
if __name__ == '__main__':
    from chiplotle.tools import io

    d1 = donut(1000, 500, inset = 20)
    io.view(d1)
Ejemplo n.º 15
0
    ur_y = ul_y
    bl_y = ul_y - height

    x_step_size = width / width_divisions
    y_step_size = height / height_divisions

    g = Group()

    ## add horizontal lines
    for i in range(height_divisions + 1):
        step_y = y_step_size * i
        l = line((ul_x, ul_y - step_y), (ur_x, ur_y - step_y))
        g.append(l)
    ## add vertical lines

    for i in range(width_divisions + 1):
        step_x = x_step_size * i
        l = line((ul_x + step_x, ul_y), (bl_x + step_x, bl_y))
        g.append(l)

    return g

## RUN DEMO CODE

if __name__ == '__main__':
    from chiplotle.tools import io
    gr = grid(1000, 2000, 10, 20)
    assert isinstance(gr, Group)
    print gr.format
    io.view(gr)
Ejemplo n.º 16
0
    for i in reversed(range(len(points) - 1)):
        dxy.insert(0, a[i] + dxy[0] * bi[i])

    ## compute interpolated points...
    plot_points = [ ]
    for i in range(len(points) - 1):
        control_points = [
            points[i],
            points[i] + dxy[i],
            points[i+1] - dxy[i+1],
            points[i+1]]
        plot_points += bezier_interpolation(control_points,
                                                        interpolation_count, 1)[:-1]

    return Path(plot_points)



## RUN DEMO CODE

if __name__ == '__main__':
    from chiplotle.geometry.core.group import Group
    from chiplotle.tools import io
    points  = [(0, 0), (1000, 1000), (-1000, 1000), (-1000, -1000), (1000, -1000), (0, 0)]
    e1 = path_interpolated(points, 1)
    e2 = path_interpolated(points, 0.5)
    e3 = path_interpolated(points, 0)
    assert isinstance(e1, Path)

    io.view(Group([e1, e2, e3]))
Ejemplo n.º 17
0
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
from future import standard_library

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


def line(startpoint, endpoint):
    """Returns a Path with only two points.
    The path describes a simple straight line.
    """
    return Path([startpoint, endpoint])


## RUN DEMO CODE

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

    l = line((0, 0), (1000, 1000))
    print(l.format)
    io.view(l)
Ejemplo n.º 18
0
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library

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


def path(points):
    """A simple path."""
    return Path(points)


## DEMO CODE
if __name__ == "__main__":
    from chiplotle.tools import io

    points = [(0, 0), (10, 10), (-10, 10), (-10, -10), (10, -10), (0, 0)]
    p = path(points)
    io.view(p)
Ejemplo n.º 19
0
from chiplotle.geometry.core.polygon import Polygon
from chiplotle.geometry.shapes.arc_circle import arc_circle
import math

def fan(radius, start_angle, end_angle, height, segments=100, filled=False):
    '''A Fan is a slice of a donut seen from above
    (when you can see the hole in the middle).

    All angles are assumed to be in radians.'''
    if start_angle > end_angle:
        end_angle += math.pi * 2

    arc1 = arc_circle(radius - height / 2, start_angle, end_angle, segments)
    arc2 = arc_circle(radius + height / 2, start_angle, end_angle, segments)
    points = list(arc1.points) + list(reversed(arc2.points))
    return Polygon(points)


## RUN DEMO CODE

if __name__ == '__main__':
    from chiplotle.tools import io
    import math

    f = fan(1000, math.pi / 4, math.pi / 4 * 3, 500, 30)
    io.view(f)
Ejemplo n.º 20
0

## RUN DEMO CODE

if __name__ == '__main__':
    from chiplotle.tools import io
    from chiplotle.geometry.shapes.group import group
    from chiplotle.geometry.shapes.cross import cross
    from chiplotle.geometry.transforms.offset import offset

    t_base = 4000
    points = [(-t_base/2,0),(0,t_base*0.8660),(t_base/2,0)]

    ## a list containing different sets of weights for the middle point
    weights = [[1,1,1],[1,2,1],[1,0.5,1],[1,0,1],[1,-0.5,1]]

    c = group([])
    ## draws a cross at each control point
    for i in points:
        r = cross(100,100)
        offset(r, i)
        c.append(r)

    ## draws the rational bezier curve for each weight set
    for w in weights:
        b = path_bezier(points, weight=w)
        c.append(b)

    io.view(c)

Ejemplo n.º 21
0
def arc_circle(radius, start_angle, end_angle, segments=100, segmentation_mode="2PI"):
    """
   Constructs an arc from a circle with the given radius,
   and number of segments. Arc goes from start_angle to end_angle,
   both of which are in radians.

      - `segmentation_mode` : '2PI' or 'arc'. The first segments
         the whole circle into the given number of segments,
         the second segments the arc.
   """
    radius = radius * 2.0
    return arc_ellipse(
        radius, radius, start_angle, end_angle, segments, segmentation_mode
    )


## RUN DEMO CODE

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

    gr = Group()

    for radius in range(100, 1000, 100):
        ac = arc_circle(radius, 1.0, math.pi)
        assert isinstance(ac, Path)
        gr.append(ac)

    io.view(gr, "png")
Ejemplo n.º 22
0
from chiplotle.geometry.shapes.rectangle import rectangle
from chiplotle.geometry.core.group import Group


def frame(width, height, inset):
    '''A frame (rectangle within a rectangle) with a width, height, and inset.

    - `width` is the width of the frame.
    - `height` is the height of the frame.
    - `inset` is the distance to inset the inner rectangle from the outer.
    '''

    r1 = rectangle(width, height)
    r2 = rectangle(width - (inset * 2), height - (inset * 2))
    return Group([r1, r2])


## RUN DEMO CODE
if __name__ == '__main__':
    from chiplotle.tools import io

    f1 = frame(1000, 500, inset=20)
    io.view(f1)
Ejemplo n.º 23
0
from chiplotle.geometry.core.path import Path

def line(startpoint, endpoint):
    '''Returns a Path with only two points.
    The path describes a simple straight line.
    '''
    return Path([startpoint, endpoint])


## RUN DEMO CODE

if __name__ == '__main__':
    from chiplotle.tools import io

    l = line((0,0), (1000,1000))
    print l.format
    io.view(l)
Ejemplo n.º 24
0
    return result


## RUN DEMO CODE

if __name__ == '__main__':
    from chiplotle.geometry.core.group import Group
    from chiplotle.geometry.transforms.offset import offset
    from chiplotle.geometry.transforms.rotate import rotate
    from chiplotle.tools import io

    #one of each main spiral type
    s1 = spiral_archimedean(500, wrapping_constant=1)

    s2 = spiral_archimedean(500, wrapping_constant=2, direction="ccw")
    offset(s2, (0, -1000))

    #these two are long, so we'll rotate them and move them to the side
    #of the others
    s3 = spiral_archimedean(1800, wrapping_constant=-1, direction="ccw")
    rotate(s3, math.pi * 1.5)
    offset(s3, (650, 400))
    s4 = spiral_archimedean(1500, wrapping_constant=-2, direction="ccw")
    rotate(s4, math.pi * .6)
    offset(s4, (1000, -1100))

    g = Group([s1, s2, s3, s4])

    io.view(g)
Ejemplo n.º 25
0
standard_library.install_aliases()
from chiplotle.geometry.shapes.ellipse import ellipse
from chiplotle.geometry.core.group import Group


def donut(width, height, inset, segments=100):
    """
        A donut (ellipse within ellipse) with a width, height, inset, segments.

        segments is how many lines should be used to draw ellipse. More
        segments create a smoother ellipse, but will take longer to draw.

        inset is the distance to inset the inner ellipse from the outer.

        The donut is drawn with the current pen location as the center.
        offset may be used to shift this around, for example, to draw from
        the lower, left corner.
    """

    e1 = ellipse(width, height, segments)
    e2 = ellipse(width - (inset * 2), height - (inset * 2), segments)
    return Group([e1, e2])


## RUN DEMO CODE
if __name__ == "__main__":
    from chiplotle.tools import io

    d1 = donut(1000, 500, inset=20)
    io.view(d1)
Ejemplo n.º 26
0
            points[i] + dxy[i],
            points[i + 1] - dxy[i + 1],
            points[i + 1],
        ]
        plot_points += bezier_interpolation(control_points,
                                            interpolation_count, 1)[:-1]

    return Path(plot_points)


## RUN DEMO CODE

if __name__ == "__main__":
    from chiplotle.geometry.core.group import Group
    from chiplotle.tools import io

    points = [
        (0, 0),
        (1000, 1000),
        (-1000, 1000),
        (-1000, -1000),
        (1000, -1000),
        (0, 0),
    ]
    e1 = path_interpolated(points, 1)
    e2 = path_interpolated(points, 0.5)
    e3 = path_interpolated(points, 0)
    assert isinstance(e1, Path)

    io.view(Group([e1, e2, e3]))
Ejemplo n.º 27
0
        point_order = []
        for i in range(0, num_points):
            point_num =  (i * jump_size) % num_points
            point_order.append(point_num)

        corners = [corners[i] for i in point_order]

        return  Polygon(corners)


## RUN DEMO CODE
if __name__ == '__main__':
    from chiplotle.tools import io
    from chiplotle.geometry.shapes.star_crisscross import star_crisscross
    from chiplotle.geometry.core.group import Group
    from chiplotle.geometry.transforms.offset import offset

    gr1 = Group()

    for points in range(5, 26):
        for i in range(1, points):
            s = star_crisscross(1000, 1000, num_points = points,
                jump_size = i, find_valid_jump_size = False)
            offset(s, ((i - 1) * 1000, -(points - 5) * 1000))
            gr1.append(s)

    io.view(gr1)


Ejemplo n.º 28
0
    return Path(plot_points)


## RUN DEMO CODE

if __name__ == "__main__":
    from chiplotle.tools import io
    from chiplotle.geometry.shapes.group import group
    from chiplotle.geometry.shapes.cross import cross
    from chiplotle.geometry.transforms.offset import offset

    t_base = 4000
    points = [(-t_base / 2, 0), (0, t_base * 0.8660), (t_base / 2, 0)]

    ## a list containing different sets of weights for the middle point
    weights = [[1, 1, 1], [1, 2, 1], [1, 0.5, 1], [1, 0, 1], [1, -0.5, 1]]

    c = group([])
    ## draws a cross at each control point
    for i in points:
        r = cross(100, 100)
        offset(r, i)
        c.append(r)

    ## draws the rational bezier curve for each weight set
    for w in weights:
        b = path_bezier(points, weight=w)
        c.append(b)

    io.view(c)
Ejemplo n.º 29
0
        point_order = []
        for i in range(0, num_points):
            point_num = (i * jump_size) % num_points
            point_order.append(point_num)

        corners = [corners[i] for i in point_order]

        return Polygon(corners)


## RUN DEMO CODE
if __name__ == "__main__":
    from chiplotle.tools import io
    from chiplotle.geometry.shapes.star_crisscross import star_crisscross
    from chiplotle.geometry.core.group import Group
    from chiplotle.geometry.transforms.offset import offset

    gr1 = Group()

    for points in range(5, 26):
        for i in range(1, points):
            s = star_crisscross(1000,
                                1000,
                                num_points=points,
                                jump_size=i,
                                find_valid_jump_size=False)
            offset(s, ((i - 1) * 1000, -(points - 5) * 1000))
            gr1.append(s)

    io.view(gr1)
Ejemplo n.º 30
0
    from chiplotle.geometry.shapes.line import line
    from chiplotle.geometry.core.group import Group
    from chiplotle.tools import io
    from random import randrange

    #draw a bunch of lines that do not intersect

    no_intersections = Group()

    line_1 = line([randrange(0, 4000), randrange(0, 4000)],
        [randrange(0, 4000), randrange(0, 4000)])
    no_intersections.append(line_1)

    while len(no_intersections) < 300:
        new_line = line([randrange(0, 4000), randrange(0, 4000)],
            [randrange(0, 4000), randrange(0, 4000)])

        intersection = False

        for l in no_intersections:
            if get_line_intersection(new_line, l) != None:
                intersection = True
                break

        if intersection == False:
            no_intersections.append(new_line)
            print "found %d lines..." % len(no_intersections)

    io.view(no_intersections)

Ejemplo n.º 31
0
from chiplotle.geometry.core.group import Group
from chiplotle.tools.mathtools.rotate_2d import rotate_2d
from chiplotle.geometry.transforms.transformvisitor import TransformVisitor


def rotate(shape, angle, pivot=(0, 0)):
    """In place rotation.

    - `shape` is the shape to be rotated.
    - `angle` is the angle (in radians) of rotation.
    - `pivot` is the center of rotation. Must be a Coordinate or (x, y) pair.
    """
    def rotate(coords, angle, pivot=pivot):
        return rotate_2d(coords, angle, pivot)

    t = TransformVisitor(rotate)
    t.visit(shape, angle, pivot)


## RUN DEMO CODE
if __name__ == "__main__":
    from chiplotle.geometry.shapes.rectangle import rectangle
    from chiplotle.tools import io

    r1 = rectangle(1000, 400)
    r2 = rectangle(1000, 400)
    r3 = rectangle(2000, 900)
    rotate(r1, 3.14 / 4)
    rotate(r2, 3.14 / 4, (500, 500))
    io.view(Group([r1, r2, r3]))
Ejemplo n.º 32
0
from chiplotle.geometry.core.path import Path

def path(points):
    '''A simple path.'''
    return Path(points)



## DEMO CODE
if __name__ == '__main__':
    from chiplotle.tools import io
    points  = [(0, 0), (10, 10), (-10, 10), (-10, -10), (10, -10), (0, 0)]
    p = path(points)
    io.view(p)
Ejemplo n.º 33
0
   '''
   Constructs an arc from a circle with the given radius,
   and number of segments. Arc goes from start_angle to end_angle,
   both of which are in radians.

      - `segmentation_mode` : '2PI' or 'arc'. The first segments
         the whole circle into the given number of segments,
         the second segments the arc.
   '''
   radius = radius * 2.0
   return arc_ellipse(radius, radius,
                      start_angle, end_angle,
                      segments, segmentation_mode)



## RUN DEMO CODE

if __name__ == '__main__':
   from chiplotle.tools import io

   gr = Group()

   for radius in range(100, 1000, 100):
       ac = arc_circle(radius, 1.0, math.pi)
       assert isinstance(ac, Path)
       gr.append(ac)

   io.view(gr, 'png')