Exemplo n.º 1
0
    def display(self):
        colour_scale = remap(self.lifespan, (0, self.initial_lifespan),
                             (0, 255))
        fill(0, colour_scale, 0, colour_scale)
        stroke(colour_scale, 0, 0, colour_scale)

        theta = self.velocity.angle
        with push_matrix():
            translate(self.location.x, self.location.y)
            rotate(theta + PI / 2)
            triangle(
                (0, -self.size / 2),
                (-self.size / 4, self.size / 2),
                (self.size / 4, self.size / 2),
            )
        circle((self.location.x, self.location.y), 5)
        """
        display debug vector lines.
        Green = acceleration
        Red = velocity
        """

        # line((self.location.x, self.location.y),
        #      (self.location.x + self.velocity.x * 10,
        #       self.location.y + self.velocity.y * 10))
        # stroke(0, 244, 0)
        # line((self.location.x, self.location.y),
        #      (self.location.x + self.acceleration.x * 100,
        #       self.location.y + self.acceleration.y * 100))
        """ Debug end """
Exemplo n.º 2
0
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')
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 5
0
 def show(self):
     translate(self.x, self.y)
     angle = atan2(self.dy, self.dx)
     rotate(angle)
     # fixed sized "boid"
     triangle(
         [0, 0],
         [-10, 4],
         [-10, -4],
     )
     rotate(-angle)
     translate(-self.x, -self.y)
Exemplo n.º 6
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()
Exemplo n.º 7
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()
Exemplo n.º 8
0
def draw():
    # sayac değikenini düzenlemek için global
    global sayac
    # Eğer ilk framede isek, arka planı siyah yap
    if sayac == 0:
        p5.background(p5.Color(0, 0, 0))

    # isimlerin sayacinci elemanını al
    isim = isimler[sayac]

    # 0, 0 noktasını ekranın sol üst köşesine taşı (resetleme)
    p5.reset_matrix()
    # 0, 0 noktasını ekranın x ekseninnde orta, y ekseninde alt tarafa taşı
    p5.translate(1920 / 2, 1080 - 50)

    # isim deki her harf için döngü başlat
    for harf in isim:
        # harfın ascii değerine bak.
        if ord(harf) % 2:
            # Çift ise pozitif yönde aci kadar dön
            p5.rotate(aci)
        else:
            # Tek ise negatif yönde aci kadar dön
            p5.rotate(-aci)

        # 0, 0'dan y yönünde uzunluk kadar br çizgi çiz
        p5.line(p5.Vector(0, 0), p5.Vector(0, -uzuluk))
        # 0, 0 noktasını çizilen çizginin son noktasına taşı
        p5.translate(0, -uzuluk)

    # Eğer sayac isimlerin uzunluğundan bir eksik ise
    if sayac == len(isimler) - 1:
        # Bitti yaz ve p5, döngüsünü durdur
        print("Bitti")
        p5.no_loop()
    else:
        # değilse, sayac'ı bir arttır
        sayac += 1