예제 #1
0
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)

        self.players = []
        self.player = Player((9, 7), BLUE, self)

        self.level = level1
예제 #2
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = GREEN
     self.pos = (random.randint(1, self.width - 1),
                 random.randint(1, self.height - 1))
     self.speed = 1
     self.deltax, self.deltay = self.speed, self.speed
예제 #3
0
파일: Fft.py 프로젝트: TkkrLab/py-ledart
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)

        self.mode = kwargs.get('mode', 3)
        self.topcolor = kwargs.get('topcolor', GREEN)
        self.barcolor = kwargs.get('barcolor', BLUE)

        self.sample_rate = int(44100 / 4)
        self.chunk = self.width * 2
        self.no_channels = kwargs.get('channels', 1)

        self.stream = alsaaudio.PCM(alsaaudio.PCM_CAPTURE,
                                    alsaaudio.PCM_NORMAL)
        self.stream.setchannels(self.no_channels)
        self.stream.setrate(self.sample_rate)
        self.stream.setformat(alsaaudio.PCM_FORMAT_S16_LE)
        self.stream.setperiodsize(self.chunk)

        self.color_pallet = [c / self.height for c in range(self.height)]

        # self.window = numpy.bartlett(self.width)
        # self.window = numpy.blackman(self.width)
        # self.window = numpy.hamming(self.width)
        self.window = numpy.hanning(self.width)
        # self.window = numpy.kaiser(self.width, 0)
        # self.window = [1, ] * self.width

        self.fouriers = []
예제 #4
0
파일: Fft.py 프로젝트: TkkrLab/py-ledart
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)

        self.mode = kwargs.get('mode', 3)
        self.topcolor = kwargs.get('topcolor', GREEN)
        self.barcolor = kwargs.get('barcolor', BLUE)

        self.sample_rate = int(44100 / 4)
        self.chunk = self.width * 2
        self.no_channels = kwargs.get('channels', 1)

        self.stream = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NORMAL)
        self.stream.setchannels(self.no_channels)
        self.stream.setrate(self.sample_rate)
        self.stream.setformat(alsaaudio.PCM_FORMAT_S16_LE)
        self.stream.setperiodsize(self.chunk)

        self.color_pallet = [c / self.height for c in range(self.height)]

        # self.window = numpy.bartlett(self.width)
        # self.window = numpy.blackman(self.width)
        # self.window = numpy.hamming(self.width)
        self.window = numpy.hanning(self.width)
        # self.window = numpy.kaiser(self.width, 0)
        # self.window = [1, ] * self.width

        self.fouriers = []
예제 #5
0
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)

        self.players = []
        self.player = Player((9, 7), BLUE, self)

        self.level = level1
예제 #6
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = GREEN
     self.pos = (random.randint(1, self.width - 1),
                 random.randint(1, self.height - 1))
     self.speed = 1
     self.deltax, self.deltay = self.speed, self.speed
예제 #7
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.ripples = []
     for i in range(0, 4):
         x, y = random.randint(0,
                               self.width), random.randint(0, self.height)
         self.ripples.append(Ripple((x, y), BLUE, self))
예제 #8
0
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)
        self.background = Graphics(**kwargs)

        self.life = Life(self.width, self.height, 1, WHITE)
        self.step = kwargs.get('decay', 4)
        self.color_step = (self.step, self.step, self.step)

        self.fill(WHITE)
예제 #9
0
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)
        self.background = Graphics(**kwargs)

        self.life = Life(self.width, self.height, 1, WHITE)
        self.step = kwargs.get('decay', 4)
        self.color_step = (self.step, self.step, self.step)
        
        self.fill(WHITE)
예제 #10
0
파일: Plasma.py 프로젝트: TkkrLab/py-ledart
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)
        speed = kwargs.get('speed', 0.1)
        self.fill(BLACK)
        self.palet = PaletGenerate()
        self.offset = 10
        self.speed = speed

        self.surfaceSize = len(self)
        self.timer = Timer(self.speed)
        self.time = 0
        self.palet = PaletGenerate()
        self.c = self.palet.colorFade()
