示例#1
0
def graphFunction():
    x = xmin
    while x <= xmax:
        p.stroke(255, 0, 0)
        p.fill(0)
        p.line((x * xscl, f(x) * yscl), ((x + 0.1) * xscl, f(x + 0.1) * yscl))
        x += 0.1
示例#2
0
def draw():
    p5.background(0)

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

    settings.Maps[settings.currentMap].show()
    player.show()
    settings.Maps[settings.currentMap].drawExtras()

    p5.stroke(255)
    p5.stroke_weight(1)
    if showGrid:
        for x in range(settings.Maps[settings.currentMap].gridWidth + 2):
            p5.line((settings.Maps[settings.currentMap].GridtoPosX(x),
                     settings.Maps[settings.currentMap].GridtoPosY(0)),
                    (settings.Maps[settings.currentMap].GridtoPosX(x),
                     settings.Maps[settings.currentMap].GridtoPosY(
                         settings.Maps[settings.currentMap].gridHeight + 1)))
        for y in range(settings.Maps[settings.currentMap].gridHeight + 2):
            p5.line((settings.Maps[settings.currentMap].GridtoPosX(0),
                     settings.Maps[settings.currentMap].GridtoPosY(y)),
                    (settings.Maps[settings.currentMap].GridtoPosX(
                        settings.Maps[settings.currentMap].gridWidth + 1),
                     settings.Maps[settings.currentMap].GridtoPosY(y)))
示例#3
0
    def follow(self, path):
        # calculate future location
        predicted_location = copy.copy(self.velocity)
        predicted_location.normalize()
        predicted_location *= 10
        predicted_location += self.location
        shortest_distance = width  # initialise to a large number
        # check whether future location is on path

        for i in range(len(path.points) - 1):
            point_a = path.points[i]
            point_b = path.points[i + 1]
            norm = sp.scalar_projection(predicted_location, point_a, point_b)
            if(norm.x < point_a.x or norm.x > point_b.x):
                continue
            distance = Vector.distance(norm, predicted_location)
            if distance < shortest_distance:
                shortest_distance = distance
                direction = point_b - point_a
                direction.normalize()
                direction *= 20
                target = norm + direction


            if shortest_distance > path.radius:
                self.steer(target)
                if self.debug:
                    line(self._tup(self.location), (self._tup(predicted_location)))
                    fill(255, 0, 0)
                    ellipse((norm.x, norm.y), 10, 10)
                    fill(0, 255, 0)
                    ellipse((target.x, target.y), 10, 10)
def new_doodle(d):
    p5.background(240, 238, 225)

    n = doodles[d]

    query = "SELECT MIN(vertex_x) as 'left', " \
          "MAX(vertex_x) as 'right', " \
                   "MIN(vertex_y) as 'top', " \
                   "MAX(vertex_y) as 'bottom' " \
            "FROM path_verticies " \
            "WHERE doodle_id = '%s'" % d

    table_rows = db.query(query)
    outers = {
        k: v
        for k, v in zip(['left', 'right', 'top', 'bottom'], table_rows[0])
    }
    l, r, t, b = outers['left'], outers['right'], outers['top'], outers[
        'bottom']

    x_interp = interp1d([l, r], [0, res])
    y_interp = interp1d([t, b], [0, res])

    for i in range(n):

        path_chars_columns = [
            'doodle_id', 'path_number', 'color_r', 'color_g', 'color_b',
            'stroke_weight'
        ]

        path_verts_columns = [
            'doodle_id', 'path_number', 'vertex_number', 'vertex_x', 'vertex_y'
        ]

        query = "SELECT * FROM path_characteristics " \
                "WHERE doodle_id = '%s' AND path_number = %d" % (d, i)
        table_rows = db.query(query)
        path_chars = {k: v for k, v in zip(path_chars_columns, table_rows[0])}

        query = "SELECT * FROM path_verticies " \
                "WHERE doodle_id = '%s' AND path_number = %d" % (d, i)
        table_rows = db.query(query)
        path_verts = pd.DataFrame(table_rows, columns=path_verts_columns)

        p5.stroke(path_chars['color_r'], path_chars['color_g'],
                  path_chars['color_b'])

        for i in range(path_verts.shape[0] - 1):

            row = path_verts.iloc[i]
            row_next = path_verts.iloc[i + 1]

            x = round(float(x_interp(row.vertex_x)), 2)
            y = round(float(y_interp(row.vertex_y)), 2)
            x_next = round(float(x_interp(row_next.vertex_x)), 2)
            y_next = round(float(y_interp(row_next.vertex_y)), 2)

            p5.line((x, y), (x_next, y_next))
