Esempio n. 1
0
def draw():

    global planet, moon

    p5.fill(255)
    if not moon.finished:
        p5.background(0)
        p5.scale(1, -1)
        p5.translate(0, -height)

        moon.collide(planet)

        moon.update(planet, G)

        #planet.update(moon,G)

        p5.no_fill()
        p5.stroke(255, 60)
        #p5.circle((planet.pos.x,planet.pos.y),2*abs(moon.relpos(planet)))

    p5.fill(10, 173, 73)
    p5.stroke(0)
    planet.show()

    p5.fill(0, 0, 255)
    p5.stroke(0, 0, 255)
    moon.show()
Esempio n. 2
0
def draw():
    global Maps, showGrid
    p5.background(0)
    Maps[0].show()

    if showGrid:
        p5.stroke(255)
        p5.no_fill()
        for x in range(Maps[0].gridWidth+1):
            x += (width/2)/scl-Maps[0].gridpos.x-0.5
            for y in range(Maps[0].gridHeight+1):
                y += (height/2)/scl-Maps[0].gridpos.y-9/32
                p5.begin_shape()
                p5.vertex(x*scl, y*scl)
                p5.vertex(x*scl, (y+1)*scl)
                p5.vertex((x+1)*scl, (y+1)*scl)
                p5.vertex((x+1)*scl, y*scl)
                p5.end_shape()

    if player.walking:
        Maps[0].move(player)
        player.walkingAnimation(Maps[0])
        if player.walkTimer % player.walkingAnimationTime == 0 and player.stopRequest:
            player.walking = False
            player.walkTimer = 0

    p5.fill(255, 0, 0, 70)

    # p5.rect((4*scl+scl*((width/2)/scl-Maps[0].gridpos.x-0.5),4*scl+scl*((height/2)/scl-Maps[0].gridpos.y-9/32)),scl,scl)
    player.show()
    print(Maps[0].gridpos.x, Maps[0].gridpos.y)
Esempio n. 3
0
    def draw(self):
        if self.frame_rate == 0:
            p5.background(0, 0, 0)  # set initial background to black

        # action
        if self.paused:
            return

        self.frame_rate += 1

        self.update()

        # MARK: actual drawing
        p5.background(0, 0, 0, 90)

        p5.fill(255)
        p5.stroke(255)

        p5.rect((self.user.x, self.user.y), self.block_width,
                self.block_height)
        p5.rect((self.machine.x, self.machine.y), self.block_width,
                self.block_height)
        p5.ellipse((self.ball.x, self.ball.y), 2 * self.ball_radius,
                   2 * self.ball_radius)

        if self.draw_prediction and self.last_prediction is not None:
            p5.no_fill()
            p5.stroke(220, 0, 0)
            p5.ellipse((self.width - self.block_width - self.ball_radius,
                        self.last_prediction), 2 * self.ball_radius,
                       2 * self.ball_radius)
Esempio n. 4
0
 def text(self):
     if self.is_text:
         with pf.push_style():
             pf.text(self.str, (self.x, self.y + 30))
             print(pf.text_ascent(), pf.text_descent(),
                   pf.text_width(self.str))
             pf.no_fill()
             pf.stroke(*self.stroke_rgb)
             pf.rect((self.x, self.y + 30),
                     pf.text_width(self.str),
                     pf.text_ascent() + pf.text_descent(),
                     mode="CORNER")
Esempio n. 5
0
def draw():
    p5.background(0)
    p5.stroke(255)
    p5.no_fill()
    p5.translate(width / 2, height / 2)
    p5.rotate_x(3.41459 / 3)
    p5.translate(-w / 2, -h / 2)
    for y in range(rows):
        p5.begin_shape("TRIANGLE_STRIP")
        for x in range(cols):
            p5.vertex(x * scl, y * scl, randint(-100, 100))
            p5.vertex(x * scl, (y + 1) * scl, randint(-100, 100))
        p5.end_shape()
Esempio n. 6
0
def draw_box(qt):
    no_fill()
    stroke(255, 0, 0)
    rect((qt.boundary[0], qt.boundary[1]), qt.boundary[2], qt.boundary[3])

    fill(0, 255, 0)
    stroke(0, 255, 0)
    if len(qt.points) > 0:
        for pt in qt.points:
            ellipse([pt.x, pt.y], 1, 1)

    if qt.children[0] is not None:
        for child in qt.children:
            draw_box(child)
