コード例 #1
0
def test(size, color, fill='Default'):  # runs all shapes
    sh.triangle(size, color)
    #forward(300)
    sh.square(size, color)
    #forward(300)
    sh.pentagon(size, color)
    #forward(300)
    sh.hexagon(size, color)
    #forward(300)
    sh.octagon(size, color)
    #forward(300)
    sh.star(size, color)
    #forward(300)
    sh.circler(size, color)
コード例 #2
0
ファイル: util.py プロジェクト: johnmendel/triangle-rendering
def parse_triangle_data(tri_lines):
    ''' Takes in a iterable of lines, each line triangle data.
        Creates triangles, with vectors and colors, for each valid line
        Returns the created triangles, and an array of error data if any
    '''
    triangles = []
    invalid_lines = []
    for num, line in enumerate(tri_lines):
        data = line.strip()
        if data and data[0] != "#":
            values = [float(x) for x in data.split()]
            if len(values) == 18:
                point0 = vector(*values[0:3])
                point1 = vector(*values[3:6])
                point2 = vector(*values[6:9])
                try:
                    col0   = color(*values[9:12])
                    col1   = color(*values[12:15])
                    col2   = color(*values[15:18])
                except InvalidColor, ex:
                    invalid_lines.append((num + 1, data, str(ex)))
                else:
                    # If there were no color problemss, make the triangle
                    tri = triangle(point0, point1, point2, col0, col1, col2)
                    triangles.append(tri)
コード例 #3
0
 def show(self):
     '''Shows the survivor.'''
     self.label.text = '{}'.format(self.score)
     self.label.draw()
     alpha = int(self.f(self.health))
     angle = algelin.heading(self.vel)
     glPushMatrix()
     glTranslatef(self.pos[0] + self.size/2, self.pos[1] + self.size/3, 0.0)
     glRotatef(angle, 0, 0, 1)
     glTranslatef(-self.pos[0] - self.size/2, -self.pos[1] - self.size/3, 0.)
     shapes.triangle(self.pos[0]-2, self.pos[1]-2, self.size, angle=angle, color=(0, 0, 0, alpha+30))
     if self.debug:
         shapes.ring(self.pos[0]+self.size/2, self.pos[1]+self.size/3, self.perception[0], color=(100, 255, 0, alpha))
         shapes.ring(self.pos[0]+self.size/2, self.pos[1]+self.size/3, self.perception[1], color=(255, 100, 0, alpha))
         shapes.line(self.pos[0]+self.size/3, self.pos[1]+self.size/3, self.atraction[0], color=(100, 255, 0, alpha))
         shapes.line(self.pos[0]+self.size/3, self.pos[1]+self.size/3, self.atraction[1], color=(255, 100, 0, alpha))
     glPopMatrix()
コード例 #4
0
import shapes

shapes.octagon()
shapes.circlery()
shapes.square()
shapes.hexagon()
shapes.star()
shapes.triangle()

mainloop()
コード例 #5
0
ファイル: funcitons.py プロジェクト: Adsime/TDT4137-a3
def triangle_val(xPos, coordinates, cut):
    return shapes.triangle(xPos, coordinates[0], coordinates[1], coordinates[2], cut)
コード例 #6
0
import shapes as sh

print(sh.circle(4))
print(sh.rectangle(4, 5))
print(sh.triangle(4, 6))
コード例 #7
0
ファイル: turtle_shapes.py プロジェクト: jwmarion/DC_Turtles
import shapes
from turtle import mainloop

shapes.startPoint()

shapes.star(100, True, 'red')

shapes.square(100, False, 'blue')

shapes.hexagon(100, True, 'beige')

shapes.circle(100, True, 'purple')

shapes.pentagon(100, False, 'white')

shapes.octagon(100, True, 'Green')

shapes.triangle(100, True, 'yellow')

mainloop()
コード例 #8
0
for x in range(0, 7):
    shapes.cell(
        image, [0, x],
        [randint(0, 255), randint(0, 255),
         randint(0, 255)], 0.1)
    shapes.cell(image, [0, x], e, 0.1)
for x in range(7, 0, -1):
    shapes.cell(
        image, [0, x],
        [randint(0, 255), randint(0, 255),
         randint(0, 255)], 0.1)
    shapes.cell(image, [0, x], e, 0.1)

# triangles
shapes.triangle(image, [0, 0], [3, 3], [0, 6], [0, 0, 255], 1)
shapes.triangle(image, [6, 0], [3, 3], [6, 6], [0, 0, 255], 1)
image = shapes.clear(image)