示例#5
0
def draw():
    global smallBall, bigBall
    p5.background(0)
    smallBall.updatePos(bigBall)
    smallBall.collision(bigBall)

    smallBall.show()
    bigBall.show()
    p5.stroke(255, 0, 0)
    p5.line((smallBall.pos), (bigBall.pos))
示例#6
0
def draw():

    p5.translate(width / 2, height / 2)

    #v=p5.Vector(randint(-100,100),randint(-100,100))
    v = p5.Vector.random_2D()  #random unit vector in 2d
    v *= 100
    p5.stroke_weight(4)
    p5.stroke(255, 50)
    p5.line((0, 0), (v.x, v.y))
def draw():
    global smallBall, bigBall
    p5.background(0)
    MousePos = p5.Vector(mouse_x, mouse_y)
    smallBall.pos = MousePos
    smallBall.collision(bigBall)
    print(abs(smallBall.relativePos(bigBall)))
    smallBall.show()
    bigBall.show()
    p5.stroke(255, 0, 0)
    p5.line((smallBall.pos), (bigBall.pos))
示例#8
0
def draw():
    p5.background(0)
    pos = p5.Vector(200, 200)
    mouse = p5.Vector(mouse_x, mouse_y)
    v = mouse - pos
    #m=abs(v)
    v = v.normalize() * 100
    p5.translate(width / 2, height / 2)
    p5.stroke_weight(4)
    p5.stroke(255)
    p5.line((0, 0), (v.x, v.y))
示例#9
0
 def display(self):
     for row in range(self.number_of_rows):
         for column in range(self.number_of_columns):
             origin = [column * self.resolution, row * self.resolution]
             vector_x = copy.copy(self.field[row][column].x)
             vector_y = copy.copy(self.field[row][column].y)
             vector_x *= 10
             vector_y *= 10
             with push_matrix():
                 translate(self.resolution / 2, self.resolution / 2)
                 line((origin), (origin[0] + vector_x, origin[1] + vector_y))
                 reset_matrix()
示例#10
0
def draw():
    background(250)
    global point_a
    global point_b
    stroke(0)
    mouse = Vector(mouse_x, mouse_y)

    line(point_a, mouse)
    line(point_a, point_b)

    norm = scalar_projection(mouse, point_a, point_b)
    fill(255, 0, 0)
    ellipse((norm.x, norm.y), 10, 10)
示例#11
0
def draw():
    p.background(255)
    p.translate(width/2, height/2)
    points = []
    t = 0
    while t < 1000:
        points.append(harmonograph(t))
        t += 0.01
    for i, s in enumerate(points):
        p.stroke_weight(0.01)
        p.stroke(255, 0, 0)
        if i < len(points)-1:
            p.line((s[0], s[1]), (points[i+1][0], points[i+1][1]))
示例#12
0
def draw():
    p5.background(0)
    p5.stroke(255)
    p5.stroke_weight(strokeWeight)
    if showGrid:
        for x in range(int(gridW / gridScl) + 1):
            x += gridOffsetX / gridScl
            p5.line((x * gridScl, gridOffsetY),
                    (x * gridScl, gridOffsetY + gridH))

        for y in range(int(gridH / gridScl) + 1):
            y += gridOffsetY / gridScl
            p5.line((gridOffsetX, y * gridScl),
                    (gridOffsetX + gridW, y * gridScl))
