示例#1
0
        i += 1


squareSize = 34
square = Path(points=[
    Point(paper.center.x + squareSize / 2, paper.center.y + squareSize / 2),
    Point(paper.center.x + squareSize / 2, paper.center.y - squareSize / 2),
    Point(paper.center.x - squareSize / 2, paper.center.y - squareSize / 2),
    Point(paper.center.x - squareSize / 2, paper.center.y + squareSize / 2)
],
              closed=True).setPen(cyan)

numLines = 40

for i in range(numLines):
    guideA = drawGuide(
        Point(square.bottomLeft.x - squareSize / (numLines - 1) * i,
              square.bottomLeft.y),
        Point(square.topLeft.x - squareSize / (numLines - 1) * i,
              square.topLeft.y))
    guideA.points[1].move(random() / 2 - 0.25, random() - 0.5 - 10)
    guideA.points[0].move(random() / 2 - 0.25, random() * -2 + 1)

    dashAlongLine(guideA, i / (random() * 8 + 6))

black.setBox()
black.rotate(randint(0, 4) * 90, paper.center)

black.saveGcode("dashes.nc")
paper.save("dashes.svg")
示例#2
0
randSize = 50

smallSquare = getSquare(Point(
  paper.center.x + randSize * random() - randSize / 2,
  paper.center.y + randSize * random() - randSize / 2),
smallSize).setPen(cyan)


randomise(bigSquare, 4)
randomise(smallSquare, 2)


guideA = Path(points = [bigSquare.points[0], smallSquare.points[0]]).setPen(fuscia)
guideB = Path(points = [bigSquare.points[1], smallSquare.points[1]]).setPen(fuscia)
guideC = Path(points = [bigSquare.points[2], smallSquare.points[2]]).setPen(fuscia)
guideD = Path(points = [bigSquare.points[3], smallSquare.points[3]]).setPen(fuscia)

numLines = 12

for l in range(numLines + 1):
  Path(points = [
    guideA.pointAtDistance((guideA.length() / numLines) * l),
    guideB.pointAtDistance((guideB.length() / numLines) * l),
    guideC.pointAtDistance((guideC.length() / numLines) * l),
    guideD.pointAtDistance((guideD.length() / numLines) * l)
  ], closed = True).setPen(black)


black.saveGcode("two-square.nc")
paper.save("two-square.svg")
示例#3
0
    if m > d:
        m = d

    p.moveVector(a, m)

for p in pointList:
    d = p.distanceTo(spotLight3)
    a = p.angleTo(spotLight3)

    m = (40 - d) / 5

    if m > d:
        m = d

    p.moveVector(a, m)
    p.moveVector(random() * 360, 0.1)

for i in range(divisions):
    rowList = []
    colList = []

    for p in range(divisions):
        rowList.append(pointList[i * divisions + p])
        colList.append(pointList[i + p * divisions])

    Path(rowList).setPen(black)
    Path(colList).setPen(black)

black.saveGcode('grid.nc')
paper.save('grid.svg')
示例#4
0
  return square

def randomise(path, distance):
  for p in path.points:
    p.moveVector(360 * random(), distance * random())

square = getSquare(paper.center, 36).setPen(cyan)
randomise(square, 7)

guideA = Path(points = [square.points[0], square.points[1]]).setPen(fuscia)
guideB = Path(points = [square.points[3], square.points[2]]).setPen(fuscia)

numLines = 80

pointList = []

for l in range(numLines + 1):
  if l % 2 == 0:
    pointList.append(guideA.pointAtDistance(guideA.length() / numLines * l))
    pointList.append(guideB.pointAtDistance(guideB.length() / numLines * l))
  else: 
    pointList.append(guideB.pointAtDistance(guideB.length() / numLines * l))
    pointList.append(guideA.pointAtDistance(guideB.length() / numLines * l))

snake = Path(points = pointList).setPen(black)

snake.rotate(randint(0, 3) * 90)

black.saveGcode("snake.nc")
paper.save("snake.svg")