当前位置: 首页>>代码示例>>Python>>正文


Python Graphics.Graphics类代码示例

本文整理汇总了Python中Tools.Graphics.Graphics的典型用法代码示例。如果您正苦于以下问题:Python Graphics类的具体用法?Python Graphics怎么用?Python Graphics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Graphics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GraphicsCircleTest

class GraphicsCircleTest(object):
    def __init__(self):
        self.graphics = Graphics(matrix_width, matrix_height)
        self.radius = 0
        self.direction = 1
        self.color = RED

    def generate(self):
        # clear the drawing surface
        self.graphics.fill(BLACK)
        # put a circle on our surface
        self.graphics.drawCircle(matrix_width / 2, matrix_height / 2,
                                 self.radius, self.color)

        # circle grows and shrinks based on direction.
        if self.direction:
            self.radius += 1
        else:
            self.radius -= 1

        # if the circle is to big or to small inverse growth direction.
        if self.radius >= (matrix_height / 2) or self.radius <= 0:
            self.direction = not self.direction

        # get the surface drawn
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:26,代码来源:GraphicsTests.py

示例2: VuFlash

class VuFlash(object):
    def __init__(self):
        self.graphics = Graphics(matrix_width, matrix_height)
        self.graphics.fill(BLUE)
        self.p = pyaudio.PyAudio()
        self.stream = self.p.open(format=audio_params[0],
                                  channels=audio_params[1],
                                  rate=audio_params[2],
                                  input=audio_params[3],
                                  output=audio_params[4],
                                  frames_per_buffer=audio_params[5]
                                  )
        self.color = BLUE

    def getaudio(self):
        try:
            raw = self.stream.read(audio_params[5])
        except IOError as e:
            if e[1] != pyaudio.paInputOverFlowed:
                raise
            else:
                print("Warning: audio input buffer overflow")
            raw = '\x00' * self.audio_params[5]
        return np.array(np.frombuffer(raw, np.int16), dtype=np.float64)

    def generate(self):
        audio = self.getaudio()
        rmsed = translate(rms(audio), 0, 0xffff/5, 0, matrix_height)
        self.color = interp_color(rms(audio/10000))
        self.color = color_convert(self.color)
        self.graphics.fill(self.color)
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:32,代码来源:VuOther.py

示例3: Capture

class Capture(object):
    def __init__(self):
        self.graphics = Graphics(matrix_height, matrix_width)

    def generate(self):
        self.graphics.fill(BLACK)
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:7,代码来源:Capture.py

示例4: TestPattern

class TestPattern(object):
    def __init__(self):
        self.graphics = Graphics(matrix_width, matrix_height)
    
    def generate(self):
        self.graphics.fill(WHITE)
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:7,代码来源:testingLedSign.py

示例5: Test

class Test(object):
    def __init__(self):
        self.graphics = Graphics(matrix_width, matrix_height)
        self.x = 0
        self.y = 0
        self.color = GREEN
        self.phase = 1
        self.timer = Timer(1 / 30.)
        self.wave_range = 1
        self.wave_step = 1
        self.amplitude = 4
        self.offset = matrix_width / 2
        self.freq = 1. / matrix_height * 8
        self.controlled = True
        self.mc = MidiController()

    def generate(self):
        self.graphics.fill(BLACK)
        if self.timer.valid():
            self.phase += 1
        for i in range(0, self.wave_range, self.wave_step):
            for self.y in range(0, matrix_height):
                if self.controlled:
                    self.freq = self.mc.getButton(0, 0) / 126.
                    self.amplitude = self.mc.getButton(0, 1)
                    self.timer.set_interval(self.mc.getButton(0, 2) / 126.)
                self.x = math.sin(self.y * self.freq + self.phase
                                  ) * self.amplitude + self.offset + i
                b = translate(i, 0, matrix_width, 0, 50)
                g = translate(self.y, 0, matrix_height, 0, 80)
                r = translate(self.x, 0, 12, 0, 24)
                self.color = (255, 0, 0)
                self.graphics.drawPixel(self.x, self.y, self.color)
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:34,代码来源:ScrollingSineWave.py

示例6: DisplayPng

class DisplayPng(object):
    def __init__(self):
        # image = '/home/robert/py-artnet/hacked.png'
        # self.data = getPngPixelData(image)
        # self.pixeldata = self.data[0]
        self.graphics = Graphics(matrix_width, matrix_height)

    def generate(self):
        self.graphics.fill(BLACK)
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:10,代码来源:DisplayPng.py

示例7: GraphicsDotTest

class GraphicsDotTest(object):
    def __init__(self):
        self.graphics = Graphics(matrix_width, matrix_height)
        self.color = (123, 111, 222)

    def generate(self):
        self.graphics.fill(BLACK)
        for i in range(0, 5):
            self.graphics.drawPixel(i, i, self.color)
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:10,代码来源:GraphicsTests.py

示例8: GrayedLife