Esempio n. 7
0
def draw():
    p.background(0)
    p.translate(width / 2, height / 2)
    # grid(xscl, yscl)

    rot = p.remap(mouse_x, (0, width), (0, p.TWO_PI))
    tilt = p.remap(mouse_y, (0, height), (0, p.TWO_PI))
    rot_matrix = rottilt(rot, tilt)

    newmatrix = multmatrix(fmatrix, rot_matrix)

    p.no_fill()
    p.stroke_weight(2)
    p.stroke(255, 0, 0)
    graphPoints2(newmatrix, edges)
Esempio n. 8
0
 def draw(self):
     p5.stroke_weight(0.01)
     if self.stage > 0:
         p5.rect((self.bottomLeft.x, self.bottomLeft.y), self.linewidth,
                 -self.height)
     if self.stage > 1:
         p5.rect((self.bottomLeft.x, self.bottomLeft.y - self.height),
                 self.width / 2 + self.linewidth / 2, self.linewidth)
     if self.stage > 2:
         p5.rect((self.bottomLeft.x + self.width / 2 - self.linewidth / 2,
                  self.bottomLeft.y - self.height), self.linewidth,
                 self.height / 4)
     if self.stage > 3:
         p5.no_fill()
         p5.circle((self.bottomLeft.x + self.width / 2, self.bottomLeft.y -
                    self.height + self.height / 4 + (self.linewidth * 2.5)),
                   self.linewidth * 5,
                   mode="CENTER")
     if self.stage > 4:
         p5.fill(255)
         p5.rect((self.bottomLeft.x + self.width / 2 - self.linewidth / 4,
                  self.bottomLeft.y - self.height + self.height / 4 +
                  (self.linewidth * 5)), self.linewidth / 2,
                 self.height / 4)
     if self.stage > 5:
         p5.rect((self.bottomLeft.x + self.width / 2 - self.linewidth / 4,
                  self.bottomLeft.y - self.height + self.height / 4 +
                  (self.linewidth * 5) + 10), -self.width / 4,
                 self.linewidth / 2)
     if self.stage > 6:
         p5.rect((self.bottomLeft.x + self.width / 2 + self.linewidth / 4,
                  self.bottomLeft.y - self.height + self.height / 4 +
                  (self.linewidth * 5) + 10), self.width / 4,
                 self.linewidth / 2)
     if self.stage > 7:
         p5.stroke(255)
         p5.stroke_weight(4)
         p5.line((self.bottomLeft.x + self.width / 2,
                  self.bottomLeft.y - self.height + self.height / 4 +
                  (self.linewidth * 5) + self.height / 4),
                 (self.bottomLeft.x + self.width - self.width / 4,
                  self.bottomLeft.y - self.height / 12))
     if self.stage > 8:
         p5.line((self.bottomLeft.x + self.width / 2,
                  self.bottomLeft.y - self.height + self.height / 4 +
                  (self.linewidth * 5) + self.height / 4),
                 (self.bottomLeft.x + self.width - self.width * 3 / 4,
                  self.bottomLeft.y - self.height / 12))
Esempio n. 9
0
 def rect(self):
     if self.is_rect:
         with pf.push_style():
             if not self.is_stroke and not self.is_fill:
                 return
             pf.color_mode("RGB")
             if self.is_fill:
                 pf.fill(*self.fill_rgb)
             else:
                 pf.no_fill()
             if self.is_stroke:
                 pf.stroke_weight(self.stroke_weight)
                 pf.stroke(*self.stroke_rgb)
             else:
                 pf.no_stroke()
             pf.rect([self.get_rect_x(), self.get_rect_y()], self.w, self.h)
