(self, frame:list, lights:list, cam)
| 35 | particle[2] = (particle[2] - self.position[2]) % self.size + self.position[2] |
| 36 | |
| 37 | def add_to_frame(self, frame:list, lights:list, cam) -> list: |
| 38 | |
| 39 | for particle in self.particles: |
| 40 | x = particle[0] - cam.x |
| 41 | y = particle[1] - cam.y |
| 42 | z = particle[2] - cam.z |
| 43 | x, y, z = ( |
| 44 | x * cam.rotation[0][0] + y * cam.rotation[0][1] + z * cam.rotation[0][2], |
| 45 | x * cam.rotation[1][0] + y * cam.rotation[1][1] + z * cam.rotation[1][2], |
| 46 | x * cam.rotation[2][0] + y * cam.rotation[2][1] + z * cam.rotation[2][2], |
| 47 | ) |
| 48 | if z <= cam.z_near: |
| 49 | continue |
| 50 | |
| 51 | x2d = cam.width // 2 + int(x * cam.rendering_plane_z / z) |
| 52 | y2d = cam.height // 2 - int(y * cam.rendering_plane_z / z) |
| 53 | if not (0 <= x2d < cam.width and 0 <= y2d < cam.height): |
| 54 | continue |
| 55 | |
| 56 | |
| 57 | for light in lights: |
| 58 | distance_2 = (x - light.x_in_cam) * (x - light.x_in_cam) + (y - light.y_in_cam) * (y - light.y_in_cam) + (z - light.z_in_cam) * (z - light.z_in_cam) |
| 59 | if distance_2 < 400: |
| 60 | frame[y2d][x2d] = (min(255, int(frame[y2d][x2d][0] + 50 / distance_2)), |
| 61 | min(255, int(frame[y2d][x2d][1] + 50 / distance_2)), |
| 62 | min(255, int(frame[y2d][x2d][2] + 50 / distance_2))) |
| 63 | return frame |
| 64 | |
| 65 | |
| 66 |
nothing calls this directly
no outgoing calls
no test coverage detected