예제 #11
0
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)
        self.rule = kwargs.get("rule", random.randint(0, 0xff))
        self.scrolling = kwargs.get("scrolling", True)
        self.refresh_time = kwargs.get("refreshtime", 6.0)
        self.color = kwargs.get("color", BLUE)

        # start scan at second line. since we scan what's above it.
        self.hpos = 1
        self.height_range = range(1, self.height)
        # seed first line
        # self.create_random_row(0)
        self.draw_pixel(self.width / 2, 0, self.color)
        # timer for refreshing the screen.
        self.refresh_timer = Timer(self.refresh_time)
예제 #12
0
class CProgressedLife(Graphics):
    '''
    brighten spots with prolonged cell life,
    while darken spots where there is less cell life
    and color it accordingly 
    '''
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)
        self.background = Graphics(**kwargs)

        self.life = Life(self.width, self.height, 1, WHITE)
        self.step = kwargs.get('decay', 4)
        self.color_step = (self.step, self.step, self.step)
        
        self.fill(WHITE)

    def draw(self):
        for i, point in enumerate(self.background.get_points()):
            color = self.background[point]
            if self.life.field[i]:
                color = ColorRGBOps.brighten(color, self.step)
            else:
                color = ColorRGBOps.darken(color, self.step)
            self.background[point] = color
            shade = color[0] / 256.
            color = [int(c * 0xff) for c in colorsys.hsv_to_rgb(1 - shade, 1, shade)]
            self[point] = color

    def generate(self):
        self.life.process()
        self.draw()
예제 #13
0
class CProgressedLife(Graphics):
    '''
    brighten spots with prolonged cell life,
    while darken spots where there is less cell life
    and color it accordingly 
    '''
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)
        self.background = Graphics(**kwargs)

        self.life = Life(self.width, self.height, 1, WHITE)
        self.step = kwargs.get('decay', 4)
        self.color_step = (self.step, self.step, self.step)

        self.fill(WHITE)

    def draw(self):
        for i, point in enumerate(self.background.get_points()):
            color = self.background[point]
            if self.life.field[i]:
                color = ColorRGBOps.brighten(color, self.step)
            else:
                color = ColorRGBOps.darken(color, self.step)
            self.background[point] = color
            shade = color[0] / 256.
            color = [
                int(c * 0xff)
                for c in colorsys.hsv_to_rgb(1 - shade, 1, shade)
            ]
            self[point] = color

    def generate(self):
        self.life.process()
        self.draw()
예제 #14
0
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)

        self.mode = kwargs.get('mode', 3)
        
        self.sample_rate = int(44100 / 4)
        self.chunk = self.width * 2
        self.no_channels = 1
        self.average_size = 10

        self.stream = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NORMAL)
        self.stream.setchannels(self.no_channels)
        self.stream.setrate(self.sample_rate)
        self.stream.setformat(alsaaudio.PCM_FORMAT_S16_LE)
        self.stream.setperiodsize(self.chunk)

        self.chunks = []
예제 #15
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = BLUE
     x = random.randint(1, self.width - 1)
     y = random.randint(1, self.height - 1)
     self.pos = x, y
     self.speed = 1
     self.deltax, self.deltay = 0, 0
     self.body = []
     # add our head to our body :)
     self.body.append(self.pos)
     self.player1 = TronPlayer(BLUE, self)
     self.player1.update(self)
     self.player1.draw()
     pygame.init()
     self.window = pygame.display.set_mode((80, 60))
     self.debug = False
예제 #16
0
파일: Plasma.py 프로젝트: TkkrLab/py-ledart
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)
        self.plasma = Graphics(surface=self)

        self.x_range = range(0, self.width, 1)
        self.y_range = range(0, self.height, 1)

        self.speed = kwargs.get('speed', 1)
        self.interval = 1000 / self.speed
        self.time = random.randint(0, 100)
        self.previousTick = 0
        self.plasma_width = kwargs.get('plasma_width', 5)

        self.angle = 0

        self.generatePalette()
        self.generatePlasmaSurface()
