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 """
def show(self): if (self.blinkCounter > 5): stroke(255, 0, 0) else: stroke(0, 0, 255) fill(0, 0, 255) circle((self.position.x, self.position.y), 10)
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))
def display_pointer(self, mass=40): stroke(255) fill(100) theta = self.velocity.angle with push_matrix(): translate(self.location.x, self.location.y) rotate_z(theta + PI / 2) triangle((0, -mass / 2), (-mass / 4, mass / 2), (mass / 4, mass / 2)) fill(0, 255, 0) circle((self.location.x, self.location.y), 5)
def show(self): if self.trail: self.xlist.append(self.pos.x) self.ylist.append(self.pos.y) p5.stroke(255, 255, 30) numberfromlast = 1000 numberfromlast += 1 for i in range(len(self.xlist[-numberfromlast:])): p5.point(self.xlist[-numberfromlast:][i], self.ylist[-numberfromlast:][i]) p5.stroke(0) p5.circle((self.pos.x, self.pos.y), self.d, mode="CENTER")
def display(self): stroke(255) fill(255) theta = self.velocity.angle with push_matrix(): translate(self.location.x, self.location.y) rotate_z(theta + PI / 2) triangle( (0, -self.mass / 2), (-self.mass / 4, self.mass / 2), (self.mass / 4, self.mass / 2), ) fill(0, 255, 0) circle((self.location.x, self.location.y), 5)
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))
def draw(): global perlx global perly perlx += 0.005 perly += 0.005 fill(remap(noise(perlx), (0, 1), (0, 255)), (255), (255), 100, color_mode="HSB") rect((width - 10, height), 10, -10, mode="CORNER") if mouse_is_pressed: fill(remap(noise(perlx), (0, 1), (0, 255)), (255), (255), 100, color_mode="HSB") else: fill(255, 15) circle_size = 25 * (noise(perlx, perly) + 1) circle((mouse_x, mouse_y), circle_size)
def draw(): # Arka alanı siyah yap p5.background(0) # Orijini (Yani (0, 0) noktasını) pencerenin ortasına taşı p5.translate(w / 2, h / 2) # Analog saatte, saat değerlerinin olduğu konumlara # kırmızı noktalar koymak için döngü # [0, 360) aralığında 30'ar derece açılarla değer oluştur: # Böylece 0, 30, 60, ..., 270, 300, 330 değerleri elde edilecek for i in range(0, 360, 30): # Her bir açı için x ve y konumlarını hesapla x = r * math.cos(math.radians(i)) y = r * math.sin(math.radians(i)) # Çizilecek nesnenin içini kırmızı renk ile doldur p5.fill(255, 0, 0) # Çizilecek nesne için çevre çizgisi çizme p5.no_stroke() # x ve y konumuna 15 piksel çapında bir daire çiz. p5.circle((x, y), 15) # Analog saatte, dakika değerlerinin olduğu konumlara # beyaz noktalar koymak için döngü # [0, 360) aralığında 6'şar derece açılarla değer oluştur: # Böylece 0, 6, 12, ..., 342, 348, 354 değerleri elde edilecek for u in range(0, 360, 6): # Eğer u açısı 30'a tm bölünebiliyorsa işlemi YAPMA if u % 30: # Her bir açı için x ve y konumlarını hesapla x = r * math.cos(math.radians(u)) y = r * math.sin(math.radians(u)) # Çizilecek nesnenin içini beyaz renk ile doldur p5.fill(255) # Çizilecek nesne için çevre çizgisi çizme p5.no_stroke() # x ve y konumuna 10 piksel çapında bir daire çiz. p5.circle((x, y), 10)
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))
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))
def show(self): stroke(0) circle((self.position.x, self.position.y), radius=10)
def show(self): p5.circle((self.pos.x, self.pos.y), self.d, mode="CENTER")
def render(self): circle((self.X, self.Y), self.size)
def show(self): stroke(255) circle((self.position.x, self.position.y), 10)
def render(self): p.fill(self.color) p.circle(self.pos, self.r)
def addCircle(self, x, y, r, color=WHITE): with p5.push_style(): p5.no_stroke() p5.fill(*color) p5.circle((x, y), 2*r)
def show(self): r = self.size stroke(255) # color white circle(self.pos, radius=r)
def show(self): p5.stroke(255) p5.stroke_weight(2) p5.fill(255, 100) p5.circle((self.pos.x, self.pos.y), 32)
def show(self): p5.circle((self.pos.x,self.pos.y),self.r*2)
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 draw(): global corner_handle p5.background(0) with p5.push_matrix(): p5.apply_matrix(canvas_surface.get_transform_mat()) # GIS shapes and objects if show_basemap: _gis.draw_basemap() if show_shapes: _gis.draw_polygon_layer(buildings, 0, 1, p5.Color(96, 205, 21), p5.Color(213, 50, 21), 'co2') _gis.draw_polygon_layer(typologiezonen, 0, 1, p5.Color(123, 201, 230, 50)) _gis.draw_linestring_layer(nahwaermenetz, p5.Color(217, 9, 9), 3) _gis.draw_polygon_layer(waermezentrale, 0, 1, p5.Color(252, 137, 0)) # find buildings intersecting with selected grid cells buildings['selected'] = False for y, row in enumerate(_grid.grid): for x, cell in enumerate(row): if cell.selected: # get viewport coordinates of the cell rectangle cell_vertices = _grid.surface.transform([[ _x, _y ] for _x, _y in [[x, y], [x + 1, y], [x + 1, y + 1], [x, y + 1]]]) ii = _gis.get_intersection_indexer( buildings, cell_vertices) buildings.loc[ii, 'selected'] = True # highlight selected buildings _gis.draw_polygon_layer(buildings[buildings.selected], p5.Color(255, 0, 127), 2, None) # grid if show_grid: _grid.draw(p5.Color(255, 255, 255), 1) # mask border = 1000 with p5.push_style(): p5.fill(p5.Color(0, 0, 0)) p5.rect(-border, -border, width + 2 * border, border) p5.rect(-border, height, width + 2 * border, height + border) p5.rect(-border, -border, border, height + 2 * border) p5.rect(width, -border, width + border, height + 2 * border) # get the drag handle (if the mouse hovers over it) corner_handle = canvas_surface.get_corner_handle(20) if corner_handle: with p5.push_style(): p5.no_stroke() p5.fill(p5.Color(255, 255, 255, 200)) p5.circle(list(corner_handle)[0], list(corner_handle)[1], 20)
def show(self): p5.stroke(255) p5.no_fill() p5.circle((self.pos.x,self.pos.y),self.r*2)
def render_fires(self): for fire in self.fires: p.fill(123) self.cash.append(((fire.y, fire.y + 7), (fire.x, fire.x + 7))) p.circle(fire, 10)
def show_boid(self): stroke(255) #white contour colors fill(0, 0, 255) #fill with blue circle((self.position[0], self.position[1]), radius=10)
def display_circle(self): self.set_colour() fill(self.colour) # no_stroke() circle((self.location.x, self.location.y), 15)
def ciz(self): """Bu metod, ekrana self.x ve self.'de self.r çapında bir daire çizer""" p5.circle((self.x, self.y), self.r)