I have an Pixel object like this:
class Pixel:
def __init__(self, screen, color, pos, size=8):
self.screen = screen
self.color = color
self.pos = pos
self.size = size
def update(self):
pygame.draw.circle(self.screen, self.color, self.pos, self.size)
And I want to create an output and looks like a circle made of those Pixel objects. So far, I've tried a program like this:
# PyMate
import pygame
from pygame.colordict import THECOLORS
from drawing import Pixel, Frame
frame = Frame((800, 650))
frames = [frame]
pixels = []
x, y = 50, 50
li = []
for i in range(1000):
li.append(Pixel(frames[0], THECOLORS["orange"], (x, y)))
if i % 500 == 0:
x -= 0.002
y -= 0.006
else:
y += 0.006
x += 0.002
pixels.extend(li)
frames.append(frame)
running = True
while running:
frame = Frame((800, 650))
frames.append(frame)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
for i in frames:
i.fill(THECOLORS["white"])
for i in pixels:
i.update()
del frame, frames[0]
pygame.display.update()
This kind of works, but it draws a straight line (not what I wanted). The part I'm really fouced on is this:
for i in range(1000):
li.append(Pixel(frames[0], THECOLORS["orange"], (x, y)))
if i % 500 == 0:
x -= 0.002
y -= 0.006
else:
y += 0.006
x += 0.002
The x and y changes don't seem to be right, the modulus number doesn't seem to be right either. What numbers could they be?
