def place(self): self.active = 1 #print(self.char_width,self.char_height, self.text_cols,self.text_rows) io.rect(self.x,self.y,self.width,self.height, self._color) io.rect(self.x + self.border,self.y + self.border, self.width - self.border*2, self.height - self.border*2, self.background) self.sub_place()
def place(self): #ensure that each pixel will place #the previos loaded data grid self.prev = [] for valx in range(self.grid_width): self.prev.append([]) for valy in range(self.grid_height): self.prev[valx].append(2**31) self.active = 1 io.rect(self.x, self.y, self.width, self.height, self.background) self.refresh()
def sub_place(self): #width = io.text_dimensions(self.x+self.border,self.y+self.border,self.value) #io.rect(self.x+self.border + width,self.y+self.border, self.width - width, self.height) #place rect to clear any place where new text won't go minx = self.width for line in self.value.split('\n'): minx = min(minx, io.text_dimensions(self.x,self.y,line)[0] ) io.rect(self.x+self.border + minx, self.y+self.border, self.width - self.border*2 - minx, self.height - self.border*2, self.background) io.text(self.x + self.border,self.y + 1 + self.border, self.value, color = self.color, background = self.background)
def refresh(self): if self.active: data = self.data_func(*self.data_tup) #find max and min max_val = -100000 #init min_val = 100000 # crazy for row in data: for val in row: max_val = max(max_val, val) min_val = min(min_val, val) color_range = max_val - min_val + 1 x_pos = self.grid_x for x in range(self.grid_width): y_pos = self.grid_y for y in range(self.grid_height): #check if screen needs refresh! (only chagne prev if screen is to be writen to!) color_val = max( 0, int( floor( ((data[x][y] - min_val)**3 / color_range**3) * 10) * 255 / 10) - int(color_range**2 / (data[x][y] * 1.01 - min_val)**3)) if abs(color_val - self.prev[x][y]) >= self.memory_tol: #change the previous stored value self.prev[x][y] = color_val io.rect( self.x + self.border + x * self.pixel_width, self.y + self.border + y * self.pixel_width, self.pixel_width, self.pixel_height, io.color( 255 - color_val * self.color_mask[0], #r 255 - color_val * self.color_mask[1], #g 255 - color_val * self.color_mask[2])) #b del data, x_pos, y_pos collect() return (max_val, min_val, color_range)
def clear(self): self.active = 0 io.rect(self.x, self.y, self.width, self.height, self.color_clear)
def clear(self): self.active = 0 self.current.clear() io.rect(self.x, self.y, self.width, self.height, self.color_clear)
def place(self): self.active = 1 io.rect(self.x, self.y, self.width, self.height, self.background) self.current.place()
def clear(self): self.active = 0 for pointer in self.contents: pointer.clear() io.rect(self.x, self.y, self.width, self.height, self.color_clear)
def place(self): self.active = 1 io.rect(self.x, self.y, self.width, self.height, self.background) for pointer in self.contents: pointer.place()
def clear(self): self.active = 0 for but in self.contents: but.clear() io.rect(self.x, self.y, self.width, self.height, self.background)
def place(self): self.active = 1 io.rect(self.x, self.y, self.width, self.height, self.background) for but in self.contents: but.place()