Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from kivy.uix.scatter import Scatter
from kivy.properties import ListProperty, NumericProperty
from kivy.clock import Clock
from kivy.vector import Vector
from kivy.animation import Animation
from random import random
class GameManager(ScreenManager):
pass
class Game(FloatLayout):
poles = ListProperty([])
label_opacity = NumericProperty()
num = NumericProperty(0)
def __init__(self, *args, **kwargs):
super(Game, self).__init__(*args, **kwargs)
Clock.schedule_interval(self.update, 1./60)
Clock.schedule_interval(self.spawn_pole, 2)
def update(self, dt):
self.ids.kiwi.update(dt)
self.update_poles(dt)
self.remove_poles()
self.check_collisions()
def check_collisions(self):
for pole in self.poles:
reference_size = ListProperty([])
'''Reference size used for aspect ratio approximation calculation.
:attr:`reference_size` is a :class:`~kivy.properties.ListProperty` and
defaults to `[]`.
'''
cover_size = ListProperty([0, 0])
'''Size of the aspect ratio aware texture. Gets calculated in
``CoverBehavior.calculate_cover``.
:attr:`cover_size` is a :class:`~kivy.properties.ListProperty` and
defaults to `[0, 0]`.
'''
cover_pos = ListProperty([0, 0])
'''Position of the aspect ratio aware texture. Gets calculated in
``CoverBehavior.calculate_cover``.
:attr:`cover_pos` is a :class:`~kivy.properties.ListProperty` and
defaults to `[0, 0]`.
'''
def __init__(self, **kwargs):
super(CoverBehavior, self).__init__(**kwargs)
# bind covering
self.bind(
size=self.calculate_cover,
pos=self.calculate_cover
)
def _aspect_ratio_approximate(self, size):
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
thumb_color_down = AliasProperty(
_get_thumb_color_disabled,
_set_thumb_color_disabled,
bind=["_thumb_color_disabled"],
)
_track_color_active = ListProperty()
_track_color_normal = ListProperty()
_track_color_disabled = ListProperty()
_thumb_pos = ListProperty([0, 0])
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.theme_cls.bind(
theme_style=self._set_colors,
primary_color=self._set_colors,
primary_palette=self._set_colors,
)
self._set_colors()
def _set_colors(self, *args):
self._track_color_normal = self.theme_cls.disabled_hint_text_color
if self.theme_cls.theme_style == "Dark":
'''
light_orientation = ListProperty([0.01, 0.01, 0.01])
'''light_position
'''
light_0 = ListProperty([0.01, 0.01, 0.01])
'''light_0
'''
light_1 = ListProperty([0.01, 0.01, 0.01])
'''light_1
'''
MPICKING_BUFFER_SIZE = ListProperty([320, 240])
canvas_size = ListProperty([1366, 768])
last_widget_str = StringProperty("")
def __init__(self, **kwargs):
self.shadow = kwargs.get("shadow", False)
self.canvas_size = 1366, 768
global PICKING_BUFFER_SIZE
PICKING_BUFFER_SIZE = kwargs.get("canvas_size", Window.size)
self.shadow = True
self.picking = True
self.fbo_list = {}
self.co = self.canvas
#self.canvas = RenderContext(compute_normal_mat=False)
self.canvas = Fbo(size=self.canvas_size,
class ContourPlot(Plot):
"""
ContourPlot visualizes 3 dimensional data as an intensity map image.
The user must first specify 'xrange' and 'yrange' (tuples of min,max) and
then 'data', the intensity values.
`data`, is a MxN matrix, where the first dimension of size M specifies the
`y` values, and the second dimension of size N specifies the `x` values.
Axis Y and X values are assumed to be linearly spaced values from
xrange/yrange and the dimensions of 'data', `MxN`, respectively.
The color values are automatically scaled to the min and max z range of the
data set.
"""
_image = ObjectProperty(None)
data = ObjectProperty(None, force_dispatch=True)
xrange = ListProperty([0, 100])
yrange = ListProperty([0, 100])
def __init__(self, **kwargs):
super(ContourPlot, self).__init__(**kwargs)
self.bind(data=self.ask_draw, xrange=self.ask_draw,
yrange=self.ask_draw)
def create_drawings(self):
self._image = Rectangle()
self._color = Color([1, 1, 1, 1])
self.bind(color=lambda instr, value: setattr(self._color, 'rgba', value))
return [self._color, self._image]
def draw(self, *args):
super(ContourPlot, self).draw(*args)
data = self.data
return False
class BoxSettings(BoxLayout):
pass
'''
def on_touch_down(self, touch):
super(BoxSettings, self).on_touch_down(touch)
if self.collide_point(*touch.pos):
#touch.grab( self )
return True
return False'''
class MainTools(FloatLayout):
col_types = ListProperty()
col_funcs = ListProperty()
sprite_list = ListProperty()
data_key_types = ListProperty()
def __init__(self, **kwargs):
super(MainTools, self).__init__(**kwargs)
self.grav_backup = cy.Vec2d(0,0)
self.staticOn = False
self.paused = False
self.killMomem = False
self.selectedItem = None
self.selectedEntity = None
self.toolSettings = {"circle": {"texture": "sheep"},
"square": {"texture": "Dirt"},
"box": {"texture": "face_box"},
"draw": {"texture": "Grass1"},
"poly": {"texture": "Grass1"},
BoxLayout):
"""A simple tile. It does nothing special, just inherits the right behaviors
to work as a building block.
"""
pass
class SmartTile(ThemableBehavior, RectangularRippleBehavior, ButtonBehavior,
FloatLayout):
"""A tile for more complex needs.
Includes an image, a container to place overlays and a box that can act
as a header or a footer, as described in the Material Design specs.
"""
box_color = ListProperty([0, 0, 0, 0.5])
"""Sets the color and opacity for the information box."""
box_position = OptionProperty('footer', options=['footer', 'header'])
"""Determines wether the information box acts as a header or footer to the
image.
"""
lines = OptionProperty(1, options=[1, 2])
"""Number of lines in the header/footer.
As per Material Design specs, only 1 and 2 are valid values.
"""
overlap = BooleanProperty(True)
"""Determines if the header/footer overlaps on top of the image or not"""
frequency of sine wave of Grating
phase : float
the phase shift of the sin wave
std_dev : integer
the standard deviation of the Gaussian mask controlling the size of the
mask. Larger values create a larger grating on screen due to greater
transparency and smaller values create smaller grating on screen due to
less transparency.
"""
envelope = StringProperty('g')
frequency = NumericProperty(20)
std_dev = NumericProperty(None)
phase = NumericProperty(0.0)
color_one = ListProperty([1., 1., 1., 1.])
color_two = ListProperty([0., 0., 0., 0.])
contrast = NumericProperty(1.0)
def __init__(self, **kwargs):
super(type(self), self).__init__(**kwargs)
if self.std_dev is None:
self.std_dev = (self.width / 2) * 0.1
self._texture = None
self._mask_texture = None
self._period = None
self.bind(envelope=self._update_texture,
std_dev=self._update_texture,
phase=self._update_texture,
def __init__(self, *args, **kwargs):
super(InterpreterSettingsScreen, self).__init__(*args, **kwargs)
for attr in dir(self):
if attr.startswith('setting__'):
self.bind(**{attr: partial(self.setting_updated, attr)})
def setting_updated(self, setting, instance, value):
setattr(App.get_running_app(), setting, value)
class ButtonCheckbox(ButtonBehavior, Label):
active = BooleanProperty(True)
box_size = NumericProperty()
draw_colour = ListProperty((0.2, 0.2, 0.2, 1))
text_colour = ListProperty((0.0, 0.0, 0.0, 1))
handle_touch = BooleanProperty(True)
def on_touch_down(self, touch):
if not self.handle_touch:
return False
return super(ButtonCheckbox, self).on_touch_down(touch)
class ButtonRadio(ButtonBehavior, Widget):
box_size = NumericProperty()
radio_offset = NumericProperty()
active = BooleanProperty()
class SettingsTitle(Label):
pass