# @name EffectClock # @desc Große HH:MM-Uhr mit frei wählbarem Effekt in den Ziffern # @author Denn's DJ # @version 2.1 class EffectClock var masks def init() # Segmentmuster für die Ziffern 0 bis 9 self.masks = [63, 6, 91, 79, 102, 109, 125, 7, 127, 111] end def digit_pixel(px, py, left, value) if px < left || px > left + 4 return false end var x = px - left var mask = self.masks[value] if x >= 1 && x <= 3 && py <= 1 && int(mask / 1) % 2 == 1 return true end if x >= 3 && py >= 1 && py <= 3 && int(mask / 2) % 2 == 1 return true end if x >= 3 && py >= 4 && py <= 6 && int(mask / 4) % 2 == 1 return true end if x >= 1 && x <= 3 && py >= 6 && int(mask / 8) % 2 == 1 return true end if x <= 1 && py >= 4 && py <= 6 && int(mask / 16) % 2 == 1 return true end if x <= 1 && py >= 1 && py <= 3 && int(mask / 32) % 2 == 1 return true end if x >= 1 && x <= 3 && py >= 3 && py <= 4 && int(mask / 64) % 2 == 1 return true end return false end def draw() var h = hour() var m = minute() if h < 0 || m < 0 clear(0x000000) return end # Effekt hier auswählen: effect("ColorWaves") var left = (width() - 26) / 2 var top = (height() - 8) / 2 var h1 = int(h / 10) var h2 = h % 10 var m1 = int(m / 10) var m2 = m % 10 for y : 0 .. height() - 1 for x : 0 .. width() - 1 var py = y - top var keep = self.digit_pixel(x, py, left, h1) || self.digit_pixel(x, py, left + 6, h2) || self.digit_pixel(x, py, left + 15, m1) || self.digit_pixel(x, py, left + 21, m2) || ((x == left + 12 || x == left + 13) && ((py >= 1 && py <= 2) || (py >= 5 && py <= 6))) if !keep pixel(x, y, 0x000000) end end end end end return EffectClock()