# moving circles
for y in range(5):
    shapes.circle(image, (3, 4), 2, w, .1)
    shapes.circle(image, (3, 4), 2, e, 0)
    shapes.circle(image, (4, 5), 3, w, .1)
    shapes.circle(image, (4, 5), 3, e, 0)
    shapes.circle(image, (5, 6), 3, w, .1)
    shapes.circle(image, (5, 6), 3, e, 0)
    shapes.circle(image, (6, 7), 3, w, .1)
    shapes.circle(image, (6, 7), 3, e, 0)
    shapes.circle(image, (7, 8), 3, w, .1)
    shapes.circle(image, (7, 8), 3, e, 0)
コード例 #9
0
# 測試一下 shapes 模組中的程式

import turtle
from shapes import square, triangle

screen = turtle.Screen()
screen.setup(400, 400)

t = turtle.Turtle()

triangle(t, 50, 50, 100)
triangle(t, -50, -50, 50)
triangle(t, -50, 50, 30)

screen.exitonclick()
コード例 #10
0
import shapes

#main program begins
print("drawing!")
shapes.square(0,0,200,'magenta',True)
shapes.triangle(0,200,200,'red',True)
shapes.mycircle(-100,200,50,'yellow',True,360)
print("finished!")
コード例 #11
0
ファイル: art.py プロジェクト: teresahu/digitalcrafts
 def makeTri(siz, col, flip='Default'):
     if flip == True:
         sh.triangleFlip((SIZES[siz]) / K, COLORS[col], fill=True)
     else:
         sh.triangle((SIZES[siz]) / K, COLORS[col], fill=True)
コード例 #12
0
import shapes as sh

print(sh.circle(10))
print(sh.rectangle(10, 5))
print(sh.triangle(10, 5))

print('główny - wartość zmiennnej __name__:', __name__)
コード例 #13
0
                    list_location.append(num)
                    if sublist[1] != 0:
                        overlaps_path = fc.checkoverlaps(num, list_location_path, overlaps_path)
                        list_location_path.append(num)

                    if sublist[1] == 2 or sublist[1] == 1:
                        fill = '#FF6D8F'  # pink
                        stroke = '#960c2c'
                        if sublist[2] == 2:  # nonsense
                            fill = '#FFFF8E'  # yellow
                            stroke = '#ffaa00'
                        elif sublist[2] == 1:  # gly
                            fill = '#91bdff'  # blue
                            stroke = '#004ec4'
                        if overlaps_path == 0:
                            f.write(shapes.triangle(line2, num, fill, stroke))
                            f.write(shapes.line(line2, num, stroke))
                        else:
                            line2 = 278 - (overlaps_path * 9)
                            f.write(shapes.overlap_triangle(line2, num, fill, stroke))
                    elif sublist[1] == 0:
                        fill = '#c8ff72'  # green
                        stroke = '#5d8c15'
                    if overlaps == 0:
                        f.write(shapes.triangle(line1, num, fill, stroke))
                        f.write(shapes.line(line1, num, stroke))
                    elif len(edits_list) != 0:
                        line1 = 170 - (overlaps * 9)
                        f.write(shapes.overlap_triangle(line1, num, fill, stroke))
                    else:
                        line1 = 178 - (overlaps * 9)
コード例 #14
0
def triangle_val(xPos, coordinates, cut):
    return shapes.triangle(xPos, coordinates[0], coordinates[1],
                           coordinates[2], cut)
コード例 #15
0
def tritest():
    sh.triangle(50, 'red')
コード例 #16
0
ファイル: Spirograph.py プロジェクト: ben-boy/spirograph
            t.hideturtle()
            t.speed(100)
            t.color(colours)
            shapes.square(int(size))
            t.left(int(rotate))

if choice == "triangle":
    size = input("Give me a number ")
    rotate = input("Give another number ")
    colour = input("Give a colour ")

    while True:
        t.speed(100)
        t.hideturtle()
        t.color(str(colour))
        shapes.triangle(int(size))
        t.left(int(rotate))

if choice == "randomtriangle":
    size = randint(50, 200)
    rotate = randint(10, 100)
    print(size, rotate)

    while True:
        for colours in [
                "red", "orange", "yellow", "green", "blue", "purple", "pink"
        ]:
            t.bgcolor("black")
            t.hideturtle()
            t.speed(100)
            t.color(colours)