Пример #1
0
 def draw(self, light, **params):
     ret = Buffer()
     pos = Position()
     pos.x = int(abs(ret.w - self.mask.w) / 2)
     pos.y = int(abs(ret.h - self.mask.h) / 2)
     ret.addMask(self.mask, light=light, pos=pos)
     return ret
Пример #2
0
    def draw(self, stamp, back, invert, **params):

        self.buffer = Buffer()

        front = self.tunnel.buffer(off=0.)
        if invert:
            self.buffer.add(front.addMask(self.mask, light=DARK))
        else:
            self.buffer.add(front.addMask(self.mask.inverse(), light=DARK))

        if back:
            back = self.tunnel.buffer(off=0.5)
            self.buffer.add(back.addMask(self.mask.inverse(), light=DARK))

        return self.buffer
Пример #3
0
    def start(self, style, pattern, step, flip, light, **params):
        info("start test {:}".format(pattern))

        self.tunnel = dotlife.tunnel.Tunnel(duration=self.timer.duration,
                                            radius=5. / 8.)

        self.render, = style.value

        self.life = dotlife.life.Life(size=FRAMESIZE)

        mask = pattern.Mask(flip=flip, step=step)
        debug(str(mask))

        self.life.spawn(pattern, pos=None)
        self.buffer = Buffer().addMask(self.life, light=light)

        return True
Пример #4
0
class Test(Mode):

    Pattern = dotlife.life.Pattern

    Style = Style
    DefaultStyle = Style.none

    def start(self, style, pattern, step, flip, light, **params):
        info("start test {:}".format(pattern))

        self.tunnel = dotlife.tunnel.Tunnel(duration=self.timer.duration,
                                            radius=5. / 8.)

        self.render, = style.value

        self.life = dotlife.life.Life(size=FRAMESIZE)

        mask = pattern.Mask(flip=flip, step=step)
        debug(str(mask))

        self.life.spawn(pattern, pos=None)
        self.buffer = Buffer().addMask(self.life, light=light)

        return True

    def step(self, style, light, **params):
        self.life.step()
        self.buffer = Buffer().addMask(self.life, light=light)

    def draw(self, style, pattern, step, light, **params):
        c = 0
        #        debug("draw life {:}#{:d}".format(pattern,c))

        self.buffer = self.render(self)
        return self.buffer.addMask(self.life, light=light)

#        return self.buffer
#
#        pos = Buffer().centerForMask(self.mask)
#        buf = Buffer().addMask(self.mask,light=light,pos=pos)
#        return buf

    flags = [
        Mode.FLAG("step"),
        Mode.FLAG("flip"),
        Mode.FLAG("style", DefaultStyle),
        Mode.FLAG("pattern", Pattern.glider),
        ("l:", "light=", "light", 1, "brightness", lambda x: int(x)),
    ]
Пример #5
0
    def draw(self,style,**params):

        pal = self.palette.value
        c = 16
        c = self.timer.count % pal.length

        buffer = Buffer()
        
        if style == Style.all:
            for y in range(int(buffer.h/2)):
                for x in range(buffer.w):
                    buffer[x,y+int(buffer.h/4)] = pal[c]
                    c += 1
                    c %= pal.length
        elif style == Style.fade:
            buffer = Buffer(size=FRAMESIZE,val=pal[c])
        elif style == Style.scroll:
            for y in range(buffer.h):
                for x in range(buffer.w):
                    buffer[x,y] = pal[c]
                c += 1
                c %= pal.length
                            
        return buffer
Пример #6
0
    def draw(self,back,step,**params):

        ret = Buffer()
        front = self.plasma.buffer(off=0)
        ret.add(front.addMask(self.mask,light=DARK))
        
        if back:
           back = self.plasma.buffer(off=PI/2.)
           ret.add(back.addMask(self.mask.inverse(), light=DARK))


        return ret
Пример #7
0
    def draw(self, **params):
        ret = Buffer()
        palette0 = Palette.Sine(amp=31, bias=1.)
        palette1 = Palette.Sine(amp=31, bias=1., phase=1. * PI / 6.)
        palette2 = Palette.Sine(amp=31, bias=1., phase=2. * PI / 6.)
        palette3 = Palette.Sine(amp=31, bias=1., phase=3. * PI / 6.)
        palette4 = Palette.Sine(amp=31, bias=1., phase=4. * PI / 6.)
        palette5 = Palette.Sine(amp=31, bias=1., phase=5. * PI / 6.)

        #        palette0 = Palette(color=[DARK])
        #        palette1 = Palette(color=[LIGHT])
        #        palette2 = Palette(color=[LIGHT])
        #        palette3 = Palette(color=[DARK])
        #        palette4 = Palette(color=[DARK])
        #        palette5 = Palette(color=[DARK])

        c = self.timer.count
        shade = [
            palette2.item(c),
            palette3.item(c),
            palette4.item(c),
            palette5.item(c),
            palette0.item(c),
            palette1.item(c),
            palette1.item(c),
            palette1.item(c),
        ]

        center = Position(0, 0)
        #        center.x += 2
        #       center.y += -2
        for y in range(FRAMESIZE.h):
            for x in range(FRAMESIZE.w):
                s = Draft.ring(x, y, center)
                ret[x, y] = shade[s % len(shade)]

        return ret
