コード例 #1
0
ファイル: polygon.py プロジェクト: rubaimushtaq/python
def draw():
    p.translate(width / 2, height / 2)
    p.begin_shape()
    for i in range(6):
        p.vertex(100 * p.cos(p.radians(60 * i)),
                 100 * p.sin(p.radians(60 * i)))
        p.rotate(p.radians(60))
    p.end_shape('CLOSE')
コード例 #2
0
def draw():
    global t
    p.background(255)
    p.translate(width/2, height/2)
    p.rotate(p.radians(t))
    for _ in range(12):
        p.rect((200, 0),50, 50)
        p.rotate(p.radians(360/12))
    t += 2
コード例 #3
0
def draw():
    global t
    p.background(255)
    p.translate(width/2, height/2)
    for i in range(90):
        p.rotate(p.radians(360/90))
        with p.push_matrix():
            p.translate(200, 0)
            p.rotate(p.radians(t+2*i*360/90))
            tri(100)
        t+=0.01
コード例 #4
0
def draw():
    global sprite
    p5.background(255)
    theta = mouse_y

    # reference shape
    sprite.draw_pointer()

    p5.fill(255, 0, 0, 128)
    #  rotate a house shape aboutits centre
    with p5.push_matrix():
        p5.translate(40, 40)
        p5.rotate(p5.radians(theta))
        sprite.draw_house()
コード例 #5
0
def draw():
    global sprite_1
    global sprite_2
    p5.background(255)
    theta = mouse_y
    # sprite_1.x = mouse_x

    # reference shape
    sprite_1.draw_pointer()

    p5.fill(255, 0, 0, 128)
    #  rotate a house shape about its centre
    with p5.push_matrix():
        p5.translate(40, 40)
        p5.rotate(p5.radians(theta))
        sprite_1.draw_house()

    p5.fill(250, 250, 0, 127)
    with p5.push_matrix():
        p5.translate(mouse_x, mouse_y)
        p5.rotate(2 * p5.PI * mouse_y / height)
        sprite_2.draw_pointer()
コード例 #6
0
def polygon(sides, sz):
    p.begin_shape()
    for i in range(sides):
        step = p.radians(360 / sides)
        p.vertex(sz * p.cos(i * step), sz * p.sin(i * step))
    p.end_shape('CLOSE')