예제 #17
0
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)

        blue = ColorRGBOps.darken(BLUE, 128)
        green = ColorRGBOps.darken(GREEN, 128)
        red = ColorRGBOps.darken(RED, 128)

        self.life1 = Life(self.width, self.height, 1, color=BLUE)
        self.life2 = Life(self.width, self.height, 1, color=green)
        self.life3 = Life(self.width, self.height, 1, color=red)

        self.step = int(0xff/10)

        self.step_red = (self.step, 0, 0)
        self.step_green = (0, self.step, 0)
        self.step_blue = (0, 0, self.step)

        self.index = 0
예제 #18
0
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)

        self.mode = kwargs.get('mode', 3)

        self.sample_rate = int(44100 / 4)
        self.chunk = self.width * 2
        self.no_channels = 1
        self.average_size = 10

        self.stream = alsaaudio.PCM(alsaaudio.PCM_CAPTURE,
                                    alsaaudio.PCM_NORMAL)
        self.stream.setchannels(self.no_channels)
        self.stream.setrate(self.sample_rate)
        self.stream.setformat(alsaaudio.PCM_FORMAT_S16_LE)
        self.stream.setperiodsize(self.chunk)

        self.chunks = []
예제 #19
0
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)

        blue = ColorRGBOps.darken(BLUE, 128)
        green = ColorRGBOps.darken(GREEN, 128)
        red = ColorRGBOps.darken(RED, 128)

        self.life1 = Life(self.width, self.height, 1, color=BLUE)
        self.life2 = Life(self.width, self.height, 1, color=green)
        self.life3 = Life(self.width, self.height, 1, color=red)

        self.step = int(0xff / 10)

        self.step_red = (self.step, 0, 0)
        self.step_green = (0, self.step, 0)
        self.step_blue = (0, 0, self.step)

        self.index = 0
예제 #20
0
파일: Pong.py 프로젝트: TkkrLab/py-ledart
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)

        # create a ball. multiple balls should be possible :)
        bcolor = kwargs.get('bcolor', GREEN)
        self.ball = Ball((self.get_width() / 2,
                          self.get_height() / 2),
                         bcolor, self)

        # try to use the controller.
        # but if it's not available use the automatic one.
        select = kwargs.get('select', (autocontroller, autocontroller))
        s1, s2 = select
        try:
            firstcontroler = controllers[s1]
            self.controller1 = firstcontroler(plugged=s1, ball=self.ball)
            secondcontroler = controllers[s2]
            self.controller2 = secondcontroler(plugged=s2, ball=self.ball)

        except Exception as e:
            fmt = (e, )
            fmtstr = "unable to find controllers playing on automatic\n>> %s\n"
            print(fmtstr % fmt)
            self.controller1 = PongControllerAuto(plugged=s1, ball=self.ball)
            self.controller2 = PongControllerAuto(plugged=s2, ball=self.ball)

        # create two paddles
        pcolor = kwargs.get('pcolor', BLUE)
        paddle1_pos = (0, 0)
        self.paddle1 = (Paddle(paddle1_pos, pcolor, self.controller1,
                        self.controller1.LTHUMB_X, self))
        paddle2_pos = (0, self.width - 1)
        self.paddle2 = (Paddle(paddle2_pos, pcolor, self.controller2,
                        self.controller2.RTHUMB_X, self))

        # timing variables used to controle the speed of the ball
        speed = kwargs.get('speed', self.height / 2)
        self.start_speed = speed
        # speed = pixels/s
        self.speed = speed
        self.previous = 0
        self.print_score = False

        self.count = count(0, 1)