class GrayedLife(object):
    '''
    take the gray scales over every point and
    add or subtract depening on if alive or not
    '''
    def __init__(self):
        self.graphics = Graphics(matrix_width, matrix_height)
        self.graphics.fill(BLUE)

    def generate(self):
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:11,代码来源:PixelLife.py

示例9: PatternDummy

class PatternDummy(object):
    def __init__(self):
        self.graphics = Graphics(matrix_width, matrix_height)
        self.color = BLACK
        self.graphics.fill(self.color)

    def generate(self):
        return self.graphics.getSurface()

    def __del__(self):
        del self
开发者ID:ozel,项目名称:py-artnet,代码行数:11,代码来源:Gui.py

示例10: SegmentClock

class SegmentClock(object):
    def __init__(self):
        self.graphics = Graphics(matrix_width, matrix_height)
        self.segmentdisp = SegmentDisplay(self.graphics)

    def generate(self):
        self.graphics.fill(BLACK)
        hour = time.localtime().tm_hour
        minutes = time.localtime().tm_min
        self.segmentdisp.drawnumbers(1, 0, hour, 2)
        self.segmentdisp.drawnumbers(1, matrix_height / 2 + 1, minutes, 2)
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:12,代码来源:SegmentClockDigitColor.py

示例11: VUmetertwo

class VUmetertwo(object):
    def __init__(self):
        self.graphics = Graphics(matrix_width, matrix_height)
        self.controller = AudioController(channel=1, rate=256000, period=64)
        self.color = BLUE
        self.inputlength = matrix_height
        self.inputs = []
        self.offset = 13
        self.max = 1250
        self.lim = self.max
        self.rate = 10

    def getaverageof(self, number):
        averages = []
        for i in range(0, number):
            data = self.controller.getinput()
            while(data is None):
                data = self.controller.getinput()
            averages.append(data)
        sums = 0
        for num in averages:
            sums += num
        return int(sums / len(averages))

    def getinputs(self):
        self.inputs = []
        sums = 0
        for input in range(0, self.inputlength):
            data = self.getaverageof(3)
            self.inputs.append(data)
            sums += data
        return sums / len(self.inputs)

    def generate(self):
        average = self.getinputs()
        self.graphics.fill(BLACK)
        for i, line in enumerate(self.inputs):
            if line > self.max:
                self.max = line
            else:
                if self.max <= self.lim:
                    self.max = self.lim
                else:
                    self.max -= int((self.max - self.lim) / self.rate)
            length = int(translate(average, 0, self.max, 0, matrix_height))
            data = int(translate(line, 0, average, 0, length))
            if data > 0xff:
                self.data = 0xff
            if data > self.max:
                self.max = data
            self.graphics.drawLine(0, i, data - self.offset, i, self.color)
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:52,代码来源:Vumeter.py

示例12: SegmentClocked

class SegmentClocked(object):
    def __init__(self):
        self.graphics = Graphics(matrix_width, matrix_height)
        self.segmentdisp = SegmentDisplay(self.graphics)
        self.previous = 1

    def generate(self):
        self.graphics.fill(BLACK)
        current = time.time()
        fps = int(1. / (current - self.previous))
        self.segmentdisp.drawnumbers(0, 0, fps, 4)
        self.previous = time.time()
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:13,代码来源:SegmentClockDigitColor.py

示例13: __init__

    def __init__(self, speed=20):
        self.graphics = Graphics(matrix_width, matrix_height)
        self.plasma = Graphics(matrix_width, matrix_height)
        
        self.x_range = xrange(0, matrix_width, 1)
        self.y_range = xrange(0, matrix_height, 1)

        self.interval = .1/speed #interval/speed is how many ticks a second.
        self.time = 0
        self.previousTick = 0

        self.generatePalette()
        self.generatePlasmaSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:13,代码来源:Plasma.py

示例14: VUmeterThree

class VUmeterThree(object):
    def __init__(self):
        self.graphics = Graphics(matrix_width, matrix_height)
        self.controller = AudioController(channel=1, rate=16000, period=64)
        self.max = 1

    def generate(self):
        self.graphics.fill(BLACK)
        data = getaverageof(10, self.controller)
        data = int(translate(data, 0, 700, 0, 8))
        for i in range(0, 17):
            self.graphics.drawLine(0, i, data - 10, 0, BLUE)
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:13,代码来源:Vumeter.py

示例15: SegmentCounter

class SegmentCounter(object):
    def __init__(self):
        self.graphics = Graphics(matrix_width, matrix_height)
        self.timer = Timer(1 / 30.)
        self.number = 0
        self.segmentdisp = SegmentDisplay(self.graphics)

    def generate(self):
        self.graphics.fill(BLACK)
        if self.timer.valid():
            self.number += 1
        self.segmentdisp.drawnumbers(0, 0, self.number, 4)
        return self.graphics.getSurface()
开发者ID:ozel,项目名称:py-artnet,代码行数:13,代码来源:SegmentDisplayTwo.py


注:本文中的Tools.Graphics.Graphics类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。