示例#13
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))
示例#14
0
def grid(xscl, yscl):
    p.stroke_weight(1)
    p.stroke(0, 255, 255)
    for i in range(xmin, xmax + 1):
        p.line((i * xscl, ymin * yscl), (i * xscl, ymax * yscl))
    for i in range(ymin, ymax + 1):
        p.line((xmin * xscl, i * yscl), (xmax * xscl, i * yscl))
    p.stroke(0)
    p.line((0, ymin * yscl), (0, ymax * yscl))
    p.line((xmin * xscl, 0), (xmax * xscl, 0))
def new_doodle():
    p5.background(240, 238, 225)
    
    d = doodle_ids[randint(0, len(doodle_ids) - 1)]
    n = doodles[d]
    
    for i in range(n):
        
        path_chars_columns =['doodle_id', 'path_number', 'color_r', 
                             'color_g', 'color_b', 'stroke_weight']
        
        path_verts_columns =['doodle_id', 'path_number', 
                             'vertex_number', 'vertex_x', 'vertex_y']
         
        query = "SELECT * FROM path_characteristics " \
                "WHERE doodle_id = '%s' AND path_number = %d" % (d, i)
        cursor.execute(query)
        table_rows = cursor.fetchall()
        path_chars = {k:v for k,v in zip(path_chars_columns, table_rows[0])}
        
        query = "SELECT * FROM path_verticies " \
                "WHERE doodle_id = '%s' AND path_number = %d" % (d, i)
        cursor.execute(query)
        table_rows = cursor.fetchall()
        path_verts = pd.DataFrame(table_rows, columns=path_verts_columns)
        
        p5.stroke(path_chars['color_r'], 
                  path_chars['color_g'], 
                  path_chars['color_b'])
        
        
#        p5.stroke_weight(path_chars['stroke_weight'])
        for i in range(path_verts.shape[0] - 1):
            
            row = path_verts.iloc[i]
            row_next = path_verts.iloc[i + 1]
            
            x = round(row.vertex_x, 2)
            y = round(row.vertex_y, 2)
            x_next = round(row_next.vertex_x, 2)
            y_next = round(row_next.vertex_y, 2)
            
            p5.line((x, y), (x_next, y_next))
示例#16
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
示例#17
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
示例#18
0
    def displayWord(self, word):
        self.word = word
        self.wordLength = len(word)
        self.spacing = (self.width / (self.wordLength)) / 2

        self.offset = (width / 2 - self.width / 2) + self.spacing / 2

        self.txt_size = int(self.spacing * 4 / 3)
        self.GuessFont = p5.create_font("arial.ttf", self.txt_size)
        p5.text_font(self.GuessFont, self.txt_size)
        p5.text_align("CENTER", "BASELINE")
        self.txt_width = p5.text_width("A")

        for i in range(self.wordLength):
            p5.fill(255)
            p5.text(word[i],
                    ((i * 2 * self.spacing) + self.spacing / 2 + self.offset,
                     self.y - (self.txt_width * 4 / 3) - 2))
            p5.line((i * 2 * self.spacing + self.offset, self.y),
                    (((i * 2) + 1) * self.spacing + self.offset, self.y))
示例#19
0
def draw():
    global ofset, x, y, z,fp,fl
    if(flag7=="fsek"):
        ofset = sek
    if (flag2 == "pus"):
        pass
    if(flag8=="nxt" or flag9=="pev"):
        ofset=sek
        fp=fl

    else:
        signal, sampling_rate = audio2numpy.audio_from_file(fp, offset=ofset, duration=dur, dtype='int')
        p.background(250)
        signal = abs(signal)
        # signal = signal[..., 1]
        ofset = ofset + dur
        # print(np.size(signal[:250]))
        for i in signal:
            p.line((x, height - 5), (x, -(200 * i[1] + 50) + height - 5))
            x +=1.5
            p.line((x, height - 5), (x, -(200 * i[0]+100) + height - 5))
            x+=1.5
            p.line((x, height - 5), (x, -(200*i[1]+50)+height - 5))
            x +=1.5
            if (ofset >= final):
                pass
        time.sleep(dur)
        x = 5