Esempio n. 10
0
def draw():
    global t, circleList
    p.background(200)
    p.translate(width / 4, height / 2)
    p.no_fill()
    p.stroke(0)
    p.ellipse((0, 0), 2 * r1, 2 * r1)
    p.fill(255, 0, 0)
    y = r1 * p.sin(t)
    x = r1 * p.cos(t)
    circleList = [y] + circleList[:249]
    p.ellipse((x, y), r2, r2)
    p.stroke(0, 255, 0)
    p.line((x, y), (200, y))
    p.fill(0, 255, 0)
    p.ellipse((200, y), 10, 10)
    for i, c in enumerate(circleList):
        p.ellipse((200 + i, c), 15, 15)
    t += 0.1
Esempio n. 11
0
def draw():
    global r1, r2, x1, y1, t, prop, points
    p.translate(width / 2, height / 2)
    p.background(255)
    p.no_fill()
    p.stroke(0)
    p.ellipse((x1, y1), 2 * r1, 2 * r1)
    x2 = (r1 - r2) * p.cos(t)
    y2 = (r1 - r2) * p.sin(t)
    p.ellipse((x2, y2), 2 * r2, 2 * r2)
    x3 = x2 + prop * (r2 - r3) * p.cos(-((r1 - r2) / r2) * t)
    y3 = y2 + prop * (r2 - r3) * p.sin(-((r1 - r2) / r2) * t)
    p.fill(255, 0, 0)
    p.ellipse((x3, y3), 2 * r3, 2 * r3)
    points = [[x3, y3]] + points[:2000]
    for i, d in enumerate(points):
        if i < len(points) - 1:
            p.stroke(255, 0, 0)
            p.line((d[0], d[1]), (points[i + 1][0], points[i + 1][1]))
    t += 0.1
Esempio n. 12
0
def draw():
    # pf.image_mode("center")
    # pf.tint()
    # img_size[0]-=1
    pf.background(255)
    # pf.image(img0,(100,100))
    pf.text_font(font)

    # pf.stroke_weight(0)
    pf.text_align("center", "center")
    # pf.stroke(255,0,0)
    # pf.no_fill()

    pf.text_size(100)

    en_str = "hello 你好"

    pf.fill(255, 0, 0)

    gap = 100
    height = 20
    pf.text(en_str, (50, height))

    pf.stroke(0, 0, 255)
    pf.stroke_weight(5)

    height += gap
    pf.text(en_str, (50, height))

    pf.stroke_weight(-5)
    height += gap
    pf.text(en_str, (50, height))

    pf.no_fill()
    height += gap
    pf.stroke_weight(5)
    pf.text(en_str, (50, height))

    height += gap
    pf.stroke_weight(-5)
    pf.text(en_str, (50, height))
Esempio n. 13
0
def draw():
    p5.background(0)

    p5.image_mode("CORNER")
    p5.image(Map.sprite, (0, 0),
             size=(Map.sprite.size[0] * screenScale / 6,
                   Map.sprite.size[1] * screenScale / 6))

    if not True:
        p5.stroke(255)
        p5.no_fill()
        for x in range(int(width / 16)):
            for y in range(int(height / 16)):
                p5.begin_shape()
                p5.vertex(x * scl, y * scl)
                p5.vertex(x * scl, (y + 1) * scl)
                p5.vertex((x + 1) * scl, (y + 1) * scl)
                p5.vertex((x + 1) * scl, y * scl)
                p5.end_shape()

    p5.rect_mode("CENTER")
    p5.fill(255, 0, 0, 90)
    for x, y in Map.bannedList:
        p5.rect((x * scl + 0.5 * scl, y * scl + 0.5 * scl), scl, scl)
Esempio n. 14
0
def tri(length):
    p.no_fill()
    p.triangle((0, -length),(-length*m.sqrt(3)/2, length/2),(length*m.sqrt(3)/2, length/2))
Esempio n. 15
0
 def draw():
     draw_box(qt)
     no_fill()
     stroke(0, 0, 255)
     rect([search[0], search[1]], search[2], search[3])
Esempio n. 16
0
def setup():
    global xscl, yscl
    p.size(width, height)
    xscl = width / rangex
    yscl = -height / rangey
    p.no_fill()
Esempio n. 17
0
def setup():
    p.size(width, height)
    p.no_fill()
Esempio n. 18
0
 def show(self):
     p5.stroke(255)
     p5.no_fill()
     p5.circle((self.pos.x,self.pos.y),self.r*2)