예제 #21
0
파일: Pong.py 프로젝트: TkkrLab/py-ledart
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)

        # create a ball. multiple balls should be possible :)
        bcolor = kwargs.get('bcolor', GREEN)
        self.ball = Ball((self.get_width() / 2, self.get_height() / 2), bcolor,
                         self)

        # try to use the controller.
        # but if it's not available use the automatic one.
        select = kwargs.get('select', (autocontroller, autocontroller))
        s1, s2 = select
        try:
            firstcontroler = controllers[s1]
            self.controller1 = firstcontroler(plugged=s1, ball=self.ball)
            secondcontroler = controllers[s2]
            self.controller2 = secondcontroler(plugged=s2, ball=self.ball)

        except Exception as e:
            fmt = (e, )
            fmtstr = "unable to find controllers playing on automatic\n>> %s\n"
            print(fmtstr % fmt)
            self.controller1 = PongControllerAuto(plugged=s1, ball=self.ball)
            self.controller2 = PongControllerAuto(plugged=s2, ball=self.ball)

        # create two paddles
        pcolor = kwargs.get('pcolor', BLUE)
        paddle1_pos = (0, 0)
        self.paddle1 = (Paddle(paddle1_pos, pcolor, self.controller1,
                               self.controller1.LTHUMB_X, self))
        paddle2_pos = (0, self.width - 1)
        self.paddle2 = (Paddle(paddle2_pos, pcolor, self.controller2,
                               self.controller2.RTHUMB_X, self))

        # timing variables used to controle the speed of the ball
        speed = kwargs.get('speed', self.height / 2)
        self.start_speed = speed
        # speed = pixels/s
        self.speed = speed
        self.previous = 0
        self.print_score = False

        self.count = count(0, 1)
예제 #22
0
파일: Snake.py 프로젝트: TkkrLab/py-ledart
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)

        self.select = kwargs.get('select', 0)
        self.controller = controllers[self.select]()

        self.body_color = GREEN
        self.head_color = BLUE

        x = random.randint(1, self.width - 1)
        y = random.randint(1, self.height - 1)
        self.pos = x, y
        self.speed = kwargs.get('speed', 8)
        self.original_speed = self.speed
        self.previousTick = 0
        self.deltax, self.deltay = 0, 0

        self.body = []
        self.tailLen = 0
        self.food = Food((0, 0), WHITE, self)
        self.food.randPos()

        # add our head to our body :)
        self.body.append(self.pos)
예제 #23
0
파일: Snake.py 프로젝트: TkkrLab/py-ledart
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)

        self.select = kwargs.get('select', 0)
        self.controller = controllers[self.select]()

        self.body_color = GREEN
        self.head_color = BLUE

        x = random.randint(1, self.width - 1)
        y = random.randint(1, self.height - 1)
        self.pos = x, y
        self.speed = kwargs.get('speed', 8)
        self.original_speed = self.speed
        self.previousTick = 0
        self.deltax, self.deltay = 0, 0

        self.body = []
        self.tailLen = 0
        self.food = Food((0, 0), WHITE, self)
        self.food.randPos()

        # add our head to our body :)
        self.body.append(self.pos)
예제 #24
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = BLUE
     self.fill(self.color)
예제 #25
0
파일: Water.py 프로젝트: TkkrLab/py-ledart
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.ripples = []
     for i in range(0, 4):
         x, y = random.randint(0, self.width), random.randint(0, self.height)
         self.ripples.append(Ripple((x, y), BLUE, self))
예제 #26
0
 def draw_pixel(self, x, y, color):
     color = [int(c * 0xff) for c in colorsys.hsv_to_rgb(y / float(self.height), 1, 1)]
     Graphics.draw_pixel(self, x, y, color)
예제 #27
0
파일: Plasma.py 프로젝트: TkkrLab/py-ledart
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.plasma = Graphics(surface=self)
     self.tshift = 0.0
     self.cshift = 0.0
예제 #28
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.life = Life(self.width, self.height, 1)
     self.color = kwargs.get('color', BLUE)
예제 #29
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = CYAN
     self.rect_size = self.width
     self.pos = 0, 0
예제 #30
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = kwargs.get('color', (80, 255, 100))
     self.chance = kwargs.get('chance', 0.04)
     # insert single drop for testing
     self.drops = [RainDrop(self, self.color)]
예제 #31
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = (123, 111, 222)
예제 #32
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.fill(BLUE)
예제 #33
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = RED
     self.pos = 0,0
     self.vertical = True
     self.horizontal = False
예제 #34
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = YELLOW
     self.pos = 0, 0
