Python kivy.graphics.Color() Examples
The following are 30
code examples of kivy.graphics.Color().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
kivy.graphics
, or try the search function
.
Example #1
Source File: __init__.py From kivy-smoothie-host with GNU General Public License v3.0 | 7 votes |
def create_drawings(self): from kivy.graphics import Line, RenderContext # very first time, create a texture for the shader if not hasattr(SmoothLinePlot, '_texture'): tex = Texture.create(size=(1, 64), colorfmt='rgb') tex.add_reload_observer(SmoothLinePlot._smooth_reload_observer) SmoothLinePlot._texture = tex SmoothLinePlot._smooth_reload_observer(tex) self._grc = RenderContext( fs=SmoothLinePlot.SMOOTH_FS, use_parent_modelview=True, use_parent_projection=True) with self._grc: self._gcolor = Color(*self.color) self._gline = Line( points=[], cap='none', width=2., texture=SmoothLinePlot._texture) return [self._grc]
Example #2
Source File: gesturesurface.py From Tickeys-linux with MIT License | 6 votes |
def init_gesture(self, touch): '''Create a new gesture from touch, ie it's the first on surface, or was not close enough to any existing gesture (yet)''' col = self.color if self.use_random_color is True: col = hsv_to_rgb(random(), 1., 1.) g = GestureContainer(touch, max_strokes=self.max_strokes, line_width=self.line_width, color=col) # Create the bounding box Rectangle for the gesture if self.draw_bbox: bb = g.bbox with self.canvas: Color(col[0], col[1], col[2], self.bbox_alpha, mode='rgba', group=g.id) g._bbrect = Rectangle( group=g.id, pos=(bb['minx'], bb['miny']), size=(bb['maxx'] - bb['minx'], bb['maxy'] - bb['miny'])) self._gestures.append(g) return g
Example #3
Source File: gesturesurface.py From Tickeys-linux with MIT License | 6 votes |
def init_stroke(self, g, touch): l = [touch.x, touch.y] col = g.color new_line = Line( points=l, width=self.line_width, group=g.id) g._strokes[str(touch.uid)] = new_line if self.line_width: canvas_add = self.canvas.add canvas_add(Color(col[0], col[1], col[2], mode='rgb', group=g.id)) canvas_add(new_line) # Update the bbox in case; this will normally be done in on_touch_move, # but we want to update it also for a single press, force that here: g.update_bbox(touch) if self.draw_bbox: self._update_canvas_bbox(g) # Register the stroke in GestureContainer so we can look it up later g.add_stroke(touch, new_line)
Example #4
Source File: gesturesurface.py From Tickeys-linux with MIT License | 6 votes |
def init_gesture(self, touch): '''Create a new gesture from touch, ie it's the first on surface, or was not close enough to any existing gesture (yet)''' col = self.color if self.use_random_color is True: col = hsv_to_rgb(random(), 1., 1.) g = GestureContainer(touch, max_strokes=self.max_strokes, line_width=self.line_width, color=col) # Create the bounding box Rectangle for the gesture if self.draw_bbox: bb = g.bbox with self.canvas: Color(col[0], col[1], col[2], self.bbox_alpha, mode='rgba', group=g.id) g._bbrect = Rectangle( group=g.id, pos=(bb['minx'], bb['miny']), size=(bb['maxx'] - bb['minx'], bb['maxy'] - bb['miny'])) self._gestures.append(g) return g
Example #5
Source File: touchring.py From Tickeys-linux with MIT License | 6 votes |
def _mouse_move(win, pos, *args): global cursor_size if hasattr(win, '_cursor'): c = win._cursor else: with win.canvas.after: img = Image(cursor_image) Color(1, 1, 1, 1, mode='rgba') size = ( cursor_size[0] or img.texture.size[0], cursor_size[1] or img.texture.size[1] ) print(size) win._cursor = c = Rectangle(texture=img.texture, size=size) c.pos = pos[0] + cursor_offset[0], pos[1] - c.size[1] + cursor_offset[1]
Example #6
Source File: touchring.py From Tickeys-linux with MIT License | 6 votes |
def _touch_down(win, touch): ud = touch.ud touch.scale_for_screen(win.width, win.height) with win.canvas.after: ud['tr.color'] = Color(1, 1, 1, pointer_alpha) iw, ih = pointer_image.size ud['tr.rect'] = Rectangle( pos=( touch.x - (pointer_image.width / 2. * pointer_scale), touch.y - (pointer_image.height / 2. * pointer_scale)), size=(iw * pointer_scale, ih * pointer_scale), texture=pointer_image.texture) if not ud.get('tr.grab', False): ud['tr.grab'] = True touch.grab(win)
Example #7
Source File: mouse.py From Tickeys-linux with MIT License | 6 votes |
def update_graphics(self, win, create=False): global Color, Ellipse de = self.ud.get('_drawelement', None) if de is None and create: if Color is None: from kivy.graphics import Color, Ellipse with win.canvas.after: de = ( Color(.8, .2, .2, .7), Ellipse(size=(20, 20), segments=15)) self.ud._drawelement = de if de is not None: self.push() self.scale_for_screen( win.system_size[0], win.system_size[1], rotation=win.rotation) de[1].pos = self.x - 10, self.y - 10 self.pop()
Example #8
Source File: monitor.py From Tickeys-linux with MIT License | 6 votes |
def start(win, ctx): # late import to avoid breaking module loading from kivy.input.postproc import kivy_postproc_modules kivy_postproc_modules['fps'] = StatsInput() global _ctx ctx.label = Label(text='FPS: 0.0') ctx.inputstats = 0 ctx.stats = [] ctx.statsr = [] with win.canvas.after: ctx.color = Color(1, 0, 0, .5) ctx.rectangle = Rectangle(pos=(0, win.height - 25), size=(win.width, 25)) ctx.color = Color(1, 1, 1) ctx.rectangle = Rectangle(pos=(5, win.height - 20)) ctx.color = Color(1, 1, 1, .5) for x in range(64): ctx.stats.append(0) ctx.statsr.append( Rectangle(pos=(win.width - 64 * 4 + x * 4, win.height - 25), size=(4, 0))) Clock.schedule_interval(partial(update_fps, ctx), .5) Clock.schedule_interval(partial(update_stats, ctx), 1 / 60.)
Example #9
Source File: touchring.py From Tickeys-linux with MIT License | 6 votes |
def _touch_down(win, touch): ud = touch.ud touch.scale_for_screen(win.width, win.height) with win.canvas.after: ud['tr.color'] = Color(1, 1, 1, pointer_alpha) iw, ih = pointer_image.size ud['tr.rect'] = Rectangle( pos=( touch.x - (pointer_image.width / 2. * pointer_scale), touch.y - (pointer_image.height / 2. * pointer_scale)), size=(iw * pointer_scale, ih * pointer_scale), texture=pointer_image.texture) if not ud.get('tr.grab', False): ud['tr.grab'] = True touch.grab(win)
Example #10
Source File: backend_kivy.py From garden.matplotlib with MIT License | 6 votes |
def draw_rubberband(self, event, x0, y0, x1, y1): w = abs(x1 - x0) h = abs(y1 - y0) rect = [int(val)for val in (min(x0, x1) + self.canvas.x, min(y0, y1) + self.canvas.y, w, h)] if self.lastrect is None: self.canvas.canvas.add(Color(*self.rubberband_color)) else: self.canvas.canvas.remove(self.lastrect) self.lastrect = InstructionGroup() self.lastrect.add(Line(rectangle=rect, width=1.0, dash_length=5.0, dash_offset=5.0)) self.lastrect.add(Color(1.0, 0.0, 0.0, 0.2)) self.lastrect.add(Rectangle(pos=(rect[0], rect[1]), size=(rect[2], rect[3]))) self.canvas.canvas.add(self.lastrect)
Example #11
Source File: touchring.py From Tickeys-linux with MIT License | 6 votes |
def _mouse_move(win, pos, *args): global cursor_size if hasattr(win, '_cursor'): c = win._cursor else: with win.canvas.after: img = Image(cursor_image) Color(1, 1, 1, 1, mode='rgba') size = ( cursor_size[0] or img.texture.size[0], cursor_size[1] or img.texture.size[1] ) print(size) win._cursor = c = Rectangle(texture=img.texture, size=size) c.pos = pos[0] + cursor_offset[0], pos[1] - c.size[1] + cursor_offset[1]
Example #12
Source File: gesturesurface.py From Tickeys-linux with MIT License | 6 votes |
def init_stroke(self, g, touch): l = [touch.x, touch.y] col = g.color new_line = Line( points=l, width=self.line_width, group=g.id) g._strokes[str(touch.uid)] = new_line if self.line_width: canvas_add = self.canvas.add canvas_add(Color(col[0], col[1], col[2], mode='rgb', group=g.id)) canvas_add(new_line) # Update the bbox in case; this will normally be done in on_touch_move, # but we want to update it also for a single press, force that here: g.update_bbox(touch) if self.draw_bbox: self._update_canvas_bbox(g) # Register the stroke in GestureContainer so we can look it up later g.add_stroke(touch, new_line)
Example #13
Source File: dial-gauge.py From kivy-smoothie-host with GNU General Public License v3.0 | 6 votes |
def draw_setpoint(self, *args): # draw a setpoint if self.setpoint_canvas: self.canvas.after.remove(self.setpoint_canvas) self.setpoint_canvas = None if math.isnan(self.setpoint_value) or math.isinf(self.setpoint_value): return v = self.value_to_angle(self.setpoint_value) length = self.dial_diameter / 2.0 - self.tic_length if not self.setpoint_length else self.setpoint_length self.setpoint_canvas = InstructionGroup() self.setpoint_canvas.add(PushMatrix()) self.setpoint_canvas.add(Color(*self.setpoint_color)) self.setpoint_canvas.add(Rotate(angle=v, axis=(0, 0, -1), origin=self.dial_center)) self.setpoint_canvas.add(Translate(self.dial_center[0], self.dial_center[1])) self.setpoint_canvas.add(Line(points=[0, 0, 0, length], width=self.setpoint_thickness, cap='none')) # self.setpoint_canvas.add(SmoothLine(points=[0, 0, 0, length], width=self.setpoint_thickness)) self.setpoint_canvas.add(PopMatrix()) self.canvas.after.add(self.setpoint_canvas)
Example #14
Source File: mouse.py From Tickeys-linux with MIT License | 6 votes |
def update_graphics(self, win, create=False): global Color, Ellipse de = self.ud.get('_drawelement', None) if de is None and create: if Color is None: from kivy.graphics import Color, Ellipse with win.canvas.after: de = ( Color(.8, .2, .2, .7), Ellipse(size=(20, 20), segments=15)) self.ud._drawelement = de if de is not None: self.push() self.scale_for_screen( win.system_size[0], win.system_size[1], rotation=win.rotation) de[1].pos = self.x - 10, self.y - 10 self.pop()
Example #15
Source File: dial-gauge.py From kivy-smoothie-host with GNU General Public License v3.0 | 6 votes |
def draw_annulars(self): # draw annulars that are in the annulars list: # requires properties annular_thickness, and a list of dicts {color: , start: , stop: }, ..., # where start and stop are the values of the scale to start and stop the annular if len(self.annulars) == 0: return awidth = self.annular_thickness self.annular_canvas = InstructionGroup() if self.semi_circle: self.annular_canvas.add(PushMatrix()) self.annular_canvas.add(Translate(0, -self.dial_diameter / 2 + self.hub_radius)) for a in self.annulars: self.annular_canvas.add(Color(*a.get('color', [0, 1, 0, 1]))) st = self.value_to_angle(a.get('start', self.scale_min)) en = self.value_to_angle(a.get('stop', self.scale_max)) self.annular_canvas.add(Line(ellipse=(self.pos[0] + awidth, self.pos[1] + awidth, self.dial_diameter - awidth * 2, self.dial_diameter - awidth * 2, st + awidth / 2.0 - self.tic_width, en + awidth / 2.0), width=awidth, cap='none', joint='round')) if self.semi_circle: self.annular_canvas.add(PopMatrix()) self.canvas.before.add(self.annular_canvas)
Example #16
Source File: __init__.py From RaceCapture_App with GNU General Public License v3.0 | 6 votes |
def create_drawings(self): from kivy.graphics import Line, RenderContext from kivy.graphics.texture import Texture # very first time, create a texture for the shader if not hasattr(SmoothLinePlot, '_texture'): tex = Texture.create(size=(1, 64), colorfmt='rgb') tex.add_reload_observer(SmoothLinePlot._smooth_reload_observer) SmoothLinePlot._texture = tex SmoothLinePlot._smooth_reload_observer(tex) self._grc = RenderContext(fs=SmoothLinePlot.SMOOTH_FS, use_parent_modelview=True, use_parent_projection=True) with self._grc: self._gcolor = Color(*self.color) self._gline = Line(points=[], cap='none', width=2., texture=SmoothLinePlot._texture) return [self._grc]
Example #17
Source File: labels.py From kivy-material-ui with MIT License | 6 votes |
def on_touch_move( self, touch ) : if self._touched : self._d = touch.pos self._hover_size, self._hover_pos = self._get_hover() if self.root_layout : self._clear_canvas() with self.root_layout.canvas : kg.Color( *self.hover_color, **self._unique_group ) kg.Rectangle( size=self._hover_size, \ pos=self._hover_pos, \ **self._unique_group ) return True
Example #18
Source File: textinput.py From Tickeys-linux with MIT License | 5 votes |
def _draw_selection(self, *largs): pos, size, line_num, (s1c, s1r), (s2c, s2r),\ _lines, _get_text_width, tab_width, _label_cached, width,\ padding_left, padding_right, x, canvas_add, selection_color = largs # Draw the current selection on the widget. if line_num < s1r or line_num > s2r: return x, y = pos w, h = size x1 = x x2 = x + w if line_num == s1r: lines = _lines[line_num] x1 -= self.scroll_x x1 += _get_text_width(lines[:s1c], tab_width, _label_cached) if line_num == s2r: lines = _lines[line_num] x2 = (x - self.scroll_x) + _get_text_width(lines[:s2c], tab_width, _label_cached) width_minus_padding = width - (padding_right + padding_left) maxx = x + width_minus_padding if x1 > maxx: return x1 = max(x1, x) x2 = min(x2, x + width_minus_padding) canvas_add(Color(*selection_color, group='selection')) canvas_add(Rectangle( pos=(x1, pos[1]), size=(x2 - x1, size[1]), group='selection'))
Example #19
Source File: __init__.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def __init__(self, **kw): self._trigger_genitems = Clock.create_trigger(self._genitems, -1) self.bind(min=self._trigger_genitems, max=self._trigger_genitems, multiples_of=self._trigger_genitems) super(CircularNumberPicker, self).__init__(**kw) self.selected = self.min self.bind(selected=self.on_selected, pos=self.on_selected, size=self.on_selected) cx = self.center_x + self.padding[0] - self.padding[2] cy = self.center_y + self.padding[3] - self.padding[1] sx, sy = self.pos_for_number(self.selected) epos = [i - (self.delta_radii * self.number_size_factor) for i in (sx, sy)] esize = [self.delta_radii * self.number_size_factor * 2] * 2 dsize = [i * .3 for i in esize] dpos = [i + esize[0] / 2. - dsize[0] / 2. for i in epos] csize = [i * .05 for i in esize] cpos = [i - csize[0] / 2. for i in (cx, cy)] dot_alpha = 0 if self.selected % self.multiples_of == 0 else 1 color = list(self.selector_color) with self.canvas: self._selection_color = Color(*(color + [self.selector_alpha])) self._selection_circle = Ellipse(pos=epos, size=esize) self._selection_line = Line(points=[cx, cy, sx, sy], width=dp(1.25)) self._selection_dot_color = Color(*(color + [dot_alpha])) self._selection_dot = Ellipse(pos=dpos, size=dsize) self._center_color = Color(*self.color) self._center_dot = Ellipse(pos=cpos, size=csize) self.bind(selector_color=lambda ign, u: setattr(self._selection_color, "rgba", u + [self.selector_alpha])) self.bind(selector_color=lambda ign, u: setattr(self._selection_dot_color, "rgb", u)) self.bind(selector_color=lambda ign, u: self.dot_is_none()) self.bind(color=lambda ign, u: setattr(self._center_color, "rgb", u)) Clock.schedule_once(self._genitems) Clock.schedule_once(self.on_selected) # Just to make sure pos/size are set
Example #20
Source File: colorpicker.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self, r_min, r_max, theta_min, theta_max, color=(0, 0, 1, 1), origin = (0, 0), **kwargs): super(_ColorArc, self).__init__(**kwargs) self.origin = origin self.r_min = r_min self.r_max = r_max self.theta_min = theta_min self.theta_max = theta_max self.color = color self.color_instr = Color(*color, mode='hsv') self.add(self.color_instr) self.mesh = self.get_mesh() self.add(self.mesh)
Example #21
Source File: colorpicker.py From Tickeys-linux with MIT License | 5 votes |
def change_color(self, color=None, color_delta=None, sv=None, a=None): self.remove(self.color_instr) if color is not None: self.color = color elif color_delta is not None: self.color = [self.color[i] + color_delta[i] for i in range(4)] elif sv is not None: self.color = (self.color[0], sv[0], sv[1], self.color[3]) elif a is not None: self.color = (self.color[0], self.color[1], self.color[2], a) self.color_instr = Color(*self.color, mode='hsv') self.insert(0, self.color_instr)
Example #22
Source File: textinput.py From Tickeys-linux with MIT License | 5 votes |
def _draw_selection(self, *largs): pos, size, line_num, (s1c, s1r), (s2c, s2r),\ _lines, _get_text_width, tab_width, _label_cached, width,\ padding_left, padding_right, x, canvas_add, selection_color = largs # Draw the current selection on the widget. if line_num < s1r or line_num > s2r: return x, y = pos w, h = size x1 = x x2 = x + w if line_num == s1r: lines = _lines[line_num] x1 -= self.scroll_x x1 += _get_text_width(lines[:s1c], tab_width, _label_cached) if line_num == s2r: lines = _lines[line_num] x2 = (x - self.scroll_x) + _get_text_width(lines[:s2c], tab_width, _label_cached) width_minus_padding = width - (padding_right + padding_left) maxx = x + width_minus_padding if x1 > maxx: return x1 = max(x1, x) x2 = min(x2, x + width_minus_padding) canvas_add(Color(*selection_color, group='selection')) canvas_add(Rectangle( pos=(x1, pos[1]), size=(x2 - x1, size[1]), group='selection'))
Example #23
Source File: geojson.py From pydelhi_mobile with GNU Affero General Public License v3.0 | 5 votes |
def _geojson_part_geometry(self, geometry, properties): tp = geometry["type"] graphics = [] if tp == "Polygon": tess = Tesselator() for c in geometry["coordinates"]: xy = list(self._lonlat_to_xy(c)) xy = flatten(xy) tess.add_contour(xy) tess.tesselate(WINDING_ODD, TYPE_POLYGONS) color = self._get_color_from(properties.get("color", "FF000088")) graphics.append(Color(*color)) for vertices, indices in tess.meshes: graphics.append( Mesh( vertices=vertices, indices=indices, mode="triangle_fan")) elif tp == "LineString": stroke = get_color_from_hex(properties.get("stroke", "#ffffff")) stroke_width = dp(properties.get("stroke-width")) xy = list(self._lonlat_to_xy(geometry["coordinates"])) xy = flatten(xy) graphics.append(Color(*stroke)) graphics.append(Line(points=xy, width=stroke_width)) return graphics
Example #24
Source File: view.py From pydelhi_mobile with GNU Affero General Public License v3.0 | 5 votes |
def load_tile_for_source(self, map_source, opacity, size, x, y, zoom): tile = Tile(size=(size, size), cache_dir=self.cache_dir) tile.g_color = Color(1, 1, 1, 0) tile.tile_x = x tile.tile_y = y tile.zoom = zoom tile.pos = (x * size + self.delta_x, y * size + self.delta_y) tile.map_source = map_source tile.state = "loading" if not self._pause: map_source.fill_tile(tile) self.canvas_map.add(tile.g_color) self.canvas_map.add(tile) self._tiles.append(tile)
Example #25
Source File: tachometer.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def __init__(self, **kwargs): super(LinearGauge, self).__init__(**kwargs) # these values match the actual dimensions of the referenced graphic assets self.gauge_width = 2000 self.gauge_height = 500 x = self.pos[0] y = self.pos[1] scale_x = self.width / self.gauge_width scale_y = self.height / self.gauge_height with self.canvas: PushMatrix() self.dial_color = Color(rgba=self.color) self.gauge_translate = Translate(x, y, 0) self.gauge_scale = Scale(x=scale_x, y=scale_y) Rectangle(source='resource/gauge/horizontal_bar_gauge.png', pos=self.pos, size=(self.gauge_width, self.gauge_height)) PopMatrix() PushMatrix() self.mask_translate = Translate(x, y, 0) self.mask_scale = Scale(x=scale_x, y=scale_y) Rectangle(source='resource/gauge/horizontal_bar_gauge_mask.png', pos=self.pos, size=(self.gauge_width, self.gauge_height)) PopMatrix() with self.canvas.after: PushMatrix() Color(1, 1, 1, 1) self.shadow_translate = Translate(x, y, 0) self.shadow_scale = Scale(x=scale_x, y=scale_y) Rectangle(source='resource/gauge/horizontal_bar_gauge_shadow.png', pos=self.pos, size=(self.gauge_width, self.gauge_height)) PopMatrix() self.bind(pos=self.update_all, size=self.update_all)
Example #26
Source File: __init__.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def __init__(self, **kwargs): super(Graph, self).__init__(**kwargs) with self.canvas: self._fbo = Fbo(size=self.size) self._marker_color = Color(self.marker_color) self._marker = Line() with self._fbo: self._background_color = Color(*self.background_color) self._background_rect = Rectangle(size=self.size) self._mesh_ticks_color = Color(*self.tick_color) self._mesh_ticks = Mesh(mode='lines') self._mesh_rect_color = Color(*self.border_color) self._mesh_rect = Mesh(mode='line_strip') with self.canvas: Color(1, 1, 1) self._fbo_rect = Rectangle(size=self.size) mesh = self._mesh_rect mesh.vertices = [0] * (5 * 4) mesh.indices = range(5) self._plot_area = StencilView() self.add_widget(self._plot_area) t = self._trigger = Clock.create_trigger(self._redraw_all) ts = self._trigger_size = Clock.create_trigger(self._redraw_size) tc = self._trigger_color = Clock.create_trigger(self._update_colors) self.bind(center=ts, padding=ts, precision=ts, plots=ts, x_grid=ts, y_grid=ts, draw_border=ts) self.bind(xmin=t, xmax=t, xlog=t, x_ticks_major=t, x_ticks_minor=t, xlabel=t, x_grid_label=t, ymin=t, ymax=t, ylog=t, y_ticks_major=t, y_ticks_minor=t, ylabel=t, y_grid_label=t, font_size=t, label_options=t) self.bind(tick_color=tc, background_color=tc, border_color=tc) self._trigger()
Example #27
Source File: __init__.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def create_drawings(self): self._color = Color(*self.color) self._mesh = Mesh(mode='line_strip') self.bind(color=lambda instr, value: setattr(self._color.rgba, value)) return [self._color, self._mesh]
Example #28
Source File: __init__.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def create_drawings(self): from kivy.graphics import RenderContext self._grc = RenderContext( use_parent_modelview=True, use_parent_projection=True) with self._grc: self._gcolor = Color(*self.color) self._gline = Line(points=[], cap='none', width=self._line_width, joint='round') return [self._grc]
Example #29
Source File: __init__.py From kivy-smoothie-host with GNU General Public License v3.0 | 5 votes |
def __init__(self, **kwargs): super(Graph, self).__init__(**kwargs) with self.canvas: self._fbo = Fbo(size=self.size, with_stencilbuffer=self._with_stencilbuffer) with self._fbo: self._background_color = Color(*self.background_color) self._background_rect = Rectangle(size=self.size) self._mesh_ticks_color = Color(*self.tick_color) self._mesh_ticks = Mesh(mode='lines') self._mesh_rect_color = Color(*self.border_color) self._mesh_rect = Mesh(mode='line_strip') with self.canvas: Color(1, 1, 1) self._fbo_rect = Rectangle(size=self.size, texture=self._fbo.texture) mesh = self._mesh_rect mesh.vertices = [0] * (5 * 4) mesh.indices = range(5) self._plot_area = StencilView() self.add_widget(self._plot_area) t = self._trigger = Clock.create_trigger(self._redraw_all) ts = self._trigger_size = Clock.create_trigger(self._redraw_size) tc = self._trigger_color = Clock.create_trigger(self._update_colors) self.bind(center=ts, padding=ts, precision=ts, plots=ts, x_grid=ts, y_grid=ts, draw_border=ts) self.bind(xmin=t, xmax=t, xlog=t, x_ticks_major=t, x_ticks_minor=t, xlabel=t, x_grid_label=t, ymin=t, ymax=t, ylog=t, y_ticks_major=t, y_ticks_minor=t, ylabel=t, y_grid_label=t, font_size=t, label_options=t, x_ticks_angle=t) self.bind(tick_color=tc, background_color=tc, border_color=tc) self._trigger()
Example #30
Source File: highlightbehavior.py From kivystudio with MIT License | 5 votes |
def redraw_canvas(self, *args): if self.current_highlighted_child: self.instruction_canvas.clear() self.instruction_canvas.add(Color(*self.highlighted_color)) if self.highlighted_shape =='rectangle': self.instruction_canvas.add(Rectangle(pos=self.current_highlighted_child.pos, size=self.current_highlighted_child.size)) elif self.highlighted_shape =='rounded_rectangle': self.instruction_canvas.add(RoundedRectangle(pos=self.current_highlighted_child.pos, size=self.current_highlighted_child.size)) else: raise Exception('Invalid highlighted shape {}'.format(self.highlighted_shape))