示例#20
0
    def draw_objects(self):
        # global simulation

        # triangle((0, 0), (0, 200), (350, 100))
        background(30, 30, 47)

        # don't paint obstacles for free run
        if self.free_run:
            return

        fill(50)
        # shaded are upper quadrant
        quad((0, 0), (0, 160), (280, 256), (self.shaded_area_x, 0))
        quad((0, self.height), (0, 640), (280, 544),
             (self.shaded_area_x, self.height))

        fill(102)
        triangle((0, 160), (0, 640), (700, 400))

        # fishes' start box
        rect((self.box_left, 335), self.box_width, self.box_width)

        # replica line
        for rc in self.replicas_coordinates:
            line((0, rc[2]), (rc[0], rc[1]))
        # line((0, 720), (self.replica_x_start, self.replica_y_start))

        # shaded area line
        line((self.shaded_area_x, 0), (self.shaded_area_x, self.height))

        # 544

        # decision line
        line((self.decision_x, 0), (self.decision_x, self.height))
示例#21
0
    def show(self):
        # find line showing boid direction
        y_angle = math.atan(self.velocity[1] / self.velocity[0])
        x_angle = math.atan(self.velocity[0] / self.velocity[1])
        larger = x_angle if x_angle > y_angle else y_angle
        lsign = -1 if larger < 0 else 1

        norm_x = x_angle / (10.0 * lsign)
        norm_y = y_angle / (10.0 * lsign)

        x_mult = -1 if self.velocity[0] < 0 else 1
        y_mult = -1 if self.velocity[1] < 0 else 1

        x_point_coord = self.position[0] + (x_mult * norm_x * 100)
        y_point_coord = self.position[1] + (y_mult * norm_y * 100)

        # show the boid on the grid
        stroke(255)
        fill(255)
        circle(self.position, 9)
        stroke("red")
        line(self.position, (x_point_coord, y_point_coord))
示例#22
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
示例#23
0
def draw():
    # Arka planı siyah yap
    p5.background(0)
    # Orijini pencerenin merkezine taşı
    p5.translate(width / 2, height / 2)

    # clock fonsiyonundan gelen değerleri
    # sırasıyla h, m ve s değişkenlerine ata
    h, m, s = clock()

    # Çevre çizgisi çizme
    p5.no_stroke()

    # [0, 360) aralığında 6'şar derece aralıklarla değer oluştur
    # 0, 6, 12, ...,  342, 348, 354
    for i in range(0, 360, 6):

        # Kutupsal koordinat sisteminde
        # (r_d, i) değerini kartezyen koordinat sistemine dönüştür
        d_x, d_y = pol2car(r_d, i)

        # i değeri 30'un tam katıysa,
        if i % 30 == 0:
            # saat değerleri için nokta koyacağız
            p5.fill(255, 0, 0)
            r = 15
        else:
            # dakika/saniye değerleri için nokta koyacağız
            p5.fill(255)
            r = 10

        # Belirlenen özelliklerle hesaplanan noktada
        # bir daire çiz
        p5.circle((d_x, d_y), r)

    # Akrep kolunun ucunun konumunu hesala
    h_x, h_y = pol2car(r_h, h)
    # Akrep kolunun şekil ayarlarını yap
    p5.stroke(255)
    p5.stroke_weight(5)
    # Akrep konu çiz
    p5.line((0, 0), (h_x, h_y))

    # Yelkovan kolunun ucunun konumunu hesala
    m_x, m_y = pol2car(r_m, m)
    # Yelkovan kolunun şekil ayarlarını yap
    p5.stroke(255)
    p5.stroke_weight(3)
    # Yelkovan konu çiz
    p5.line((0, 0), (m_x, m_y))

    # Saniye kolunun ucunun konumunu hesala
    s_x, s_y = pol2car(r_s, s)
    # Saniye kolunun şekil ayarlarını yap
    p5.stroke(255, 0, 0)
    p5.stroke_weight(1)
    # Saniye konu çiz
    p5.line((0, 0), (s_x, s_y))
