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 draw_house(self): p5.rect((self.x - self.size / 2, self.y), self.size, self.size) p5.triangle( (self.x - self.size, self.y), (self.x + self.size, self.y), (self.x, self.y - self.size), )
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))
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): 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)
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 show(self): stroke(255) # point(self.position.x, self.position.y) direction = self.velocity.copy() direction.magnitude = 7 head = self.position + direction angle = 2 * math.pi / 3 port = self.velocity.copy() port.rotate(angle) port.magnitude = 3 port += self.position starboard = self.velocity.copy() starboard.rotate(-angle) starboard.magnitude = 3 starboard += self.position triangle(head, port, starboard)
def tri(length): p.no_fill() p.triangle((0, -length),(-length*m.sqrt(3)/2, length/2),(length*m.sqrt(3)/2, length/2))
def draw_pointer(self): p5.triangle( (self.x, self.y), (self.x - 10, self.y + 30), (self.x + 10, self.y + 30) )
def show(self): #making boid as a equilateral triangle triangle( (self.position.x, self.position.y), ((self.position.x + 10), (self.position.y + 10 * math.sqrt(3))), ((self.position.x + 20), (self.position.y)))