mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
a7a07fb6d5
- Convert from {@code ...} to shorter `...` - Reformat some documentation comment blocks - Update copyright notices
62 lines
1.9 KiB
JavaScript
62 lines
1.9 KiB
JavaScript
/*
|
|
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
|
* http://paperjs.org/
|
|
*
|
|
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
|
|
* http://scratchdisk.com/ & http://jonathanpuckey.com/
|
|
*
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
*
|
|
* All rights reserved.
|
|
*/
|
|
|
|
var SVGStyles = Base.each({
|
|
// Fill
|
|
fillColor: ['fill', 'color'],
|
|
fillRule: ['fill-rule', 'string'],
|
|
// Stroke
|
|
strokeColor: ['stroke', 'color'],
|
|
strokeWidth: ['stroke-width', 'number'],
|
|
strokeCap: ['stroke-linecap', 'string'],
|
|
strokeJoin: ['stroke-linejoin', 'string'],
|
|
strokeScaling: ['vector-effect', 'lookup', {
|
|
true: 'none',
|
|
false: 'non-scaling-stroke'
|
|
}, function(item, value) {
|
|
// no inheritance, only applies to graphical elements
|
|
return !value // false, meaning non-scaling-stroke
|
|
&& (item instanceof PathItem
|
|
|| item instanceof Shape
|
|
|| item instanceof TextItem);
|
|
}],
|
|
miterLimit: ['stroke-miterlimit', 'number'],
|
|
dashArray: ['stroke-dasharray', 'array'],
|
|
dashOffset: ['stroke-dashoffset', 'number'],
|
|
// Text
|
|
fontFamily: ['font-family', 'string'],
|
|
fontWeight: ['font-weight', 'string'],
|
|
fontSize: ['font-size', 'number'],
|
|
justification: ['text-anchor', 'lookup', {
|
|
left: 'start',
|
|
center: 'middle',
|
|
right: 'end'
|
|
}],
|
|
// Item
|
|
opacity: ['opacity', 'number'],
|
|
blendMode: ['mix-blend-mode', 'string']
|
|
}, function(entry, key) {
|
|
var part = Base.capitalize(key),
|
|
lookup = entry[2];
|
|
this[key] = {
|
|
type: entry[1],
|
|
property: key,
|
|
attribute: entry[0],
|
|
toSVG: lookup,
|
|
fromSVG: lookup && Base.each(lookup, function(value, name) {
|
|
this[value] = name;
|
|
}, {}),
|
|
exportFilter: entry[3],
|
|
get: 'get' + part,
|
|
set: 'set' + part
|
|
};
|
|
}, {});
|