示例#24
0
    def show(self, boid_list):
        y_angle = math.atan(self.vel[1] / self.vel[0])
        x_angle = math.atan(self.vel[0] / self.vel[1])
        larger = x_angle if x_angle > y_angle else y_angle
        lsign = -1 if larger < 0 else 1

        norm_x = x_angle / (10.0 * lsign)
        norm_y = y_angle / (10.0 * lsign)

        x_mult = -1 if self.vel[0] < 0 else 1
        y_mult = -1 if self.vel[1] < 0 else 1

        x_point_coord = self.pos[0] + (x_mult * norm_x * 150)
        y_point_coord = self.pos[1] + (y_mult * norm_y * 150)

        if self.id == 0 and VIEW_DISPLAY_ON:
            stroke("gray", alpha=100.5, v2=80)
            fill("gray", alpha=100.5, v2=80)
            circle((self.pos), radius=2 * VIEWING_DIST)

            stroke("blue")
            for boid in boid_list:
                x_coord_difference = self.pos[0] - boid.pos[0]
                y_coord_difference = self.pos[1] - boid.pos[1]
                dist = magnitude(x_coord_difference, y_coord_difference)
                #if within min distance
                if dist <= VIEWING_DIST:
                    try:
                        line(self.pos, boid.pos)
                    except:
                        pass

        #get random color
        stroke(255)
        fill(255)
        circle(self.pos, radius=10)
        stroke("red")
        line(self.pos, (x_point_coord, y_point_coord))
示例#25
0
    def follow(self, path):
        # calculate future location
        predicted_location = copy.copy(self.velocity)
        predicted_location.normalize()
        predicted_location *= 50
        predicted_location += self.location
        # check whether future location is on path
        norm = sp.scalar_projection(predicted_location, path.point_a,
                                    path.point_b)
        distance = Vector.distance(norm, predicted_location)
        direction = path.point_b - path.point_a
        direction.normalize()
        direction *= 20
        target = norm + direction

        if distance > path.radius:
            self.steer(target)
            if self.debug:
                line(self._tup(self.location), (self._tup(predicted_location)))
                fill(255, 0, 0)
                ellipse((norm.x, norm.y), 10, 10)
                fill(0, 255, 0)
                ellipse((target.x, target.y), 10, 10)
    def drawProjectionLine(self,line):
        p5.stroke(255,0,0)
        p5.fill(255,0,0)

        if line.p1.x!=line.p2.x:
            #not a vertical line
            posfromLine=self.pos-line.p1
            multiplier=(posfromLine.dot(line.Vector))/(abs(line.Vector)**2)
            proj=line.Vector*multiplier
            closestPoint=proj+line.p1


            if closestPoint.x>line.p1.x and closestPoint.x<line.p2.x:
                p5.circle((closestPoint),10)
                p5.line((closestPoint),(self.pos))
            elif closestPoint.x<line.p1.x:
                p5.circle((line.p1),10)
                p5.line((line.p1),(self.pos))
            elif closestPoint.x>line.p2.x:
                p5.circle((line.p2),10)
                p5.line((line.p2),(self.pos))

        else:
            #a vertical line
            #print("Vertical")
            closestPoint=p5.Vector(line.p1.x,self.pos.y)

            if closestPoint.y>line.p1.y and closestPoint.y<line.p2.y:
                p5.circle((closestPoint),10)
                p5.line((closestPoint),(self.pos))
            elif closestPoint.y<line.p1.y:
                p5.circle((line.p1),10)
                p5.line((line.p1),(self.pos))
            elif closestPoint.y>line.p2.y:
                p5.circle((line.p2),10)
                p5.line((line.p2),(self.pos))
 def show(self):
     p5.stroke(255)
     p5.line(self.p1,self.p2)
示例#28
0
 def applyForce(self, force):
     self.acceleration += force
     line(
         (self.location.x, self.location.y),
         (self.location.x - force.x, self.location.y - force.y),
     )
示例#29
0
def graphPoints2(pointList, edges):
    for e in edges:
        p.line((pointList[e[0]][0] * xscl, pointList[e[0]][1] * yscl),
               (pointList[e[1]][0] * xscl, pointList[e[1]][1] * yscl))
示例#30
0
 def draw_lines(self):
     for col in range(self.number_of_columns):
         line((col * self.resolution, 0), (col * self.resolution, height))
     for row in range(self.number_of_rows):
         line((0, row * self.resolution), (width, row * self.resolution))