Пример #8
0
 def step(self, style, light, **params):
     self.life.step()
     self.buffer = Buffer().addMask(self.life, light=light)
Пример #9
0
class Style(Enum):
    none = lambda x: Buffer(),
    tunnel = lambda x: x.tunnel.buffer(),
Пример #10
0
 def draw(self,light,**params):
     ret = Buffer()
     ret.addMask( self.mask, light=light )
     return ret
Пример #11
0
class Clock(Mode):

    Style = dotlife.clock.Style
    DefaultStyle = dotlife.clock.Style.large

    def start(self, stamp, **params):

        self.now = datetime.datetime.now()
        if stamp != "":
            self.now = datetime.datetime.fromisoformat(stamp)
            self.start = datetime.datetime.now()

        info("start clock: {:s}".format(self.now.strftime("%F %T")))

        self.mask = self.render(size=FRAMESIZE, now=self.now)

        radius = 5. / 8.
        self.tunnel = dotlife.tunnel.Tunnel(duration=self.timer.duration,
                                            radius=radius)

        return True

    def step(self, stamp, **params):
        info("FIRE")
        if stamp != "":
            self.now = datetime.datetime.fromisoformat(stamp) + (
                datetime.datetime.now() - self.start)
        else:
            self.now = datetime.datetime.now()

        self.mask = self.render(size=FRAMESIZE, now=self.now)

    def draw(self, stamp, back, invert, **params):

        self.buffer = Buffer()

        front = self.tunnel.buffer(off=0.)
        if invert:
            self.buffer.add(front.addMask(self.mask, light=DARK))
        else:
            self.buffer.add(front.addMask(self.mask.inverse(), light=DARK))

        if back:
            back = self.tunnel.buffer(off=0.5)
            self.buffer.add(back.addMask(self.mask.inverse(), light=DARK))

        return self.buffer

    def render(self, size, now):
        ret = Mask(size=size)
        _, _, _, hour, minute, _, _, _, _ = now.timetuple()
        h0 = int(hour / 10)
        h1 = hour % 10
        m0 = int(minute / 10)
        m1 = minute % 10

        H0 = mask.Mask.Load(Clock.font33[h0 % 10])
        H1 = mask.Mask.Load(Clock.font33[h1 % 10])
        M0 = mask.Mask.Load(Clock.font33[m0 % 10])
        M1 = mask.Mask.Load(Clock.font33[m1 % 10])

        ret = ret.addMask(H0, Position(0, 0))
        ret = ret.addMask(H1, Position(5, 0))
        ret = ret.addMask(M0, Position(0, 5))
        ret = ret.addMask(M1, Position(5, 5))
        return ret

    flags = [
        ("b", "back", "back", False, "", None),
        ("", "stamp=", "stamp", "", "timestamp", None),
        Mode.FLAG("invert"),
    ]

    font44 = [
        """
[][][][]
[]    []
[]    []
[][][][]
""", """
    []  
  [][]  
    []  
    []  
""", """
[][]    
    [][]
  []    
[][][][]
""", """
[][][][]
    [][]
      []
[][][][]
""", """
[]    []
[]    []
[][][][]
      []
""", """
[][][][]
[]     
    [][]
[][]  
""", """
[]      
[][][][]
[]    []
[][][][]
""", """
[][][][]
      []
    []  
    []  
""", """
  [][]
[][][][]
[]    []
[][][][]
""", """
[][][][]
[]    []
[][][][]
      []
"""
    ]

    font33 = [
        """
[][][]
[]  []
[][][]
""", """
  []  
  []  
  []  
""", """
[]    
  []  
[][][]
""", """
[][][]
  [][]
[][][]
""", """
[]  []
[][][]
    []
""", """
[][][]
  []  
[][]  
""", """
[]    
[][][]
[][][]
""", """
[][][]
    []
    []
""", """
[][][]
[][][]
[][][]
""", """
[][][]
[][][]
    []
"""
    ]

    dots = [
        """
      
      
      
""", """
      
  []  
      
""", """
[]    
      
    []
""", """
    []
  []  
[]    
""", """
[]  []
      
[]  []
""", """
[]  []
  []  
[]  []
""", """
[]  []
[]  []
[]  []
""", """
[]  []
[][][]
[]  []
""", """
[][][]
[]  []
[][][]
""", """
[][][]
[][][]
[][][]
"""
    ]