Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _erosion_cmd(self, _type, j):
if _type == '_test':
self._show_test(j)
elif _type == '_init':
self.desert.init(
fg=Rgba.from_json(j['_data']['fg']),
bg=Rgba.from_json(j['_data']['bg']),
)
elif _type == '_save':
self.save()
else:
print('## warn: erosion. unknown cmd: {:s}'.format(_type))
def _erosion_cmd(self, _type, j):
if _type == '_test':
self._show_test(j)
elif _type == '_init':
self.desert.init(
fg=Rgba.from_json(j['_data']['fg']),
bg=Rgba.from_json(j['_data']['bg']),
)
elif _type == '_save':
self.save()
else:
print('## warn: erosion. unknown cmd: {:s}'.format(_type))
# -*- coding: utf-8 -*-
from .primitives import box
from .primitives import bzspl
from .primitives import circle
from .primitives import stroke
from .color import Rgba
types = {
'box': box.from_json,
'circle': circle.from_json,
'stroke': stroke.from_json,
'bzspl': bzspl.from_json,
'rgba': Rgba.from_json,
}
def type_router(o):
_type = o['_type']
return types[_type](o)
c = circle(0.05, ((0.5, 0.4), (0.8, 0.4)), 1.0).json()
pprint(c)
pprint(circle.from_json(c).json())
pprint()
c = circle(0.05, ((0.5, 0.4), (0.8, 0.4)), 1.0)\
.rgb([
black(0.3),
black(0.1)]).json()
pprint(c)
pprint(circle.from_json(c).json())
pprint()
r = rgb(0.1, 0.4, 0.3, 0.99).json()
pprint(r)
pprint(Rgba.from_json(r).json())
pprint()
b = bzspl([[(0.1, 0.2),
(0.4, 0.25),
(0.9, 0.15),
(0.9, 0.3),
(0.95, 0.45),
(0.8, 0.9)]], 2, closed=True).json()
pprint(b)
pprint(bzspl.from_json(b).json())
pprint()
b2 = bzspl([[(0.1, 0.2),
(0.3, 0.4),
(0.5, 0.6)],
def _load_color(o, data):
cc = data.get('rgba')
if cc is not None:
if isinstance(cc, list):
return o.rgb([Rgba.from_json(c) for c in cc])
return o.rgb(Rgba.from_json(cc))
return o
def _load_color(o, data):
cc = data.get('rgba')
if cc is not None:
if isinstance(cc, list):
return o.rgb([Rgba.from_json(c) for c in cc])
return o.rgb(Rgba.from_json(cc))
return o