How to use the desert.color.Rgba.from_json function in desert

To help you get started, we’ve selected a few desert examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inconvergent / desert / erosion / erosion.py View on Github external
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))
github inconvergent / desert / erosion / erosion.py View on Github external
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))
github inconvergent / desert / desert / type_router.py View on Github external
# -*- 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)
github inconvergent / desert / examples / export.py View on Github external
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)],
github inconvergent / desert / desert / primitives.py View on Github external
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
github inconvergent / desert / desert / primitives.py View on Github external
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