from six.moves import xrange from scss import config from scss.functions.compass import _image_size_cache from scss.functions.compass.layouts import PackedSpritesLayout, HorizontalSpritesLayout, VerticalSpritesLayout, DiagonalSpritesLayout from scss.functions.library import FunctionLibrary from scss.types import ColorValue, List, NumberValue, QuotedStringValue, StringValue from scss.util import escape log = logging.getLogger(__name__) MAX_SPRITE_MAPS = 4096 KEEP_SPRITE_MAPS = int(MAX_SPRITE_MAPS * 0.8) COMPASS_SPRITES_LIBRARY = FunctionLibrary() register = COMPASS_SPRITES_LIBRARY.register # ------------------------------------------------------------------------------ # Compass-like functionality for sprites and images sprite_maps = {} def alpha_composite(im1, im2, offset=None, box=None, opacity=1): im1size = im1.size im2size = im2.size if offset is None: offset = (0, 0) if box is None:
from scss.functions.library import FunctionLibrary from scss.functions.compass.helpers import _font_url from scss.functions.compass.images import _image_url BOOTSTRAP_LIBRARY = FunctionLibrary() register = BOOTSTRAP_LIBRARY.register @register('twbs-font-path', 1) def twbs_font_path(path): return _font_url(path, False, True, False) @register('twbs-image-path', 1) def twbs_image_path(path): return _image_url(path, False, True, None, None, False, None, None, None, None)
try: import fontforge except: fontforge = None from scss import config from scss.functions.library import FunctionLibrary from scss.types import String, Boolean, List from scss.util import getmtime, escape, make_data_url, make_filename_hash log = logging.getLogger(__name__) MAX_FONT_SHEETS = 4096 KEEP_FONT_SHEETS = int(MAX_FONT_SHEETS * 0.8) FONTS_LIBRARY = FunctionLibrary() register = FONTS_LIBRARY.register FONT_MIME_TYPES = { 'ttf': 'application/x-font-ttf', 'svg': 'image/svg+xml', 'woff': 'application/x-font-woff', 'eot': 'application/vnd.ms-fontobject', } FONT_FORMATS = { 'ttf': "format('truetype')", 'svg': "format('svg')", 'woff': "format('woff')", 'eot': "format('embedded-opentype')", }
import base64 import logging import math import mimetypes import os.path import time from scss import config from scss.cssdefs import _undefined_re from scss.functions.library import FunctionLibrary from scss.types import BooleanValue, ListValue, NumberValue, StringValue, Value from scss.util import escape, to_str log = logging.getLogger(__name__) COMPASS_HELPERS_LIBRARY = FunctionLibrary() register = COMPASS_HELPERS_LIBRARY.register def add_cache_buster(url, mtime): fragment = url.split('#') query = fragment[0].split('?') if len(query) > 1 and query[1] != '': cb = '&_=%s' % (mtime) url = '?'.join(query) + cb else: cb = '?_=%s' % (mtime) url = query[0] + cb if len(fragment) > 1: url += '#' + fragment[1] return url
from scss.functions.compass.helpers import add_cache_buster from scss.functions.library import FunctionLibrary from scss.types import Color, List, Number, String from scss.util import escape, getmtime try: from PIL import Image except ImportError: try: import Image except: Image = None log = logging.getLogger(__name__) COMPASS_IMAGES_LIBRARY = FunctionLibrary() register = COMPASS_IMAGES_LIBRARY.register # ------------------------------------------------------------------------------ def _images_root(): return config.STATIC_ROOT if config.IMAGES_ROOT is None else config.IMAGES_ROOT def _image_url(path, only_path=False, cache_buster=True, dst_color=None, src_color=None, inline=False,
""" from __future__ import absolute_import from __future__ import division import logging import math from six.moves import xrange from scss.functions.library import FunctionLibrary from scss.types import Boolean, Color, List, Null, Number, String, Map, expect_type log = logging.getLogger(__name__) CORE_LIBRARY = FunctionLibrary() register = CORE_LIBRARY.register # ------------------------------------------------------------------------------ # Color creation def _interpret_percentage(n, relto=1., clamp=True): expect_type(n, Number, unit='%') if n.is_unitless: ret = n.value / relto else: ret = n.value / 100 if clamp:
from scss.functions.library import FunctionLibrary from scss.types import Color, Number, String, List from scss.util import escape try: from PIL import Image, ImageDraw except ImportError: try: import Image import ImageDraw except: Image = None log = logging.getLogger(__name__) EXTRA_LIBRARY = FunctionLibrary() register = EXTRA_LIBRARY.register # ------------------------------------------------------------------------------ # Image stuff def _image_noise(pixdata, size, density=None, intensity=None, color=None, opacity=None, monochrome=None, background=None): if not density: density = [0.8] elif not isinstance(density, (tuple, list)): density = [density] if not intensity: intensity = [0.5] elif not isinstance(intensity, (tuple, list)): intensity = [intensity]
import math import os.path import time from scss.six import six from scss import config from scss.functions.library import FunctionLibrary from scss.types import Boolean, List, Null, Number, String from scss.util import escape, to_str import re log = logging.getLogger(__name__) COMPASS_HELPERS_LIBRARY = FunctionLibrary() register = COMPASS_HELPERS_LIBRARY.register FONT_TYPES = { 'woff': 'woff', 'otf': 'opentype', 'opentype': 'opentype', 'ttf': 'truetype', 'truetype': 'truetype', 'svg': 'svg', 'eot': 'embedded-opentype' } def add_cache_buster(url, mtime): fragment = url.split('#')
from __future__ import absolute_import import base64 import logging from scss.six import six from scss.functions.library import FunctionLibrary from scss.functions.compass.helpers import opposite_position, position from scss.types import Color, List, Number, String from scss.util import escape, split_params, to_float, to_str log = logging.getLogger(__name__) COMPASS_GRADIENTS_LIBRARY = FunctionLibrary() register = COMPASS_GRADIENTS_LIBRARY.register # ------------------------------------------------------------------------------ def __color_stops(percentages, *args): if len(args) == 1: if isinstance(args[0], (list, tuple, List)): list(args[0]) elif isinstance(args[0], (String, six.string_types)): color_stops = [] colors = split_params(getattr(args[0], 'value', args[0])) for color in colors: color = color.strip() if color.startswith('color-stop('):
import logging import math import mimetypes import os.path import time import six from scss import config from scss.functions.library import FunctionLibrary from scss.types import BooleanValue, List, Null, NumberValue, QuotedStringValue, StringValue from scss.util import escape, to_str log = logging.getLogger(__name__) COMPASS_HELPERS_LIBRARY = FunctionLibrary() register = COMPASS_HELPERS_LIBRARY.register def add_cache_buster(url, mtime): fragment = url.split('#') query = fragment[0].split('?') if len(query) > 1 and query[1] != '': cb = '&_=%s' % (mtime) url = '?'.join(query) + cb else: cb = '?_=%s' % (mtime) url = query[0] + cb if len(fragment) > 1: url += '#' + fragment[1] return url
import logging import math import os.path import time import six from scss import config from scss.functions.library import FunctionLibrary from scss.types import Boolean, List, Null, Number, String from scss.util import escape, to_str, getmtime import re log = logging.getLogger(__name__) COMPASS_HELPERS_LIBRARY = FunctionLibrary() register = COMPASS_HELPERS_LIBRARY.register FONT_TYPES = { 'woff': 'woff', 'otf': 'opentype', 'opentype': 'opentype', 'ttf': 'truetype', 'truetype': 'truetype', 'svg': 'svg', 'eot': 'embedded-opentype' } def add_cache_buster(url, mtime): fragment = url.split('#')
from __future__ import absolute_import from scss.functions.library import FunctionLibrary from scss.functions.core import CORE_LIBRARY from scss.functions.extra import EXTRA_LIBRARY from scss.functions.compass.sprites import COMPASS_SPRITES_LIBRARY from scss.functions.compass.gradients import COMPASS_GRADIENTS_LIBRARY from scss.functions.compass.helpers import COMPASS_HELPERS_LIBRARY from scss.functions.compass.images import COMPASS_IMAGES_LIBRARY from scss.functions.bootstrap import BOOTSTRAP_LIBRARY ALL_BUILTINS_LIBRARY = FunctionLibrary() ALL_BUILTINS_LIBRARY.inherit( CORE_LIBRARY, EXTRA_LIBRARY, COMPASS_GRADIENTS_LIBRARY, COMPASS_HELPERS_LIBRARY, COMPASS_IMAGES_LIBRARY, COMPASS_SPRITES_LIBRARY, BOOTSTRAP_LIBRARY, ) # TODO back-compat for the only codebase still using the old name :) FunctionRegistry = FunctionLibrary scss_builtins = ALL_BUILTINS_LIBRARY
""" from __future__ import absolute_import import colorsys import logging import math import operator from scss.cssdefs import _conv_type, _units, _units_weights, _variable_re from scss.functions.library import FunctionLibrary from scss.types import BooleanValue, ColorValue, ListValue, NumberValue, QuotedStringValue, StringValue, Value log = logging.getLogger(__name__) CORE_LIBRARY = FunctionLibrary() register = CORE_LIBRARY.register # ------------------------------------------------------------------------------ # Color creation def _color_type(color, a, type): color = ColorValue(color).value a = NumberValue(a).value if a is not None else color[3] col = list(color[:3]) col += [0.0 if a < 0 else 1.0 if a > 1 else a] col += [type] return ColorValue(col) @register('rgba', 4)
""" from __future__ import absolute_import from __future__ import division import logging import math from six.moves import xrange from scss.functions.library import FunctionLibrary from scss.types import Boolean, Color, List, Null, Number, String, Map, expect_type log = logging.getLogger(__name__) CORE_LIBRARY = FunctionLibrary() register = CORE_LIBRARY.register # ------------------------------------------------------------------------------ # Color creation def _interpret_percentage(n, relto=1.0, clamp=True): expect_type(n, Number, unit="%") if n.is_unitless: ret = n.value / relto else: ret = n.value / 100