本文整理汇总了Python中kivy.utils.get_color_from_hex方法的典型用法代码示例。如果您正苦于以下问题:Python utils.get_color_from_hex方法的具体用法?Python utils.get_color_from_hex怎么用?Python utils.get_color_from_hex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.utils
的用法示例。
在下文中一共展示了utils.get_color_from_hex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_drawings
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
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]
示例2: _set_colors
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
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
示例3: resize
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
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)
示例4: create_drawings
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
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]
示例5: _set_colors
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
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
示例6: _set_colors
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
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
示例7: _smooth_reload_observer
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
def _smooth_reload_observer(texture):
texture.blit_buffer(SmoothLinePlot.GRADIENT_DATA, colorfmt="rgb")
示例8: draw
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
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
x_px = self.x_px()
y_px = self.y_px()
bl = x_px(self.xrange[0]), y_px(self.yrange[0])
tr = x_px(self.xrange[1]), y_px(self.yrange[1])
image.pos = bl
w = tr[0] - bl[0]
h = tr[1] - bl[1]
image.size = (w, h)
示例9: __init__
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
def __init__(self, **kwargs):
super(MDFlatButton, self).__init__(**kwargs)
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))
示例10: _set_bg_color_down
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
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
示例11: _set_bg_color_disabled
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
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
示例12: _set_thumb_color_down
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
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
示例13: _set_thumb_color_disabled
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
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
示例14: _get_primary_color
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
def _get_primary_color(self):
return get_color_from_hex(
colors[self.primary_palette][self.primary_hue])
示例15: _get_primary_light
# 需要导入模块: from kivy import utils [as 别名]
# 或者: from kivy.utils import get_color_from_hex [as 别名]
def _get_primary_light(self):
return get_color_from_hex(
colors[self.primary_palette][self.primary_light_hue])