예제 #35
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.life = Life(self.width, self.height, 1, color=BLACK)
예제 #36
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = CYAN
     self.rect_size = self.width
     self.pos = 0, 0
예제 #37
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.radius = 0
     self.direction = 1
     self.color = RED
예제 #38
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.life = Life(self.width, self.height, 1)
     self.color = kwargs.get('color', BLUE)
예제 #39
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.life = Life(self.width, self.height, 1, color=BLACK)
예제 #40
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = (123, 111, 222)
예제 #41
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = RED
     self.pos = 0, 0
     self.vertical = True
     self.horizontal = False
예제 #42
0
파일: Plasma.py 프로젝트: TkkrLab/py-ledart
class RevolvingCircle(Graphics):
    def __init__(self, **kwargs):
        Graphics.__init__(self, **kwargs)
        self.plasma = Graphics(surface=self)

        self.x_range = range(0, self.width, 1)
        self.y_range = range(0, self.height, 1)

        self.speed = kwargs.get('speed', 1)
        self.interval = 1000 / self.speed
        self.time = random.randint(0, 100)
        self.previousTick = 0
        self.plasma_width = kwargs.get('plasma_width', 5)

        self.angle = 0

        self.generatePalette()
        self.generatePlasmaSurface()

    def generatePalette(self):
        self.palette = []
        pal = PaletGenerate()
        for x in range(0, 0xff * 3, 1):
            color = pal.colorFade()
            r, g, b = color
            colorRGB = (r, g, b)
            self.palette.append(colorRGB)
        # print self.palette[0], self.palette[len(self.palette) - 1]

    def generatePlasmaSurface(self):
        self.angle = int(self.time / self.speed)
        x_offset = (self.width * sin(radians(self.angle)) +
                    self.width * sin(radians(self.angle)))
        y_offset = (self.height * cos(radians(self.angle)) +
                    self.height * cos(radians(self.angle)))
        for y in self.y_range:
            for x in self.x_range:
                c = int((0x7f * sin(sqrt(float((x + x_offset) /
                         self.plasma_width *
                        (x + x_offset) / self.plasma_width +
                        (y + y_offset) / self.plasma_width *
                        (y + y_offset) / self.plasma_width
                        )))))
                color = (abs(c),) * 3
                self.plasma.draw_pixel(x, y, color)

    def process(self):
        millis = round(time.time() * 1000)
        if((millis - self.previousTick) >= self.interval):
            self.previousTick = time.time()
            self.time += 1

    def draw(self):
        paletteShift = self.time / self.speed
        self.generatePlasmaSurface()
        for y in self.y_range:
            for x in self.x_range:
                plasma_color = self.plasma.read_pixel(x, y)
                color_shift = self.palette[int(paletteShift % len(self.palette))]
                r = (plasma_color[0] + color_shift[0]) % (len(self.palette))
                g = (plasma_color[1] + color_shift[1]) % (len(self.palette))
                b = (plasma_color[2] + color_shift[2]) % (len(self.palette))
                color = (r, g, b,)
                # darken the color to create a better contrast
                color = ColorRGBOps.darken(color, 50)
                self.draw_pixel(x, y, color)

    def generate(self):
        self.fill(BLACK)
        self.process()
        self.draw()
예제 #43
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.color = YELLOW
     self.pos = 0, 0
예제 #44
0
파일: Fft.py 프로젝트: TkkrLab/py-ledart
 def draw_pixel(self, x, y, color):
     color = [
         int(c * 0xff)
         for c in colorsys.hsv_to_rgb(y / float(self.height), 1, 1)
     ]
     Graphics.draw_pixel(self, x, y, color)
예제 #45
0
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     self.radius = 0
     self.direction = 1
     self.color = RED
예제 #46
0
파일: Plasma.py 프로젝트: TkkrLab/py-ledart
 def __init__(self, **kwargs):
     Graphics.__init__(self, **kwargs)
     speed = kwargs.get('speed', 4)
     self.fill(BLACK)
     self.palet = PaletGenerate()
     self.speed = speed