Esempio n. 1
0
 def to__owg():
     args = [
         'linear',
         position(position_and_angle or None),
         opposite_position(position_and_angle or None),
     ]
     args.extend('color-stop(%s, %s)' % (s.render(), c.render()) for s, c in color_stops)
     ret = '-webkit-gradient(' + ', '.join(to_str(a) for a in args if a is not None) + ')'
     return String.unquoted(ret)
Esempio n. 2
0
 def to__owg():
     args = [
         'linear',
         position(position_and_angle or 'center top'),
         opposite_position(position_and_angle or 'center top'),
     ]
     args.extend('color-stop(%s, %s)' % (to_str(s), c) for s, c in color_stops)
     ret = '-webkit-gradient(' + ', '.join(to_str(a) for a in args or [] if a is not None) + ')'
     return StringValue(ret)
Esempio n. 3
0
 def to__owg():
     args = [
         'linear',
         position(position_and_angle or None),
         opposite_position(position_and_angle or None),
     ]
     args.extend('color-stop(%s, %s)' % (s.render(), c.render()) for s, c in color_stops)
     ret = '-webkit-gradient(' + ', '.join(to_str(a) for a in args if a is not None) + ')'
     return String.unquoted(ret)
Esempio n. 4
0
 def to__owg():
     args = [
         'linear',
         position(position_and_angle or None),
         opposite_position(position_and_angle or None),
     ]
     args.extend('color-stop(%s, %s)' % (to_str(s), c)
                 for s, c in color_stops)
     ret = '-webkit-gradient(' + ', '.join(
         to_str(a) for a in args or [] if a is not None) + ')'
     return StringValue(ret, quotes=None)
Esempio n. 5
0
def linear_svg_gradient(*args):
    args = List.from_maybe_starargs(args)
    color_stops = args
    start = None
    if isinstance(args[-1], (String, Number, six.string_types)):
        start = args[-1]
        color_stops = args[:-1]
    color_stops = __color_stops(False, *color_stops)
    x1, y1 = zip(*grad_point(start).items())[1]
    x2, y2 = zip(*grad_point(opposite_position(start)).items())[1]
    svg = _linear_svg(color_stops, x1, y1, x2, y2)
    url = 'data:' + 'image/svg+xml' + ';base64,' + base64.b64encode(svg)
    inline = 'url("%s")' % escape(url)
    return String.unquoted(inline)
Esempio n. 6
0
def linear_svg_gradient(*args):
    args = List.from_maybe_starargs(args)
    color_stops = args
    start = None
    if isinstance(args[-1], (String, Number, six.string_types)):
        start = args[-1]
        color_stops = args[:-1]
    color_stops = __color_stops(False, *color_stops)
    x1, y1 = zip(*grad_point(start).items())[1]
    x2, y2 = zip(*grad_point(opposite_position(start)).items())[1]
    svg = _linear_svg(color_stops, x1, y1, x2, y2)
    url = 'data:' + 'image/svg+xml' + ';base64,' + base64.b64encode(svg)
    inline = 'url("%s")' % escape(url)
    return String.unquoted(inline)
Esempio n. 7
0
def linear_svg_gradient(*args):
    if len(args) == 1 and isinstance(args[0], (list, tuple, ListValue)):
        args = ListValue(args[0]).values()
    color_stops = args
    start = None
    if isinstance(args[-1], (StringValue, NumberValue, basestring)):
        start = args[-1]
        color_stops = args[:-1]
    color_stops = __color_stops(False, *color_stops)
    x1, y1 = zip(*grad_point(start).items())[1]
    x2, y2 = zip(*grad_point(opposite_position(start)).items())[1]
    svg = _linear_svg(color_stops, x1, y1, x2, y2)
    url = 'data:' + 'image/svg+xml' + ';base64,' + base64.b64encode(svg)
    inline = 'url("%s")' % escape(url)
    return StringValue(inline)