Python kivy.utils.get_color_from_hex() Examples
The following are 30
code examples of kivy.utils.get_color_from_hex().
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.utils
, 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: slider.py From Blogs-Posts-Tutorials with MIT License | 6 votes |
def _set_colors(self, *args): if self.theme_cls.theme_style == 'Dark': self._track_color_normal = get_color_from_hex('FFFFFF') self._track_color_normal[3] = .3 self._track_color_active = self._track_color_normal self._track_color_disabled = self._track_color_normal self.thumb_color = get_color_from_hex(colors['Grey']['400']) self.thumb_color_down = get_color_from_hex( colors[self.theme_cls.primary_palette]['200']) self.thumb_color_disabled = get_color_from_hex( colors['Grey']['800']) else: self._track_color_normal = get_color_from_hex('000000') self._track_color_normal[3] = 0.26 self._track_color_active = get_color_from_hex('000000') self._track_color_active[3] = 0.38 self._track_color_disabled = get_color_from_hex('000000') self._track_color_disabled[3] = 0.26 self.thumb_color_down = self.theme_cls.primary_color
Example #3
Source File: selectioncontrols.py From Blogs-Posts-Tutorials with MIT License | 6 votes |
def _set_colors(self, *args): self._track_color_normal = self.theme_cls.disabled_hint_text_color if self.theme_cls.theme_style == 'Dark': self._track_color_active = self.theme_cls.primary_color self._track_color_active[3] = .5 self._track_color_disabled = get_color_from_hex('FFFFFF') self._track_color_disabled[3] = .1 self.thumb_color = get_color_from_hex(colors['Grey']['400']) self.thumb_color_down = get_color_from_hex( colors[self.theme_cls.primary_palette]['200']) self.thumb_color_disabled = get_color_from_hex( colors['Grey']['800']) else: self._track_color_active = get_color_from_hex( colors[self.theme_cls.primary_palette]['200']) self._track_color_active[3] = .5 self._track_color_disabled = self.theme_cls.disabled_hint_text_color self.thumb_color_down = self.theme_cls.primary_color
Example #4
Source File: selectioncontrols.py From KivyMD with MIT License | 6 votes |
def _set_colors(self, *args): self._track_color_normal = self.theme_cls.disabled_hint_text_color if self.theme_cls.theme_style == 'Dark': self._track_color_active = self.theme_cls.primary_color self._track_color_active[3] = .5 self._track_color_disabled = get_color_from_hex('FFFFFF') self._track_color_disabled[3] = .1 self.thumb_color = get_color_from_hex(colors['Grey']['400']) self.thumb_color_down = get_color_from_hex( colors[self.theme_cls.primary_palette]['200']) self.thumb_color_disabled = get_color_from_hex( colors['Grey']['800']) else: self._track_color_active = get_color_from_hex( colors[self.theme_cls.primary_palette]['200']) self._track_color_active[3] = .5 self._track_color_disabled = self.theme_cls.disabled_hint_text_color self.thumb_color_down = self.theme_cls.primary_color
Example #5
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 #6
Source File: main.py From kb with MIT License | 6 votes |
def resize(self, *args): self.cell_size = (0.25 * (self.width - 5 * spacing), ) * 2 # redraw background self.canvas.before.clear() with self.canvas.before: BorderImage(pos=self.pos, size=self.size, source='board.png') Color(*get_color_from_hex('ccc0b4')) for board_x, board_y in all_cells(): BorderImage(pos=self.cell_pos(board_x, board_y), size=self.cell_size, source='cell.png') # resize tiles if not self.b: return for board_x, board_y in all_cells(): tile = self.b[board_x][board_y] if tile: tile.resize(pos=self.cell_pos(board_x, board_y), size=self.cell_size)
Example #7
Source File: slider.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _set_thumb_color(self, color, alpha=None): if len(color) == 2: self._thumb_color = get_color_from_hex(colors[color[0]][color[1]]) if alpha: self._thumb_color[3] = alpha elif len(color) == 4: self._thumb_color = color
Example #8
Source File: theming.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _get_error_color(self): return get_color_from_hex(colors['Red']['A700'])
Example #9
Source File: slider.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _set_thumb_color_disabled(self, color, alpha=None): if len(color) == 2: self._thumb_color_disabled = get_color_from_hex( colors[color[0]][color[1]]) if alpha: self._thumb_color_disabled[3] = alpha elif len(color) == 4: self._thumb_color_disabled = color
Example #10
Source File: theming.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _get_divider_color(self, opposite=False): theme_style = self._get_theme_style(opposite) if theme_style == 'Light': color = get_color_from_hex('000000') elif theme_style == 'Dark': color = get_color_from_hex('FFFFFF') color[3] = .12 return color
Example #11
Source File: rst.py From Tickeys-linux with MIT License | 5 votes |
def _get_bgc(self): return get_color_from_hex(self.colors.background)
Example #12
Source File: theming.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _get_disabled_hint_text_color(self, opposite=False): theme_style = self._get_theme_style(opposite) if theme_style == 'Light': color = get_color_from_hex('000000') color[3] = .26 elif theme_style == 'Dark': color = get_color_from_hex('FFFFFF') color[3] = .30 return color
Example #13
Source File: theming.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _get_secondary_text_color(self, opposite=False): theme_style = self._get_theme_style(opposite) if theme_style == 'Light': color = get_color_from_hex('000000') color[3] = .54 elif theme_style == 'Dark': color = get_color_from_hex('FFFFFF') color[3] = .70 return color
Example #14
Source File: theming.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _get_text_color(self, opposite=False): theme_style = self._get_theme_style(opposite) if theme_style == 'Light': color = get_color_from_hex('000000') color[3] = .87 elif theme_style == 'Dark': color = get_color_from_hex('FFFFFF') return color
Example #15
Source File: theming.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def set_clearcolor_by_theme_style(self, theme_style): if theme_style == 'Light': Window.clearcolor = get_color_from_hex( colors['Light']['Background']) elif theme_style == 'Dark': Window.clearcolor = get_color_from_hex( colors['Dark']['Background'])
Example #16
Source File: theme_picker.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def rgb_hex(self, col): return get_color_from_hex(colors[col][self.theme_cls.accent_hue])
Example #17
Source File: selectioncontrols.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _set_thumb_color_down(self, color, alpha=None): if len(color) == 2: self._thumb_color_down = get_color_from_hex( colors[color[0]][color[1]]) if alpha: self._thumb_color_down[3] = alpha else: self._thumb_color_down[3] = 1 elif len(color) == 4: self._thumb_color_down = color
Example #18
Source File: selectioncontrols.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _set_thumb_color(self, color, alpha=None): if len(color) == 2: self._thumb_color = get_color_from_hex(colors[color[0]][color[1]]) if alpha: self._thumb_color[3] = alpha elif len(color) == 4: self._thumb_color = color
Example #19
Source File: button.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _set_bg_color_down(self, color, alpha=None): if len(color) == 2: self._bg_color_down = get_color_from_hex( colors[color[0]][color[1]]) if alpha: self._bg_color_down[3] = alpha elif len(color) == 4: self._bg_color_down = color
Example #20
Source File: button.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _set_bg_color_disabled(self, color, alpha=None): if len(color) == 2: self._bg_color_disabled = get_color_from_hex( colors[color[0]][color[1]]) if alpha: self._bg_color_disabled[3] = alpha elif len(color) == 4: self._bg_color_disabled = color
Example #21
Source File: button.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _set_bg_color_down(self, color, alpha=None): if len(color) == 2: self._bg_color_down = get_color_from_hex( colors[color[0]][color[1]]) if alpha: self._bg_color_down[3] = alpha elif len(color) == 4: self._bg_color_down = color
Example #22
Source File: button.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def on_touch_down(self, touch): if touch.is_mouse_scrolling: return False elif not self.collide_point(touch.x, touch.y): return False elif self in touch.ud: return False elif self.disabled: return False else: self.fade_bg = Animation(duration=.2, _current_button_color=get_color_from_hex( colors[self.theme_cls.theme_style]['FlatButtonDown'])) self.fade_bg.start(self) return super(MDFlatButton, self).on_touch_down(touch)
Example #23
Source File: button.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def __init__(self, **kwargs): super(MDFlatButton, self).__init__(**kwargs) self._current_button_color = self.background_color self._bg_color_down = get_color_from_hex( colors[self.theme_cls.theme_style]['FlatButtonDown']) Clock.schedule_once(lambda x: self.ids._label.bind( texture_size=self.update_width_on_label_texture))
Example #24
Source File: __init__.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def draw(self, *args): super(ContourPlot, self).draw(*args) data = self.data xdim, ydim = data.shape # Find the minimum and maximum z values zmax = data.max() zmin = data.min() rgb_scale_factor = 1.0 / (zmax - zmin) * 255 # Scale the z values into RGB data buf = np.array(data, dtype=float, copy=True) np.subtract(buf, zmin, out=buf) np.multiply(buf, rgb_scale_factor, out=buf) # Duplicate into 3 dimensions (RGB) and convert to byte array buf = np.asarray(buf, dtype=np.uint8) buf = np.expand_dims(buf, axis=2) buf = np.concatenate((buf, buf, buf), axis=2) buf = np.reshape(buf, (xdim, ydim, 3)) charbuf = bytearray(np.reshape(buf, (buf.size))) self._texture = Texture.create(size=(xdim, ydim), colorfmt='rgb') self._texture.blit_buffer(charbuf, colorfmt='rgb', bufferfmt='ubyte') image = self._image image.texture = self._texture params = self._params funcx = log10 if params['xlog'] else lambda x: x funcy = log10 if params['ylog'] else lambda x: x xmin = funcx(params['xmin']) ymin = funcy(params['ymin']) size = params['size'] ratiox = (size[2] - size[0]) / float(funcx(params['xmax']) - xmin) ratioy = (size[3] - size[1]) / float(funcy(params['ymax']) - ymin) bl = (funcx(self.xrange[0]) - xmin) * ratiox + size[0], (funcy(self.yrange[0]) - ymin) * ratioy + size[1] tr = (funcx(self.xrange[1]) - xmin) * ratiox + size[0], (funcy(self.yrange[1]) - ymin) * ratioy + size[1] image.pos = bl w = tr[0] - bl[0] h = tr[1] - bl[1] image.size = (w, h)
Example #25
Source File: __init__.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def _smooth_reload_observer(texture): texture.blit_buffer(SmoothLinePlot.GRADIENT_DATA, colorfmt="rgb")
Example #26
Source File: analogchannelsview.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def _regen_plot_interpolated(self, volts, scaled): graphContainer = self.ids.graphcontainer graphContainer.clear_widgets() graph = AnalogScaler() graphContainer.add_widget(graph) plot = LinePlot(color=rgb('00FF00'), line_width=1.25) graph.add_plot(plot) self.plot = plot points = [] max_scaled = None min_scaled = None for i in range(ScalingMap.SCALING_MAP_POINTS): v = volts[i] s = scaled[i] points.append((v, s)) if max_scaled == None or s > max_scaled: max_scaled = s if min_scaled == None or s < min_scaled: min_scaled = s graph.ymin = min_scaled graph.ymax = max_scaled graph.xmin = 0 graph.xmax = 5 plot.points = points
Example #27
Source File: colorsequence.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def get_color(self, key): color = self.color_map.get(key) if not color: index = self.color_index color = rgb(self.colors[index]) index = index + 1 if index < len(self.colors) - 1 else 0 self.color_index = index self.color_map[key] = color return color
Example #28
Source File: geojson.py From pydelhi_mobile with GNU Affero General Public License v3.0 | 5 votes |
def _get_color_from(self, value): color = COLORS.get(value.lower(), value) color = get_color_from_hex(color) return color
Example #29
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 #30
Source File: colorpicker.py From Tickeys-linux with MIT License | 5 votes |
def _set_hex(self, value): self.color = get_color_from_hex(value)[:4]