1376,6,149,8,137,17,100,18,1740,36,1801,49,493,47,756,51,911,44,1917,53,367,51,468,55,613,38,382,41,992,48,337,26,967,42,906,47,1243,40,211,33,591,28,246,32,981,33,1625,25,5895,28,4039,26,379,44,1008,34,2339,42,1091,38,626,46,269,44,391,44,275,38,370,46,899,36,234,52,723,32,410,34,391,36,248,38,212,33,602,55,462,42,1100,38,4063,40,794,52,886,52,327,38,470,40,1461,67,343,53,1358,38,582,42,1423,30,1330,17,657,21,2105,29,1890,28,1402,27,1793,26,2504,27,1606,27,2025,27,1716,26,2609,27,1806,11,189,27,1858,26,2564,25,2720,26,1181,26,2523,26,1256,25,2657,26,1862,46,647,45,738,19,3118,61,347,37,161,17,555,23,129,42,232,28,539,27,1623,26,2490,25,1312,26,1217,26,2248,26,1311,25,1382,26,1307,19,2302,62,171,46,724,66,681,68,943,41,330,32,420,56,376,44,163,37,617,48,374,46,580,35,398,77,383,65,317,63,538,82,462,57,596,42,891,47,253,49,391,56,443,55,363,33,676,35,119,45,364,66,1093,35,1103,35,156,42,756,60,470,49,374,47,183,56,552,58,374,40,208,33,982,46,214,48,283,35,333,61,288,42,847,15,925,38,392,31,159,32,294,24,265,31,162,29,206,40,492,31,211,31,112,33,585,62,189,71,735,73,444,51,900,66,681,68,943,68,171,32,362,37,787,46,580,46,764,59,586,35,562,77,383,65,317,63,538,82,462,44,231,49,404,56,443,55,363,33,651,35,125,45,364,58,191,66,1091,35,1119,35,752,51,166,51,365,46,254,57,191,51,126,33,968,44,201,44,170,50,1112,35,572,48,1330,24,303,31,105,19,725,19,317,21,378
_info
{"project":"lsg2","branch":"master","version":262,"versionDate":"2024-05-29T04:17:28.000Z","fromVersion":0,"reset":true,"checksumDocs":"188-164697"}
init.ls
(function(){
return function(){
if (typeof LSG2 == 'undefined' || LSG2 === null) {
return window.LSG2 = include('lsg/lsg')();
}
};
})();
lib/svg/error.ls
(function(){
return {
vendor: 'bigstock',
vendorId: '109066487',
tags: ['error', 'hazard']
};
})();
lib/svg/error.svg
lib/util/getRequired/getRequired.ls
(function(){
return function(lsg, required, done){
var nestedLsgPaths, nestedLsgRenderers, nestedLsgObjects, objects, i$, len$, object, ref$, project, ref1$, ref2$, ref3$;
if (!done) {
done = required;
required = {
svgs: [],
images: [],
projects: []
};
}
if (!nestedLsgPaths) {
nestedLsgPaths = [];
}
if (!nestedLsgRenderers) {
nestedLsgRenderers = [];
}
if (!nestedLsgObjects) {
nestedLsgObjects = [];
}
objects = lsg.objects;
if (objects) {
if (!_.isArray(objects)) {
objects = [objects];
}
for (i$ = 0, len$ = objects.length; i$ < len$; ++i$) {
object = objects[i$];
if (object.type === 'svg') {
if (((ref$ = object.svg) != null ? ref$.slice(0, 4) : void 8) === '/../' && object.includeSvg) {
project = object.svg.split('/')[2];
required.projects.push(project);
} else if (((ref1$ = object.svg) != null ? ref1$.slice(0, 4) : void 8) === '/../') {
required.svgs.push(object.svg);
}
} else if (object.type === 'lsg') {
if (object.lsg && _.isObject(object.lsg)) {
nestedLsgObjects.push(object.lsg);
} else if (((ref2$ = object.lsg) != null ? ref2$.slice(0, 4) : void 8) === '/../' && _.includes(object.lsg, '.lsr')) {
nestedLsgRenderers.push(object);
} else if (((ref3$ = object.lsg) != null ? ref3$.slice(0, 4) : void 8) === '/../') {
nestedLsgPaths.push(object.lsg);
}
} else if (object.type === "image") {
required.images.push(object.image);
}
}
}
include('resolveNested/lsgPaths')(required, nestedLsgPaths, function(required){
return include('resolveNested/lsgRenderers')(required, nestedLsgRenderers, function(required){
return include('resolveNested/lsgObjects')(required, nestedLsgObjects, function(required){
required.projects = _.uniq(required.projects);
required.svgs = _.uniq(required.svgs);
return typeof done == 'function' ? done(required) : void 8;
});
});
});
return required;
};
})();
lib/util/getRequired/resolveNested/lsgObjects.ls
(function(){
return function(required, objects, done){
var total, count, resolve;
if (!objects.length) {
done(required);
return;
}
total = objects.length;
count = 0;
resolve = function(object){
return LSG2.util.getRequired(object, required, function(r){
required.projects = required.projects.concat(r.projects);
required.svgs = required.svgs.concat(r.svgs);
if (++count === total) {
return done(required);
}
});
};
return _.each(objects, function(object){
return resolve(object);
});
};
})();
lib/util/getRequired/resolveNested/lsgPaths.ls
(function(){
return function(required, paths, done){
var total, count, resolve, p;
if (!paths.length) {
done(required);
return;
}
total = paths.length;
count = 0;
resolve = function(path){
var jsg;
jsg = include(path);
return LSG2.util.getRequired(jsg, required, function(r){
required.projects = required.projects.concat(r.projects);
required.svgs = required.svgs.concat(r.svgs);
if (++count === total) {
return done(required);
}
});
};
p = _.uniq(_.map(paths, function(path){
return path.split('/')[2];
}));
p = _.filter(p, function(project){
var ref$;
return ((ref$ = projects.info()[project]) != null ? ref$.isLoaded : void 8) !== true;
});
return projects.load(p, function(){
return _.each(paths, function(path){
return resolve(path);
});
});
};
})();
lib/util/getRequired/resolveNested/lsgRenderers.ls
(function(){
return function(required, objects, done){
var total, count, resolve, p;
if (!objects.length) {
done(required);
return;
}
total = objects.length;
count = 0;
resolve = function(object){
var renderer, object2, jsg;
renderer = include(object.lsg);
object2 = _.cloneDeep(object);
jsg = renderer.render
? renderer.render(object2)
: renderer(object2);
return LSG2.util.getRequired(jsg, required, function(r){
required.projects = required.projects.concat(r.projects);
required.svgs = required.svgs.concat(r.svgs);
if (++count === total) {
return done(required);
}
});
};
p = _.uniq(_.map(objects, function(object){
return object.lsg.split('/')[2];
}));
p = _.filter(p, function(project){
var ref$;
return ((ref$ = projects.info()[project]) != null ? ref$.isLoaded : void 8) !== true;
});
return projects.load(p, function(){
return _.each(objects, function(object){
return resolve(object);
});
});
};
})();
lib/util/getRequiredSync/getRequiredSync.ls
(function(){
return function(lsg){
var required, nestedLsgPaths, nestedLsgRenderers, nestedLsgObjects, objects, i$, len$, object, ref$, project, ref1$, ref2$, ref3$, r;
required = {
svgs: [],
projects: [],
images: []
};
if (!nestedLsgPaths) {
nestedLsgPaths = [];
}
if (!nestedLsgRenderers) {
nestedLsgRenderers = [];
}
if (!nestedLsgObjects) {
nestedLsgObjects = [];
}
objects = lsg.objects;
if (objects) {
if (!_.isArray(objects)) {
objects = [objects];
}
for (i$ = 0, len$ = objects.length; i$ < len$; ++i$) {
object = objects[i$];
if (object.type === 'svg') {
if (((ref$ = object.svg) != null ? ref$.slice(0, 4) : void 8) === '/../' && object.includeSvg) {
project = object.svg.split('/')[2];
required.projects.push(project);
} else if (((ref1$ = object.svg) != null ? ref1$.slice(0, 4) : void 8) === '/../') {
required.svgs.push(object.svg);
}
} else if (object.type === 'lsg') {
if (object.lsg && _.isObject(object.lsg)) {
nestedLsgObjects.push(object.lsg);
} else if (((ref2$ = object.lsg) != null ? ref2$.slice(0, 4) : void 8) === '/../' && _.includes(object.lsg, '.lsr')) {
nestedLsgRenderers.push(object);
} else if (((ref3$ = object.lsg) != null ? ref3$.slice(0, 4) : void 8) === '/../') {
nestedLsgPaths.push(object.lsg);
}
} else if (object.type === 'image') {
required.images.push(object.image);
}
}
}
r = include('resolveNested/lsgPaths')(nestedLsgPaths);
required.projects = required.projects.concat(r.projects);
required.svgs = required.svgs.concat(r.svgs);
r = include('resolveNested/lsgRenderers')(nestedLsgRenderers);
required.projects = required.projects.concat(r.projects);
required.svgs = required.svgs.concat(r.svgs);
r = include('resolveNested/lsgObjects')(nestedLsgObjects);
required.projects = required.projects.concat(r.projects);
required.svgs = required.svgs.concat(r.svgs);
required.projects = _.uniq(required.projects);
required.svgs = _.uniq(required.svgs);
return required;
};
})();
lib/util/getRequiredSync/resolveNested/lsgObjects.ls
(function(){
return function(objects, done){
var required, i$, len$, object, r;
required = {
svgs: [],
projects: []
};
for (i$ = 0, len$ = objects.length; i$ < len$; ++i$) {
object = objects[i$];
r = LSG2.util.getRequiredSync(object);
required.projects = required.projects.concat(r.projects);
required.svgs = required.svgs.concat(r.svgs);
}
return required;
};
})();
lib/util/getRequiredSync/resolveNested/lsgPaths.ls
(function(){
return function(paths, done){
var required, i$, len$, path, jsg, r;
required = {
svgs: [],
projects: []
};
required.projects = _.uniq(_.map(paths, function(path){
return path.split('/')[2];
}));
for (i$ = 0, len$ = paths.length; i$ < len$; ++i$) {
path = paths[i$];
jsg = include(path);
r = LSG2.util.getRequiredSync(jsg);
required.projects = required.projects.concat(r.projects);
required.svgs = required.svgs.concat(r.svgs);
}
return required;
};
})();
lib/util/getRequiredSync/resolveNested/lsgRenderers.ls
(function(){
return function(objects){
var required, i$, len$, object, renderer, object2, jsg, r;
required = {
svgs: [],
projects: []
};
required.projects = _.uniq(_.map(objects, function(object){
return object.lsg.split('/')[2];
}));
for (i$ = 0, len$ = objects.length; i$ < len$; ++i$) {
object = objects[i$];
renderer = include(object.lsg);
object2 = _.cloneDeep(object);
jsg = renderer.render
? renderer.render(object2)
: renderer(object2);
r = LSG2.util.getRequiredSync(jsg);
required.projects = required.projects.concat(r.projects);
required.svgs = required.svgs.concat(r.svgs);
}
return required;
};
})();
lib/util/isSafariLt13/isSafariLt13.ls
(function(){
return function(){
var ua, isSafariLt13;
ua = navigator.userAgent;
return isSafariLt13 = (ua.match(/iPad/i) || ua.match(/iPhone/i) || ua.match(/Mac OS/i)) && (ua.match(/Version\/9/i) || ua.match(/OS\ 9/i) || ua.match(/Version\/10/i) || ua.match(/OS\ 10/i) || ua.match(/Version\/11/i) || ua.match(/OS\ 11/i) || ua.match(/Version\/12/i) || ua.match(/OS\ 12/i));
};
})();
lib/util/jsToLs/formatFunction/format.ls
(function(){
return function(object, spaces){
var result, expr, lines, leadingSpacesLength, leadingSpaces;
result = object.toString();
result = result.replace("function", "");
result = result.replace("{", " ->");
result = result.substring(0, result.lastIndexOf("}"));
result = result.substring(0, result.lastIndexOf("\n"));
expr = /(if .*)( {)((\s*.*\s*)*?)(\} ?)/gm;
result = result.replace(expr, "$1$3");
expr = /(else)( {)((\s*.*\s*)*?)(\})/gm;
result = result.replace(expr, "$1$3");
expr = /(while .*)( {)((\s*.*\s*)*?)(\})/gm;
result = result.replace(expr, "$1$3");
expr = /(.*?)(\s*;?$)/gm;
result = result.replace(expr, "$1");
lines = result.split("\n");
leadingSpacesLength = lines[1].match(/^\s+/)[0].length;
leadingSpaces = repeatString$(' ', leadingSpacesLength);
expr = new RegExp("^" + leadingSpaces, "gm");
return result = result.replace(expr, spaces);
};
})();
function repeatString$(str, n){
for (var r = ''; n > 0; (n >>= 1) && (str += str)) if (n & 1) r += str;
return r;
}
lib/util/jsToLs/formatMultilineString/format.ls
(function(){
return function(object, spaces){
var lines, res$, i$, ref$, len$, line;
res$ = [];
for (i$ = 0, len$ = (ref$ = object.split("\n")).length; i$ < len$; ++i$) {
line = ref$[i$];
res$.push(spaces + " " + line);
}
lines = res$;
lines.unshift("\n" + spaces + "'''");
lines.push(spaces + "'''");
return lines.join("\n");
};
})();
lib/util/jsToLs/jsToLs.ls
(function(){
var color, jsToLs;
color = include('/lib/util/resolveColor/resolveColor');
return jsToLs = function(object, indent, array){
var result, spaces, index;
if (!indent) {
indent = 1;
}
result = '';
spaces = Array(indent).join(' ');
if (_.isString(object)) {
if (object.split("\n").length > 1) {
result = inc("formatMultilineString/format")(object, spaces);
} else {
result = color(object) + "";
}
} else if (_.isArray(object)) {
_.each(object, function(val, index){
var lr;
lr = array && index === 0
? ''
: '\n' + spaces;
result += lr + "* " + jsToLs(val, indent + 1, true);
if (object.length === 1) {
return result += "\n" + spaces + "...";
}
});
} else if (_.isFunction(object)) {
result = inc("formatFunction/format")(object, spaces);
} else if (_.isObject(object)) {
index = 0;
_.each(object, function(val, key){
result += "\n" + spaces + key + ": " + jsToLs(val, indent + 1);
return index++;
});
} else {
result = object + "";
}
return result;
};
})();
lib/util/loadRemoteSvg/loadFromDb/load.ls
(function(){
return function(absPath, done){
var onError, onDone, server, url, relPath, fileName, data;
if (_.last(absPath.split('.')) === "lsg") {
done();
return;
}
if (absPath.slice(0, 10) !== "/../c-svg/") {
done();
return;
}
onError = function(error){
helpers.errorHandler("file not found: " + absPath, "/../lsg2/lib/util/loadRemoteSvg/loadFromDb/load");
return done();
};
onDone = function(error, result){
var svgParser, svgDoc, svg;
if (error) {
onError();
return;
}
if (typeof result === "string") {
svgParser = new DOMParser();
svgDoc = svgParser.parseFromString(result, 'image/svg+xml');
svg = svgDoc.documentElement;
done(svg);
return;
}
return onError();
};
server = "https://svgs.solocode.com";
url = server + "/svg";
relPath = absPath.replace("/../c-svg/", "");
fileName = relPath.replace(/\//g, "-");
data = {
fileName: fileName
};
return helpers.httpRequest.get(url, data, onDone);
};
})();
lib/util/loadRemoteSvg/loadFromProject/load.ls
(function(){
return function(absPath, done){
var p, s, info, ref$, server, project, branch, file, url, data, onDone;
p = LSG2.util.resolvePath(absPath);
s = helpers.resolveProject(p.project);
info = (ref$ = projects.info()[p.project]) != null && ref$.isLoaded ? projects.info()[p.project] : void 8;
server = (info != null ? info.server : void 8) || s.server;
project = p.project;
branch = (info != null ? info.branch : void 8) || s.branch;
if (_.includes(branch, "_ide")) {
branch = branch.replace("_ide", "");
}
file = p.file;
url = server + "/document";
data = {
project: project,
branch: branch,
path: file
};
onDone = function(error, result){
var svgParser, svgDoc, svg, jsg;
if (!(result != null && result.text) || error) {
helpers.errorHandler("file not found: " + absPath, "/../lsg2/lib/util/loadRemoteSvg/loadFromProject/load");
done();
return;
}
if (p.type === 'svg') {
svgParser = new DOMParser();
svgDoc = svgParser.parseFromString(result.text, 'image/svg+xml');
svg = svgDoc.documentElement;
return done(svg);
} else {
try {
jsg = eval(result.text);
} catch (e$) {
error = e$;
helpers.errorHandler(error, absPath);
return;
}
svg = LSG2.toSVG(jsg);
return done(svg);
}
};
return helpers.httpRequest.get(url, data, onDone);
};
})();
lib/util/loadRemoteSvg/loadRemoteSvg.ls
(function(){
return function(absPath, done){
return include("loadFromDb/load")(absPath, function(svg){
if (svg) {
return done(svg);
} else {
return include("loadFromProject/load")(absPath, done);
}
});
};
})();
lib/util/loadRenderer/loadLsg.ls
(function(){
return function(absPath, done){
var p, s, url, data, d;
p = LSG2.util.resolvePath(absPath);
s = helpers.resolveProject(p.project);
url = s.server + "/document";
data = {
project: p.project,
branch: s.branch,
path: p.file
};
d = function(error, result){
var jsg;
if (!(result != null && result.text)) {
helpers.errorHandler("file not found: " + absPath, '/../lsg/util/loadLsg/loadLsg');
done();
return;
}
try {
jsg = eval(result.text);
} catch (e$) {
error = e$;
helpers.errorHandler(error, absPath);
}
return done(jsg);
};
return helpers.httpRequest.get(url, data, d);
};
})();
lib/util/makeSvg/makeSvg.ls
(function(){
return function(tag, attrs){
var element, a;
element = document.createElementNS('http://www.w3.org/2000/svg', tag);
for (a in attrs) {
if (attrs[a] || attrs[a] === 0) {
element.setAttribute(a, attrs[a]);
}
}
return element;
};
})();
lib/util/parsePath/parsePath.ls
(function(){
var length, segment, number, parse, parseValues;
length = {
a: 7,
c: 6,
h: 1,
l: 2,
m: 2,
q: 4,
s: 4,
t: 2,
v: 1,
z: 0
};
segment = /([astvzqmhlc])([^astvzqmhlc]*)/ig;
number = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;
parse = function(path){
var data;
data = [];
path.replace(segment, function(_, command, args){
var type;
type = command.toLowerCase();
args = parseValues(args);
if (type === 'm' && args.length > 2) {
data.push([command].concat(args.splice(0, 2)));
type = 'l';
command = command === 'm' ? 'l' : 'L';
}
for (;;) {
if (args.length === length[type]) {
args.unshift(command);
return data.push(args);
}
if (args.length < length[type]) {
throw new Error('malformed path data');
}
data.push([command].concat(args.splice(0, length[type])));
}
});
return data;
};
parseValues = function(args){
var numbers;
numbers = args.match(number);
console.log('numbers', args, numbers);
if (numbers) {
return numbers.map(Number);
} else {
return [];
}
};
return parse;
})();
lib/util/pathApi/newtonSolver.js
// NewtonSolver by Walter Bislin, 07.10.2015
// http://walter.bislins.ch
// You may do what ever you want with this file and code!
(function(){
var NewtonSolver = { MaxLoops: 1000, Result: 0, Status: '', NLoops: 0 };
var SolveWithNewton = function( fn, target, guess, prec, data ) {
// function aFunction( x, data )
// aData: user data passed to aFunction
// In data you can specify properties:
// { MaxLoops: 1000 }
// Solver returns in aData:
// { Result, Status, NLoops }
var dx, X, Y, Y1, Y2, Xnew, slope;
data = data || NewtonSolver;
data.Result = 0;
data.Status = '';
data.NLoops = 0;
fn = fn || function(x,d){ d.Status='no function defined'; return x; };
target = target || 0;
guess = guess || 0;
prec = prec || 0.0001;
var maxLoops = data.MaxLoops || 1000;
var nLoops = 0;
var eps = prec / 2.0;
var eps2 = eps / 2;
Xnew = guess;
do {
X = Xnew;
try {
Y = fn( X, data ) - target;
if (Y == 0) break; // exact solution found
Y1 = fn( X-eps2, data ) - target;
if (Y1 == 0) { // exact solution found
Xnew = X - eps2;
break;
}
Y2 = fn( X + eps2, data ) - target;
if (Y2 == 0) { // exact solution found
Xnew = X + eps2;
break;
}
slope = (Y2 - Y1) / eps;
if (slope == 0) { // slope zero, cant find a solution
data.Status = 'extremum found';
break;
}
Xnew = X - (Y / slope);
} catch(err) {
data.Status = err.message;
break;
}
nLoops++;
dx = Math.abs( Xnew - X );
} while ((dx > prec) && (nLoops < maxLoops));
if (data.Status == '' && nLoops >= maxLoops) data.Status = 'max loops exceedet';
data.NLoops = nLoops;
data.Result = (data.Status == '') ? Xnew : 0;
return data.Result;
}
return SolveWithNewton
})()
lib/util/pathApi/node.ls
(function(){
return function(data, api){
var minX, minY, maxX, maxY, computeMinMax, normalize, pos, toggleType, getC, getPoints, isLine, isPoint, closestLine, getPath, movePoint, scale, linePoints;
minX = minY = 10e10;
maxX = maxY = -10e10;
computeMinMax = function(){
var c, cx, cy, i$, t, fx, fy, p, results$ = [];
if (data.c === 'Z') {
return;
}
minX = minY = 10e10;
maxX = maxY = -10e10;
if (data.c === 'C') {
c = getC();
cx = c != null ? c.cx : void 8;
cy = c != null ? c.cy : void 8;
for (i$ = 0; i$ <= 1; i$ += 0.01) {
t = i$;
fx = cx(t);
fy = cy(t);
minX = Math.min(minX, fx);
maxX = Math.max(maxX, fx);
minY = Math.min(minY, fy);
results$.push(maxY = Math.max(maxY, fy));
}
return results$;
} else {
p = pos();
minX = p[0];
maxX = p[0];
minY = p[1];
return maxY = p[1];
}
};
normalize = function(mx, my){
if (data.c === 'Z') {
return;
}
_.each(data.p, function(p, index){
return data.p[index] -= index % 2 ? my : mx;
});
maxX -= mx;
maxY -= my;
minX -= mx;
return minY -= my;
};
pos = function(){
var px, py;
if (data.c === 'Z') {
return;
}
if (data.c === 'C') {
px = data.p[4];
py = data.p[5];
} else {
px = data.p[0];
py = data.p[1];
}
return [px, py];
};
toggleType = function(){
var prevNode, ref$, px, py, dx, dy, dx1, dy1, dx2, dy2;
if (data.c === 'Z') {
return;
}
if (data.c === 'C') {
data.c = 'L';
data.p = data.p.slice(4);
} else if (data.c === 'L') {
prevNode = api.getPrevNode(data.index);
if (prevNode) {
ref$ = prevNode.pos(), px = ref$[0], py = ref$[1];
} else {
ref$ = [0, 0], px = ref$[0], py = ref$[1];
}
ref$ = pos(), dx = ref$[0], dy = ref$[1];
dx1 = px + (dx - px) * 0.33;
dy1 = py + (dy - py) * 0.33;
dx2 = px + (dx - px) * 0.66;
dy2 = py + (dy - py) * 0.66;
data.c = 'C';
data.p = [dx1, dy1, dx2, dy2, dx, dy];
}
return computeMinMax();
};
getC = function(){
var prevNode, P_0, P_1, P_2, P_3;
if (data.c === 'Z') {
return;
}
prevNode = api.getPrevNode(data.index);
if (!prevNode) {
return {};
}
if (in$(data.c, 'LM')) {
P_0 = prevNode.pos();
P_1 = data.p.slice(0, 2);
return {
cx: function(t){
return P_0[0] + (P_1[0] - P_0[0]) * t;
},
cy: function(t){
return P_0[1] + (P_1[1] - P_0[1]) * t;
}
};
} else if (data.c === 'C') {
P_0 = prevNode.pos();
P_1 = data.p.slice(0, 2);
P_2 = data.p.slice(2, 4);
P_3 = data.p.slice(4);
return {
cx: function(t){
var k;
k = 0;
return (-P_0[k] + 3 * P_1[k] - 3 * P_2[k] + P_3[k]) * Math.pow(t, 3) + (3 * P_0[k] - 6 * P_1[k] + 3 * P_2[k]) * Math.pow(t, 2) + (-3 * P_0[k] + 3 * P_1[k]) * t + P_0[k];
},
cy: function(t){
var k;
k = 1;
return (-P_0[k] + 3 * P_1[k] - 3 * P_2[k] + P_3[k]) * Math.pow(t, 3) + (3 * P_0[k] - 6 * P_1[k] + 3 * P_2[k]) * Math.pow(t, 2) + (-3 * P_0[k] + 3 * P_1[k]) * t + P_0[k];
}
};
}
};
getPoints = function(){
if (in$(data.c, 'ML')) {
return [{
x: data.p[0],
y: data.p[1],
type: 'path',
index: 0,
nodeIndex: data.index
}];
} else if (data.c === 'C') {
return [
{
x: data.p[0],
y: data.p[1],
type: 'bezier',
index: 0,
nodeIndex: data.index
}, {
x: data.p[2],
y: data.p[3],
type: 'bezier',
index: 1,
nodeIndex: data.index
}, {
x: data.p[4],
y: data.p[5],
type: 'path',
index: 2,
nodeIndex: data.index
}
];
} else {
return [];
}
};
isLine = function(x, y, delta, step){
var c, cx, cy, i$, t, fx, fy;
if (data.c === 'Z') {
return false;
}
c = getC();
cx = c != null ? c.cx : void 8;
cy = c != null ? c.cy : void 8;
if (cx != null) {
for (i$ = 0; step < 0 ? i$ >= 1 : i$ <= 1; i$ += step) {
t = i$;
fx = cx(t) - x;
fy = cy(t) - y;
if (Math.abs(fx) <= delta && Math.abs(fy) <= delta) {
return true;
}
}
}
return false;
};
isPoint = function(x, y, delta){
var i$, to$, i, px, py, isPoint;
if (data.c === 'Z') {
return -1;
}
for (i$ = 0, to$ = data.p.length; i$ <= to$; i$ += 2) {
i = i$;
px = data.p[i];
py = data.p[i + 1];
isPoint = Math.abs(Math.abs(px) - Math.abs(x)) < delta && Math.abs(Math.abs(py) - Math.abs(y)) < delta;
if (isPoint) {
return Math.floor(i / 2);
}
}
return -1;
};
closestLine = function(x, y, step){
var minDelta, c, cx, cy, i$, t, fx, fy, delta;
minDelta = 1000000;
if (data.c === 'Z') {
return minDelta;
}
c = getC();
cx = c != null ? c.cx : void 8;
cy = c != null ? c.cy : void 8;
if (cx != null) {
for (i$ = 0; step < 0 ? i$ >= 1 : i$ <= 1; i$ += step) {
t = i$;
fx = cx(t) - x;
fy = cy(t) - y;
delta = Math.sqrt(Math.pow(fx, 2) + Math.pow(fy, 2));
if (delta < minDelta) {
minDelta = delta;
}
}
}
return minDelta;
};
getPath = function(){
var r;
r = _.map(data.p, function(d){
return _.round(d, 2);
});
return data.c + r.join(' ');
};
movePoint = function(dx, dy, pointIndex){
var ref$;
if (data.c === 'Z') {
return;
}
data.p[2 * pointIndex] += dx;
data.p[2 * pointIndex + 1] += dy;
if ((ref$ = api.getNextNode(data.index)) != null) {
ref$.updateBounds();
}
return computeMinMax();
};
scale = function(fx, fy){
if (data.c === 'Z') {
return;
}
return data.p = _.map(data.p, function(p, index){
var factor;
factor = index % 2 === 0 ? fx : fy;
return _.round(p * factor, 2);
});
};
linePoints = function(step){
var c, cx, cy, points, i$, t, fx, fy;
if (data.c === 'Z') {
return;
}
step = step || 0.01;
c = getC();
cx = c.cx;
cy = c.cy;
points = [];
for (i$ = 0; step < 0 ? i$ >= 1 : i$ <= 1; i$ += step) {
t = i$;
fx = cx(t);
fy = cy(t);
points.push({
x: fx,
y: fy
});
}
return points;
};
computeMinMax();
return {
C: getC,
normalize: normalize,
updateBounds: computeMinMax,
setIndex: function(nodeIndex){
data.index = nodeIndex;
return computeMinMax();
},
points: getPoints,
toggleType: toggleType,
minX: function(){
return minX;
},
maxX: function(){
return maxX;
},
minY: function(){
return minY;
},
maxY: function(){
return maxY;
},
movePoint: movePoint,
isPoint: isPoint,
isLine: isLine,
closestLine: closestLine,
pos: pos,
path: getPath,
scale: scale,
linePoints: linePoints,
type: function(){
return data.c;
},
index: function(){
return data.index;
}
};
};
})();
function in$(x, xs){
var i = -1, l = xs.length >>> 0;
while (++i < l) if (x === xs[i]) return true;
return false;
}
lib/util/pathApi/pathApi.ls
(function(){
return function(path){
var newton, Node, values, nodes, data, getPrevNode, getNextNode, api;
newton = include('newtonSolver.js');
Node = include('node');
path = path.replace(/([A-Z])([0-9\\-])/g, function(m, a, b){
return a + " " + b;
});
values = path.split(/[\s,]+/);
nodes = [];
data = null;
getPrevNode = function(nodeIndex){
var prevNode, ref$;
if (nodeIndex > 0) {
prevNode = nodes[nodeIndex - 1];
} else if (((ref$ = _.last(nodes)) != null ? ref$.type() : void 8) === 'Z') {
prevNode = nodes[nodes.length - 2];
}
return prevNode;
};
getNextNode = function(nodeIndex){
var nextNode, ref$;
if (nodeIndex < nodes.length - 2) {
return nextNode = nodes[nodeIndex + 1];
} else if (((ref$ = _.last(nodes)) != null ? ref$.type() : void 8) === 'Z') {
return nextNode = nodes[0];
} else if (nodeIndex === nodes.length - 2) {
return nextNode = _.last(nodes);
}
};
api = {
getPrevNode: getPrevNode,
getNextNode: getNextNode
};
_.each(values, function(v){
if (/[A-Z]/.test(v)) {
if (data) {
nodes.push(Node(data, api));
}
return data = {
c: v,
p: [],
index: nodes.length
};
} else {
return data.p.push(1 * v);
}
});
nodes.push(Node(data, api));
return window.pathApi = {
normalize: function(){
var minX, minY;
minX = _.min(_.map(nodes, function(n){
return n.minX();
}));
minY = _.min(_.map(nodes, function(n){
return n.minY();
}));
_.each(nodes, function(n){
return n.normalize(minX, minY);
});
return {
x: minX,
y: minY
};
},
offset: function(){
var minX, minY;
minX = _.min(_.map(nodes, function(n){
return n.minX();
}));
minY = _.min(_.map(nodes, function(n){
return n.minY();
}));
return {
x: minX,
y: minY
};
},
w: function(){
var minX, maxX;
minX = _.min(_.map(nodes, function(n){
return n.minX();
}));
maxX = _.max(_.map(nodes, function(n){
return n.maxX();
}));
return maxX - minX;
},
h: function(){
var minY, maxY;
minY = _.min(_.map(nodes, function(n){
return n.minY();
}));
maxY = _.max(_.map(nodes, function(n){
return n.maxY();
}));
return maxY - minY;
},
scale: function(fx, fy){
if (!fy) {
fy = fx;
}
return _.each(nodes, function(n){
return n.scale(fx, fy);
});
},
path: function(){
return _.map(nodes, function(n){
return n.path();
}).join(' ');
},
points: function(){
var points, index;
points = [];
index = 0;
_.each(nodes, function(n, i){
return points = _.concat(points, n.points());
});
return points;
},
nodes: function(){
return nodes;
},
movePoint: function(dx, dy, nodeIndex, pointIndex){
return nodes[nodeIndex].movePoint(dx, dy, pointIndex);
},
insertNode: function(x, y, nodeIndex){
var data, node;
if (nodeIndex === 0) {
nodeIndex = nodes.length;
}
data = {
c: 'L',
p: [x, y]
};
node = Node(data, api);
nodes.splice(nodeIndex, 0, node);
return _.each(nodes, function(node, index){
return node.setIndex(index);
});
},
closePath: function(){
if (_.last(nodes).type() !== 'Z') {
return nodes.push(Node({
c: 'Z'
}, api));
}
},
openPath: function(){
if (_.last(nodes).type() === 'Z') {
return nodes.splice(-1);
}
},
isOpen: function(){
return _.last(nodes).type() !== 'Z';
},
removeNode: function(nodeIndex){
nodes.splice(nodeIndex, 1);
return _.each(nodes, function(node, index){
return node.setIndex(index);
});
},
toggleNodeType: function(nodeIndex){
return nodes[nodeIndex].toggleType();
},
linePoints: function(nodeIndex){
return nodes[nodeIndex].linePoints();
},
isLine: function(x, y, delta, step){
var result;
result = -1;
step = step || 0.01;
delta = delta || 7;
_.each(nodes, function(node, i){
if (node.isLine(x, y, delta, step)) {
result = i;
return false;
}
});
return result;
},
closestLine: function(x, y, step){
var result, minDelta;
result = -1;
minDelta = 1000000;
step = step || 0.01;
_.each(nodes, function(node, i){
var delta;
delta = node.closestLine(x, y, step);
if (delta < minDelta) {
result = i;
return minDelta = delta;
}
});
return result;
},
isPoint: function(x, y, delta){
var result;
result = [-1, -1];
delta = delta || 7;
_.each(nodes, function(node, i){
var p;
p = node.isPoint(x, y, delta);
if (p !== -1) {
result = [i, p];
return false;
}
});
return result;
}
};
};
})();
lib/util/pathApi/test.lsg
(function(){
return {
version: 2,
width: 300,
height: 300,
background: Color.grey[200],
backgroundLineColor: Color.grey[200],
backgroundLineSize: 1,
objects: {
type: 'path',
x: 129,
y: 81,
w: 71,
color: Color.pink[500],
lineColor: Color.purple[500],
lineSize: 5,
opacity: 0.85,
rotate: 330,
flipX: false,
flipY: false,
path: 'M0 167.6 C94.9 147.8 91.6 19.4 -1.5 -0.6'
}
};
})();
lib/util/preloadRequired/preloadRequired.ls
(function(){
return function(required, done){
var total, ref$, count, preloadSvg, preloadSvgs, preloadProjects;
total = ((ref$ = required.svgs) != null ? ref$.length : void 8) || 0;
count = 0;
preloadSvg = function(path){
return LSG2.util.remoteSvgCache.svg(path, function(){
if (++count === total) {
return typeof done == 'function' ? done() : void 8;
}
});
};
preloadSvgs = function(){
if (!total) {
if (typeof done == 'function') {
done();
}
return;
}
return _.each(required.svgs, function(path){
return preloadSvg(path);
});
};
preloadProjects = function(){
var ref$, projectDescriptions;
if (!((ref$ = required.projects) != null && ref$.length)) {
preloadSvgs();
return;
}
if (projects.load) {
return projects.load(required.projects, preloadSvgs);
} else {
projectDescriptions = _.map(required.projects, function(p){
return {
project: p
};
});
return inc("/../app01/lib/util/loadProjects/load")({
projectDescriptions: projectDescriptions,
onDone: preloadSvgs
});
}
};
return preloadProjects();
};
})();
lib/util/prepareSvg/prepareSvg.ls
(function(){
return function(o, svg, ignoreOpacity){
var vbOrig, ref$, vbOrigX, vbOrigY, vbOrigW, vbOrigH, wOrig, that, hOrig, ratioOrig, w, h, tx, ty, rx, ry, sx, sy, transform, r, wf, hf, top, ref1$, left, ref2$, bottom, ref3$, right, ref4$, vbNewW, vbNewH, vbNewX, vbNewY, vbNew;
include('/lib/util/resolveOverrides/resolveOverrides')(o, svg);
vbOrig = (ref$ = svg.attr('viewBox')) != null ? ref$.split(' ') : void 8;
vbOrigX = +vbOrig[0];
vbOrigY = +vbOrig[1];
vbOrigW = +vbOrig[2];
vbOrigH = +vbOrig[3];
wOrig = (that = svg.attr('width'))
? that.replace("px", "").replace("mm", "") * 1
: vbOrigW * 1;
hOrig = (that = svg.attr('height'))
? that.replace("px", "").replace("mm", "") * 1
: vbOrigH * 1;
ratioOrig = wOrig / hOrig;
w = !(o.w || o.h)
? wOrig
: o.w
? o.w
: o.h * ratioOrig;
h = !(o.w || o.h)
? hOrig
: o.h
? o.h
: o.w / ratioOrig;
tx = o.flipX
? o.x + w
: o.x;
ty = o.flipY
? o.y + h
: o.y;
rx = w / 2;
ry = h / 2;
sx = o.flipX ? -1 : 1;
sy = o.flipY ? -1 : 1;
transform = "translate(" + tx + " " + ty + ")";
transform += " scale(" + sx + " " + sy + ")";
transform += " rotate(" + (o.rotate || 0) + " " + rx + " " + ry + ")";
if (o.w != null && o.h != null && !o.crop) {
svg.attr({
'preserveAspectRatio': 'none'
});
}
if (o.crop) {
r = w / h;
wf = w / wOrig;
hf = h / hOrig;
top = _.includes((ref1$ = o.align) != null ? ref1$.toLowerCase() : void 8, "top");
left = _.includes((ref2$ = o.align) != null ? ref2$.toLowerCase() : void 8, "left");
bottom = _.includes((ref3$ = o.align) != null ? ref3$.toLowerCase() : void 8, "bottom");
right = _.includes((ref4$ = o.align) != null ? ref4$.toLowerCase() : void 8, "right");
if (wf > hf) {
vbNewW = w / wf;
vbNewH = h / wf;
vbNewX = (wOrig - vbNewW) / 2;
vbNewY = top
? 0
: bottom
? hOrig - vbNewH
: (hOrig - vbNewH) / 2;
} else {
vbNewW = w / hf;
vbNewH = h / hf;
vbNewX = left
? 0
: right
? wOrig - vbNewW
: (wOrig - vbNewW) / 2;
vbNewY = (hOrig - vbNewH) / 2;
}
vbNewX += vbOrigX;
vbNewY += vbOrigY;
vbNew = vbNewX + " " + vbNewY + " " + vbNewW + " " + vbNewH;
svg.attr({
viewBox: vbNew
});
}
if (!ignoreOpacity && o.opacity != null) {
svg.attr({
opacity: o.opacity
});
}
return include('/lib/util/makeSvg/makeSvg')('g', {
'transform': transform,
'class': o['class'],
'lsg:x': o.x,
'lsg:y': o.y,
'lsg:w': w,
'lsg:h': h
}).append(svg.attr({
'width': w,
'height': h
}));
};
})();
lib/util/remoteSvgCache/remoteSvgCache.ls
(function(){
var cache, errorSvgString, errorSvgParser, errorSvgDoc, errorSvg;
cache = {};
window.svgCache = cache;
errorSvgString = include('/lib/svg/error.svg');
errorSvgParser = new DOMParser();
errorSvgDoc = errorSvgParser.parseFromString(errorSvgString, 'image/svg+xml');
errorSvg = errorSvgDoc.documentElement;
return {
svg: function(path, done){
var svg;
if (path.slice(0, 4) !== '/../') {
helpers.errorHandler("absulte path expected, got: " + path, '/../lsg/lib/util/svgCache/svgCache.ls');
return errorSvg.cloneNode(true);
}
if (path.slice(-4) !== '.svg') {
helpers.errorHandler("svg file expected, got: " + path, '/../lsg/lib/util/svgCache/svgCache.ls');
return errorSvg.cloneNode(true);
}
if (cache[path]) {
svg = cache[path].cloneNode(true);
requestAnimationFrame(function(){
return typeof done == 'function' ? done(svg, true) : void 8;
});
return svg;
} else {
LSG2.util.loadRemoteSvg(path, function(svg){
cache[path] = svg;
return typeof done == 'function' ? done(svg, false) : void 8;
});
return errorSvg.cloneNode(true);
}
},
clear: function(){
return cache = {};
}
};
})();
lib/util/replaceColor/replaceColor.ls
(function(){
var replaceColor;
return replaceColor = function(svg, o){
var id, value, children, results$ = [];
for (id in o) {
value = o[id];
children = svg.findAll("." + id);
if (_.isObject(value)) {
results$.push(_.each(children, fn$));
} else {
results$.push(_.each(children, fn1$));
}
}
return results$;
function fn$(child){
return replaceColor(child, value);
}
function fn1$(child){
var grandChildren;
if (child.tagName === 'g') {
grandChildren = child.findAll(".color1");
return _.each(grandChildren, function(child){
return child.attr({
'fill': value
});
});
} else {
return child.attr({
'fill': value
});
}
}
};
})();
lib/util/replaceLineColor/replaceLineColor.ls
(function(){
return function(svg, o){
var id, value, children, results$ = [];
for (id in o) {
value = o[id];
children = svg.find("." + id);
results$.push(_.each(children, fn$));
}
return results$;
function fn$(child){
return child.attr({
'stroke': value
});
}
};
})();
lib/util/replaceLineDash/replaceLineDash.ls
(function(){
return function(svg, o){
var id, value, strokeDasharray, children, results$ = [];
for (id in o) {
value = o[id];
strokeDasharray = value === true
? "10, 10"
: value ? value + ", " + value : void 8;
children = svg.find("." + id);
results$.push(_.each(children, fn$));
}
return results$;
function fn$(child){
return child.attr({
'stroke-dasharray': strokeDasharray
});
}
};
})();
lib/util/replaceLineSize/replaceLineSize.ls
(function(){
return function(svg, o){
var id, value, children, results$ = [];
for (id in o) {
value = o[id];
children = svg.find("." + id);
results$.push(_.each(children, fn$));
}
return results$;
function fn$(child){
return child.attr({
'stroke-width': value
});
}
};
})();
lib/util/resolveColor/resolveColor.ls
(function(){
return function(color){
var name, ref$, value, shades, shade;
for (name in ref$ = Color) {
value = ref$[name];
if (_.isObject(value)) {
shades = value;
for (shade in shades) {
value = shades[shade];
if (color === value) {
return "Color." + name + "." + shade;
}
}
} else if (color === value) {
return "Color." + name;
}
}
return "'" + color + "'";
};
})();
lib/util/resolveOverrides/resolveOverrides.ls
(function(){
return function(o, svg){
if (_.isObject(o.color)) {
include("/lib/util/replaceColor/replaceColor")(svg, o.color);
} else if (o.color) {
include("/lib/util/replaceColor/replaceColor")(svg, {
color1: o.color
});
}
if (_.isObject(o.lineColor)) {
include("/lib/util/replaceLineColor/replaceLineColor")(svg, o.lineColor);
} else if (o.lineColor) {
include("/lib/util/replaceLineColor/replaceLineColor")(svg, {
lineColor1: o.lineColor
});
}
if (_.isObject(o.lineSize)) {
include("/lib/util/replaceLineSize/replaceLineSize")(svg, o.lineSize);
} else if (o.lineSize) {
include("/lib/util/replaceLineSize/replaceLineSize")(svg, {
lineSize1: o.lineSize
});
}
if (_.isObject(o.lineDash)) {
return include("/lib/util/replaceLineDash/replaceLineDash")(svg, o.lineDash);
} else if (o.lineDash) {
return include("/lib/util/replaceLineDash/replaceLineDash")(svg, {
lineDash1: o.lineDash
});
}
};
})();
lib/util/resolvePath/resolvePath.ls
(function(){
return function(path){
var project, file, type;
project = path.split('/')[2];
file = path.replace("/../" + project + "/", '');
type = _.last(path.split('.'));
return {
project: project,
file: file,
type: type
};
};
})();
lib/util/resolveRelativePath/resolveRelativePath.ls
(function(){
return function(originPath, filePath){
var origin, file, to, from, relative, absolute;
origin = originPath.split('/');
file = filePath.split('/');
if ((origin != null ? origin[1] : void 8) === '..' && (file != null ? file[2] : void 8) !== (origin != null ? origin[2] : void 8)) {
return "path('" + filePath + "')";
} else if (file.slice(0, -1) === origin.slice(0, -1)) {
return "path('" + _.last(file) + "')";
} else {
to = file.slice(3).join('/');
from = Path.dirname(origin.slice(3).join('/'));
relative = Path.relative(from, to);
absolute = "/" + to;
if (relative.split('/').length <= absolute.split('/').length) {
return "path('" + relative + "')";
} else {
return "path('" + absolute + "')";
}
}
};
})();
lib/util/svgObject/svgObject.ls
(function(){
return {
line: include('/lsg/toSVG/objects/line'),
lsg: include('/lsg/toSVG/objects/lsg'),
oval: include('/lsg/toSVG/objects/oval'),
path: include('/lsg/toSVG/objects/path'),
rect: include('/lsg/toSVG/objects/rect'),
svg: include('/lsg/toSVG/objects/svg'),
text: include('/lsg/toSVG/objects/text'),
avatar: include('/lsg/toSVG/objects/avatar'),
image: include('/lsg/toSVG/objects/image')
};
})();
lib/util/svgPathHelper/abs/abs.ls
(function(){
return function(h){
h.iterate(function(s, index, x, y){
var name, nameUC, i$, to$, i;
name = s[0];
nameUC = name.toUpperCase();
if (name === nameUC) {
return;
}
s[0] = nameUC;
switch (name) {
case "v":
s[1] += y;
break;
case "a":
s[6] += x;
s[7] += y;
break;
default:
for (i$ = 1, to$ = s.length - 1; i$ <= to$; ++i$) {
i = i$;
s[i] += i % 2 ? x : y;
}
}
});
return h;
};
})();
lib/util/svgPathHelper/copy/copy.ls
(function(){
return function(h){
var h2, res$, i$, ref$, len$, s;
h2 = inc("../helper")();
res$ = [];
for (i$ = 0, len$ = (ref$ = h.segments).length; i$ < len$; ++i$) {
s = ref$[i$];
res$.push(s.slice(0));
}
h2.segments = res$;
return h2;
};
})();
lib/util/svgPathHelper/getBBox/get.ls
(function(){
return function(h){
var r, b, bb;
r = function(v){
return _.round(v, 2);
};
b = h.toBox();
return bb = {
x: r(b.minX),
y: r(b.minY),
width: r(b.maxX - b.minX),
height: r(b.maxY - b.minY)
};
};
})();
lib/util/svgPathHelper/helper.ls
(function(){
return function(pathString){
var h;
h = {};
h.segments = [];
h.errors = [];
h.parse = function(s){
return inc("parse/parse")(s, h);
};
h.copy = function(){
return inc("copy/copy")(h);
};
h.iterate = function(f){
return inc("iterate/iterate")(f, h);
};
h.abs = function(){
return inc("abs/abs")(h);
};
h.unarc = function(){
return inc("unarc/unarc")(h);
};
h.unshort = function(){
return inc("unshort/unshort")(h);
};
h.toBox = function(){
return inc("toBox/toBox")(h);
};
h.getBBox = function(){
return inc("getBBox/get")(h);
};
if (pathString) {
h.parse(pathString);
}
return h;
};
})();
lib/util/svgPathHelper/iterate/calcNewPosition/calc.ls
(function(){
return function(segment, oldP){
var s, newP, n;
s = segment;
if (s.length <= 1) {
return;
}
newP = [0, 0];
switch (s[0]) {
case "h":
case "H":
newP[0] = s[1];
newP[1] = s[0] === "h"
? 0
: oldP[1];
break;
case "v":
case "V":
newP[0] = s[0] === "v"
? 0
: oldP[0];
newP[1] = s[1];
break;
default:
n = s.length - 2;
newP[0] = s[n];
newP[1] = s[n + 1];
}
if (s[0] === s[0].toLowerCase()) {
newP[0] += oldP[0];
newP[1] += oldP[1];
}
return newP;
};
})();
lib/util/svgPathHelper/iterate/iterate.ls
(function(){
return function(f, h){
var iterator, self, segments, replacements, newSegments, lastP, countourStartP, newPosition, i$, len$, index, s, lastX, lastY, res, i, r, j$, len1$, s2;
iterator = f;
self = h;
segments = h.segments;
replacements = [];
newSegments = [];
lastP = [0, 0];
countourStartP = [0, 0];
newPosition = inc("calcNewPosition/calc");
for (i$ = 0, len$ = segments.length; i$ < len$; ++i$) {
index = i$;
s = segments[i$];
lastX = lastP[0];
lastY = lastP[1];
res = undefined;
if (s[0] === "z" || s[0] === "Z") {
lastP = countourStartP.slice();
} else {
lastP = newPosition(s, lastP);
if (s[0] === "m" || s[0] === "M") {
countourStartP = lastP.slice();
}
}
res = iterator(s, index, lastX, lastY);
if (Array.isArray(res)) {
replacements[index] = res;
}
}
if (replacements.length === 0) {
return this;
}
for (i$ = 0, len$ = segments.length; i$ < len$; ++i$) {
i = i$;
s = segments[i$];
r = replacements[i];
if (!r) {
newSegments.push(s);
} else {
for (j$ = 0, len1$ = r.length; j$ < len1$; ++j$) {
s2 = r[j$];
newSegments.push(s2);
}
}
}
h.segments = newSegments;
return h;
};
})();
lib/util/svgPathHelper/parse/parse.ls
(function(){
return function(s, h){
var cmdParams, l, numNum, parseNum, numBuf, hasDot, hasE, segments, curseg, i$, i, c, cc, addnum, numParams;
cmdParams = {
97: 7,
99: 6,
104: 1,
108: 2,
109: 2,
113: 4,
115: 4,
116: 2,
118: 1,
122: 0
};
l = s.length;
numNum = 0;
parseNum = false;
numBuf = "";
hasDot = false;
hasE = false;
segments = [];
curseg = [];
for (i$ = 0; i$ <= l; ++i$) {
i = i$;
c = s[i] || "z";
cc = c.toLowerCase().charCodeAt(0);
if (48 <= cc && cc <= 57) {
numBuf += c;
parseNum = true;
if (curseg[0] !== "A" && curseg[0] !== "a" || cc > 49 || numNum < 3 || numNum > 4) {
continue;
}
}
if ((cc === 45 || cc === 43) && (!parseNum || hasE && numBuf[numBuf.length - 1] === "e")) {
numBuf += c;
parseNum = true;
continue;
}
if (cc === 46 && !hasDot && !hasE) {
numBuf += c;
parseNum = true;
hasDot = true;
continue;
}
if (cc === 101 && parseNum && !isNaN(numBuf)) {
numBuf += "e";
parseNum = true;
hasE = true;
continue;
}
if (parseNum) {
if (numParams) {
addnum = +numBuf;
if (isNaN(numBuf)) {
1;
} else {
curseg.push(addnum);
numNum++;
}
} else {
1;
}
numBuf = "";
parseNum = hasE = hasDot = false;
}
if (numNum === numParams && curseg.length) {
if (curseg[0] === "A" || deepEq$(curseg[0], "a", '===')) {
curseg[4] = curseg[4] ? 1 : 0;
curseg[5] = curseg[5] ? 1 : 0;
}
if (segments.length === 0 && curseg[0] !== "m" && curseg[0] !== "M") {
segments.push(["M", 0, 0]);
}
segments.push(curseg);
numNum = 0;
curseg = (fn$());
}
if (cc === 32 || cc === 9 || cc === 10 || cc === 13 || cc === 44) {
continue;
}
if (cc === 43 || cc === 45 || cc === 46) {
numBuf = c;
hasDot = cc === 46;
parseNum = true;
continue;
}
if (!cmdParams.hasOwnProperty(cc)) {
continue;
}
if (curseg.length > 1) {
1;
}
numParams = cmdParams[cc];
curseg = [c];
numNum = 0;
}
if (curseg.length > 1) {
1;
}
return h.segments = segments;
function fn$(){
switch (curseg[0]) {
case "M":
return ["L"];
case "m":
return ["l"];
case "z":
case "Z":
return [];
default:
return [curseg[0]];
}
}
};
})();
function deepEq$(x, y, type){
var toString = {}.toString, hasOwnProperty = {}.hasOwnProperty,
has = function (obj, key) { return hasOwnProperty.call(obj, key); };
var first = true;
return eq(x, y, []);
function eq(a, b, stack) {
var className, length, size, result, alength, blength, r, key, ref, sizeB;
if (a == null || b == null) { return a === b; }
if (a.__placeholder__ || b.__placeholder__) { return true; }
if (a === b) { return a !== 0 || 1 / a == 1 / b; }
className = toString.call(a);
if (toString.call(b) != className) { return false; }
switch (className) {
case '[object String]': return a == String(b);
case '[object Number]':
return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
case '[object Date]':
case '[object Boolean]':
return +a == +b;
case '[object RegExp]':
return a.source == b.source &&
a.global == b.global &&
a.multiline == b.multiline &&
a.ignoreCase == b.ignoreCase;
}
if (typeof a != 'object' || typeof b != 'object') { return false; }
length = stack.length;
while (length--) { if (stack[length] == a) { return true; } }
stack.push(a);
size = 0;
result = true;
if (className == '[object Array]') {
alength = a.length;
blength = b.length;
if (first) {
switch (type) {
case '===': result = alength === blength; break;
case '<==': result = alength <= blength; break;
case '<<=': result = alength < blength; break;
}
size = alength;
first = false;
} else {
result = alength === blength;
size = alength;
}
if (result) {
while (size--) {
if (!(result = size in a == size in b && eq(a[size], b[size], stack))){ break; }
}
}
} else {
if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) {
return false;
}
for (key in a) {
if (has(a, key)) {
size++;
if (!(result = has(b, key) && eq(a[key], b[key], stack))) { break; }
}
}
if (result) {
sizeB = 0;
for (key in b) {
if (has(b, key)) { ++sizeB; }
}
if (first) {
if (type === '<<=') {
result = size < sizeB;
} else if (type === '<==') {
result = size <= sizeB
} else {
result = size === sizeB;
}
} else {
first = false;
result = size === sizeB;
}
}
}
stack.pop();
return result;
}
}
lib/util/svgPathHelper/toBox/box/box.ls
(function(){
return function(){
var minmaxQ, minmaxC, b;
minmaxQ = inc("minmaxQ/minmaxQ");
minmaxC = inc("minmaxC/minmaxC");
b = {};
b.addX = function(x){
b.maxX == null && (b.maxX = x);
b.minX == null && (b.minX = x);
b.minX = Math.min(b.minX, x);
b.maxX = Math.max(b.maxX, x);
return b;
};
b.addY = function(y){
b.maxY == null && (b.maxY = y);
b.minY == null && (b.minY = y);
b.minY = Math.min(b.minY, y);
b.maxY = Math.max(b.maxY, y);
return b;
};
b.addXQ = function(A){
var m;
m = minmaxQ(A);
return b.addX(m[0]).addX(m[1]);
};
b.addYQ = function(A){
var m;
m = minmaxQ(A);
return b.addY(m[0]).addY(m[1]);
};
b.addXC = function(A){
var m;
m = minmaxC(A);
return b.addX(m[0]).addX(m[1]);
};
b.addYC = function(A){
var m;
m = minmaxC(A);
return b.addY(m[0]).addY(m[1]);
};
return b;
};
})();
lib/util/svgPathHelper/toBox/box/minmaxC/minmaxC.ls
(function(){
return function(A){
var minmaxQ, epsilon, K, T, S, max, min, L, i$, ref$, len$, R, Q;
minmaxQ = inc("../minmaxQ/minmaxQ");
epsilon = 1e-08;
K = A[0] - 3 * A[1] + 3 * A[2] - A[3];
if (Math.abs(K) < epsilon) {
return minmaxQ([A[0], -0.5 * A[0] + 1.5 * A[1], A[0] - 3 * A[1] + 3 * A[2]]);
}
T = -A[0] * A[2] + A[0] * A[3] - A[1] * A[2] - A[1] * A[3] + A[1] * A[1] + A[2] * A[2];
if (T <= 0) {
return [Math.min(A[0], A[3]), Math.max(A[0], A[3])];
}
S = Math.sqrt(T);
max = Math.max(A[0], A[3]);
min = Math.min(A[0], A[3]);
L = A[0] - 2 * A[1] + A[2];
for (i$ = 0, len$ = (ref$ = [(L + S) / K, (L - S) / K]).length; i$ < len$; ++i$) {
R = ref$[i$];
if (R > 0 && R < 1) {
Q = A[0] * (1 - R) * (1 - R) * (1 - R) + A[1] * 3 * (1 - R) * (1 - R) * R + A[2] * 3 * (1 - R) * R * R + A[3] * R * R * R;
if (Q < min) {
min = Q;
}
if (Q > max) {
max = Q;
}
}
}
return [min, max];
};
})();
lib/util/svgPathHelper/toBox/box/minmaxQ/minmaxQ.ls
(function(){
return function(A){
var min, max, E;
min = Math.min(A[0], A[2]);
max = Math.max(A[0], A[2]);
if ((A[1] > A[0] && A[2] >= A[1]) || (A[1] <= A[0] && A[2] <= A[1])) {
return [min, max];
}
E = (A[0] * A[2] - A[1] * A[1]) / (A[0] - 2 * A[1] + A[2]);
if (E < min) {
return [E, max];
} else {
return [min, E];
}
};
})();
lib/util/svgPathHelper/toBox/toBox.ls
(function(){
return function(h){
var b;
b = inc("box/box")();
if (h.segments.length === 0) {
return b;
}
h.copy().abs().unarc().unshort();
h.iterate(function(s, i, x, y){
switch (s[0]) {
case "H":
return b.addX(s[1]);
case "V":
return b.addY(s[1]);
case "L":
case "M":
return b.addX(s[1]).addY(s[2]);
case "Q":
return b.addXQ([x, s[1], s[3]]).addYQ([y, s[2], s[4]]);
case "C":
return b.addXC([x, s[1], s[3], s[5]]).addYC([y, s[2], s[4], s[6]]);
}
});
return b;
};
})();
lib/util/svgPathHelper/unarc/a2c/a2c.ls
(function(){
return function(x1, y1, x2, y2, fa, fs, rx, ry, phi){
var get_arc_center, approximate_unit_arc, TAU, sin_phi, cos_phi, x1p, y1p, lambda, cc, result, theta1, delta_theta, segments, i$, to$, i;
get_arc_center = inc("getArcCenter/get");
approximate_unit_arc = inc("approximateUnitArc/approximate");
TAU = Math.PI * 2;
sin_phi = Math.sin(phi * TAU / 360);
cos_phi = Math.cos(phi * TAU / 360);
x1p = cos_phi * (x1 - x2) / 2 + sin_phi * (y1 - y2) / 2;
y1p = -sin_phi * (x1 - x2) / 2 + cos_phi * (y1 - y2) / 2;
if (x1p === 0 && y1p === 0) {
return [];
}
if (rx === 0 || ry === 0) {
return [];
}
rx = Math.abs(rx);
ry = Math.abs(ry);
lambda = x1p * x1p / (rx * rx) + y1p * y1p / (ry * ry);
if (lambda > 1) {
rx *= Math.sqrt(lambda);
ry *= Math.sqrt(lambda);
}
cc = get_arc_center(x1, y1, x2, y2, fa, fs, rx, ry, sin_phi, cos_phi);
result = [];
theta1 = cc[2];
delta_theta = cc[3];
segments = Math.max(Math.ceil(Math.abs(delta_theta) / (TAU / 4)), 1);
delta_theta /= segments;
for (i$ = 0, to$ = segments - 1; i$ <= to$; ++i$) {
i = i$;
result.push(approximate_unit_arc(theta1, delta_theta));
theta1 += delta_theta;
}
return result.map(function(curve){
var i$, to$, i2, x, y, xp, yp;
for (i$ = 0, to$ = curve.length - 1; i$ <= to$; i$ += 2) {
i2 = i$;
x = curve[i2 + 0];
y = curve[i2 + 1];
x *= rx;
y *= ry;
xp = cos_phi * x - sin_phi * y;
yp = sin_phi * x + cos_phi * y;
curve[i2 + 0] = xp + cc[0];
curve[i2 + 1] = yp + cc[1];
}
return curve;
});
};
})();
lib/util/svgPathHelper/unarc/a2c/approximateUnitArc/approximate.ls
(function(){
return function(theta1, delta_theta){
var alpha, x1, y1, x2, y2;
alpha = 4 / 3 * Math.tan(delta_theta / 4);
x1 = Math.cos(theta1);
y1 = Math.sin(theta1);
x2 = Math.cos(theta1 + delta_theta);
y2 = Math.sin(theta1 + delta_theta);
return [x1, y1, x1 - y1 * alpha, y1 + x1 * alpha, x2 + y2 * alpha, y2 - x2 * alpha, x2, y2];
};
})();
lib/util/svgPathHelper/unarc/a2c/getArcCenter/get.ls
(function(){
return function(x1, y1, x2, y2, fa, fs, rx, ry, sin_phi, cos_phi){
var TAU, unit_vector_angle, x1p, y1p, rx_sq, ry_sq, x1p_sq, y1p_sq, radicant, cxp, cyp, cx, cy, v1x, v1y, v2x, v2y, theta1, delta_theta;
TAU = Math.PI * 2;
unit_vector_angle = function(ux, uy, vx, vy){
var sign, dot;
sign = ux * vy - uy * vx < 0 ? -1 : 1;
dot = ux * vx + uy * vy;
if (dot > 1) {
dot = 1;
}
if (dot < -1) {
dot = -1;
}
return sign * Math.acos(dot);
};
x1p = cos_phi * (x1 - x2) / 2 + sin_phi * (y1 - y2) / 2;
y1p = -sin_phi * (x1 - x2) / 2 + cos_phi * (y1 - y2) / 2;
rx_sq = rx * rx;
ry_sq = ry * ry;
x1p_sq = x1p * x1p;
y1p_sq = y1p * y1p;
radicant = rx_sq * ry_sq - rx_sq * y1p_sq - ry_sq * x1p_sq;
if (radicant < 0) {
radicant = 0;
}
radicant /= rx_sq * y1p_sq + ry_sq * x1p_sq;
radicant = Math.sqrt(radicant) * (fa === fs ? -1 : 1);
cxp = radicant * rx / ry * y1p;
cyp = radicant * -ry / rx * x1p;
cx = cos_phi * cxp - sin_phi * cyp + (x1 + x2) / 2;
cy = sin_phi * cxp + cos_phi * cyp + (y1 + y2) / 2;
v1x = (x1p - cxp) / rx;
v1y = (y1p - cyp) / ry;
v2x = (-x1p - cxp) / rx;
v2y = (-y1p - cyp) / ry;
theta1 = unit_vector_angle(1, 0, v1x, v1y);
delta_theta = unit_vector_angle(v1x, v1y, v2x, v2y);
if (fs === 0 && delta_theta > 0) {
delta_theta -= TAU;
}
if (fs === 1 && delta_theta < 0) {
delta_theta += TAU;
}
return [cx, cy, theta1, delta_theta];
};
})();
lib/util/svgPathHelper/unarc/unarc.ls
(function(){
return function(h){
var a2c;
a2c = inc("a2c/a2c");
h.iterate(function(s, index, x, y){
var result, name, nextX, nextY, new_segments, i$, len$, s2;
result = [];
name = s[0];
if (name !== "A" && name !== "a") {
return;
}
if (name === "a") {
nextX = x + s[6];
nextY = y + s[7];
} else {
nextX = s[6];
nextY = s[7];
}
new_segments = a2c(x, y, nextX, nextY, s[4], s[5], s[1], s[2], s[3]);
for (i$ = 0, len$ = new_segments.length; i$ < len$; ++i$) {
s2 = new_segments[i$];
result.push(["C", s2[2], s2[3], s2[4], s2[5], s2[6], s2[7]]);
}
return result;
});
return h;
};
})();
lib/util/svgPathHelper/unshort/unshort.ls
(function(){
return function(h){
var segments;
segments = h.segments;
h.iterate(function(s, idx, x, y){
var name, nameUC, isRelative, prevSegment, prevControlX, prevControlY, curControlX, curControlY;
name = s[0];
nameUC = name.toUpperCase();
if (!idx) {
return;
}
if (nameUC === "T") {
isRelative = name === "t";
prevSegment = segments[idx - 1];
if (prevSegment[0] === "Q") {
prevControlX = prevSegment[1] - x;
prevControlY = prevSegment[2] - y;
} else if (prevSegment[0] === "q") {
prevControlX = prevSegment[1] - prevSegment[3];
prevControlY = prevSegment[2] - prevSegment[4];
} else {
prevControlX = 0;
prevControlY = 0;
}
curControlX = -prevControlX;
curControlY = -prevControlY;
if (!isRelative) {
curControlX += x;
curControlY += y;
}
segments[idx] = [isRelative ? "q" : "Q", curControlX, curControlY, s[1], s[2]];
} else if (nameUC === "S") {
isRelative = name === "s";
prevSegment = segments[idx - 1];
if (prevSegment[0] === "C") {
prevControlX = prevSegment[3] - x;
prevControlY = prevSegment[4] - y;
} else if (prevSegment[0] === "c") {
prevControlX = prevSegment[3] - prevSegment[5];
prevControlY = prevSegment[4] - prevSegment[6];
} else {
prevControlX = 0;
prevControlY = 0;
}
curControlX = -prevControlX;
curControlY = -prevControlY;
if (!isRelative) {
curControlX += x;
curControlY += y;
}
segments[idx] = [isRelative ? "c" : "C", curControlX, curControlY, s[1], s[2], s[3], s[4]];
}
});
return h;
};
})();
lib/util/textSize/textSize.ls
(function(){
return function(o, text){
var textAnchor, align, lineHeight, lines, fontFamily, svg, element, i, line, bbox, w, h;
textAnchor = (function(){
switch (o.align) {
case 'center':
return align = 'middle';
case 'right':
return align = 'end';
default:
return align = 'start';
}
}());
lineHeight = o.lineHeight ? o.lineHeight / o.size : 1;
text = text + "";
lines = text.split('\n');
fontFamily = o.font === 'Solocode School' ? 'Solocode School, sans-serif' : 'Source Sans Pro Solocode, Source Sans Pro, sans-serif';
svg = include('/lib/util/makeSvg/makeSvg')('svg').append(element = include('/lib/util/makeSvg/makeSvg')('text', {
'class': o['class'],
'font-family': fontFamily,
'font-size': o.size,
'font-weight': o.bold ? 'bold' : void 8,
'font-style': o.italic ? 'italic' : void 8,
'text-anchor': textAnchor,
'fill': o.color,
'opacity': o.opacity,
'style': 'user-select: none; cursor: default'
}).append((function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = lines).length; i$ < len$; ++i$) {
i = i$;
line = ref$[i$];
results$.push(include('/lib/util/makeSvg/makeSvg')('tspan', {
'x': 0,
'y': i * lineHeight * o.size
}).text(line));
}
return results$;
}())));
body.append(svg);
bbox = element.getBBox();
w = bbox.width;
h = bbox.height;
svg.remove();
return {
element: element,
w: w,
h: h
};
};
})();
lib/util/util.ls
(function(){
return {
makeSvg: include('makeSvg/makeSvg'),
preloadRequired: include('preloadRequired/preloadRequired'),
getRequired: include('getRequired/getRequired'),
getRequiredSync: include('getRequiredSync/getRequiredSync'),
loadRemoteSvg: include('loadRemoteSvg/loadRemoteSvg'),
resolvePath: include('resolvePath/resolvePath'),
remoteSvgCache: include('remoteSvgCache/remoteSvgCache'),
replaceColor: include('replaceColor/replaceColor'),
replaceLineColor: include('replaceLineColor/replaceLineColor'),
replaceLineSize: include('replaceLineSize/replaceLineSize'),
pathApi: include('pathApi/pathApi'),
svgObject: include('svgObject/svgObject')
};
})();
lsg/fromJS/fromJS.ls
(function(){
var color, object;
color = include('/lib/util/resolveColor/resolveColor');
object = include('/lib/util/jsToLs/jsToLs');
return function(o, path, indent){
var s, lsg, objects, i$, len$, obj;
if (!indent) {
indent = 1;
}
s = Array(indent).join(' ');
indent = indent + 1;
lsg = indent > 2 ? '\n' : '';
if (true) {
lsg += s + "version: 2\n";
}
if (o['class']) {
lsg += s + "class: '" + o['class'] + "'\n";
}
if (true) {
lsg += s + "width: " + _.round(o.width) + "\n";
}
if (true) {
lsg += s + "height: " + _.round(o.height) + "\n";
}
if (o.background) {
lsg += s + "background: " + color(o.background) + "\n";
}
if (o.backgroundLineColor) {
lsg += s + "backgroundLineColor: " + color(o.backgroundLineColor) + "\n";
}
if (o.backgroundLineSize || o.backgroundLineSize === 0) {
lsg += s + "backgroundLineSize: " + _.round(o.backgroundLineSize) + "\n";
}
if (o.color) {
lsg += s + "color: " + object(o.color, indent) + "\n";
}
if (o.lineColor) {
lsg += s + "lineColor: " + object(o.lineColor, indent) + "\n";
}
if (o.lineSize || o.lineSize === 0) {
lsg += s + "lineSize: " + object(_.round(o.lineSize), indent) + "\n";
}
if (o.isEditorMode || o.isEditorMode === false) {
lsg += s + "isEditorMode: " + !!o.isEditorMode + "\n";
}
if (o.objects) {
lsg += s + "objects:\n\n";
}
objects = !_.isArray(o.objects)
? [o.objects]
: o.objects;
for (i$ = 0, len$ = objects.length; i$ < len$; ++i$) {
obj = objects[i$];
switch (obj.type) {
case 'line':
lsg += include('objects/line')(obj, path, indent);
break;
case 'path':
lsg += include('objects/path')(obj, path, indent);
break;
case 'oval':
lsg += include('objects/oval')(obj, path, indent);
break;
case 'rect':
lsg += include('objects/rect')(obj, path, indent);
break;
case 'text':
lsg += include('objects/text')(obj, path, indent);
break;
case 'svg':
lsg += include('objects/svg')(obj, path, indent);
break;
case 'lsg':
lsg += include('objects/lsg')(obj, path, indent);
break;
case 'avatar':
lsg += include('objects/avatar')(obj, path, indent);
break;
case 'image':
lsg += include('objects/image')(obj, path, indent);
}
lsg += "\n";
}
return lsg;
};
})();
lsg/fromJS/objects/avatar.ls
(function(){
var path, color, object;
path = include('/lib/util/resolveRelativePath/resolveRelativePath');
color = include('/lib/util/resolveColor/resolveColor');
object = include('/lib/util/jsToLs/jsToLs');
return function(o, p, i){
var s, indent, lsg, avatarLs, avatarLsLines, i$, len$, line;
s = Array(i).join(' ');
indent = i + 2;
lsg = '';
if (true) {
lsg += s + "* type: '" + o.type + "'\n";
}
if (o['class']) {
lsg += s + " class: '" + o['class'] + "'\n";
}
if (true) {
lsg += s + " x: " + _.round(o.x, 2) + " y: " + _.round(o.y, 2) + "\n";
}
if (o.w && o.h) {
lsg += s + " w: " + _.round(o.w) + " h: " + _.round(o.h) + "\n";
} else if (o.w) {
lsg += s + " w: " + _.round(o.w) + "\n";
} else if (o.h) {
lsg += s + " h: " + _.round(o.h) + "\n";
}
if (o.opacity || o.opacity === 0) {
lsg += s + " opacity: " + _.round(o.opacity, 2) + "\n";
}
if (o.rotate) {
lsg += s + " rotate: " + _.round(o.rotate) + "\n";
}
if (o.flipX || o.flipX === false) {
lsg += s + " flipX: " + !!o.flipX + "\n";
}
if (o.flipY || o.flipY === false) {
lsg += s + " flipY: " + !!o.flipY + "\n";
}
if (o.shadow || o.shadow === false) {
lsg += s + " shadow: " + !!o.shadow + "\n";
}
if (o.locked) {
lsg += s + " locked: " + !!o.locked + "\n";
}
if (o.hidden) {
lsg += s + " hidden: " + !!o.hidden + "\n";
}
if (o.background) {
lsg += s + " background: " + color(o.background) + "\n";
}
if (o.backgroundLineColor) {
lsg += s + " backgroundLineColor: " + color(o.backgroundLineColor) + "\n";
}
if (o.backgroundLineSize) {
lsg += s + " backgroundLineSize: " + _.round(o.backgroundLineSize) + "\n";
}
if (true) {
lsg += s + " avatar:\n";
}
avatarLs = Avatar.toLS(Avatar.validate(o.avatar).avatar);
avatarLsLines = avatarLs.split("\n");
for (i$ = 0, len$ = avatarLsLines.length; i$ < len$; ++i$) {
line = avatarLsLines[i$];
if (line !== "") {
lsg += s + " " + line + "\n";
}
}
return lsg;
};
})();
lsg/fromJS/objects/image.ls
(function(){
var color;
color = include('/lib/util/resolveColor/resolveColor');
return function(o, p, i){
var s, indent, lsg;
s = Array(i).join(' ');
indent = i + 2;
lsg = '';
if (true) {
lsg += s + "* type: '" + o.type + "'\n";
}
if (o['class']) {
lsg += s + " class: '" + o['class'] + "'\n";
}
if (true) {
lsg += s + " image: '" + o['image'] + "'\n";
}
if (true) {
lsg += s + " x: " + _.round(o.x, 2) + " y: " + _.round(o.y, 2) + "\n";
}
if (o.w && o.h) {
lsg += s + " w: " + _.round(o.w) + " h: " + _.round(o.h) + "\n";
} else if (o.w) {
lsg += s + " w: " + _.round(o.w) + "\n";
} else if (o.h) {
lsg += s + " h: " + _.round(o.h) + "\n";
}
if (o.opacity || o.opacity === 0) {
lsg += s + " opacity: " + _.round(o.opacity, 2) + "\n";
}
if (o.rotate || o.rotate === 0) {
lsg += s + " rotate: " + _.round(o.rotate) + "\n";
}
if (o.flipX || o.flipX === false) {
lsg += s + " flipX: " + !!o.flipX + "\n";
}
if (o.flipY || o.flipY === false) {
lsg += s + " flipY: " + !!o.flipY + "\n";
}
if (o.shadow || o.shadow === false) {
lsg += s + " shadow: " + !!o.shadow + "\n";
}
if (o.locked) {
lsg += s + " locked: " + !!o.locked + "\n";
}
if (o.hidden) {
lsg += s + " hidden: " + !!o.hidden + "\n";
}
if (o.crop === true) {
lsg += s + " crop: true\n";
} else if (o.crop === false) {
lsg += s + " crop: false\n";
}
if (o.align) {
lsg += s + " align: '" + o.align + "'\n";
}
return lsg;
};
})();
lsg/fromJS/objects/line.ls
(function(){
var color;
color = include('/lib/util/resolveColor/resolveColor');
return function(o, p, i){
var s, indent, lsg;
s = Array(i).join(' ');
indent = i + 2;
lsg = '';
if (true) {
lsg += s + "* type: '" + o.type + "'\n";
}
if (o['class']) {
lsg += s + " class: '" + o['class'] + "'\n";
}
if (true) {
lsg += s + " x1: " + _.round(o.x1, 2) + " y1: " + _.round(o.y1, 2) + "\n";
}
if (true) {
lsg += s + " x2: " + _.round(o.x2, 2) + " y2: " + _.round(o.y2, 2) + "\n";
}
if (o.lineColor) {
lsg += s + " lineColor: " + color(o.lineColor) + "\n";
}
if (o.lineSize || o.lineSize === 0) {
lsg += s + " lineSize: " + _.round(o.lineSize, 1) + "\n";
}
if (o.lineDash === true) {
lsg += s + " lineDash: true\n";
} else if (o.lineDash === false) {
lsg += s + " lineDash: false\n";
} else if (o.lineDash > 0) {
lsg += s + " lineDash: " + _.round(o.lineDash) + "\n";
}
if (o.lineDashOffset) {
lsg += s + " lineDashOffset: " + _.round(o.lineDashOffset) + "\n";
}
if (o.arrowStart === true) {
lsg += s + " arrowStart: true\n";
} else if (o.arrowStart === false) {
lsg += s + " arrowStart: false\n";
}
if (o.arrowEnd === true) {
lsg += s + " arrowEnd: true\n";
} else if (o.arrowEnd === false) {
lsg += s + " arrowEnd: false\n";
}
if (o.opacity || o.opacity === 0) {
lsg += s + " opacity: " + _.round(o.opacity, 2) + "\n";
}
if (o.locked) {
lsg += s + " locked: " + !!o.locked + "\n";
}
if (o.hidden) {
lsg += s + " hidden: " + !!o.hidden + "\n";
}
if (o.rotate) {
lsg += s + " rotate: " + _.round(o.rotate) + "\n";
}
if (o.flipX || o.flipX === false) {
lsg += s + " flipX: " + !!o.flipX + "\n";
}
if (o.flipY || o.flipY === false) {
lsg += s + " flipY: " + !!o.flipY + "\n";
}
if (o.shadow || o.shadow === false) {
lsg += s + " shadow: " + !!o.shadow + "\n";
}
return lsg;
};
})();
lsg/fromJS/objects/lsg.ls
(function(){
var path, color, object;
path = include('/lib/util/resolveRelativePath/resolveRelativePath');
color = include('/lib/util/resolveColor/resolveColor');
object = include('/lib/util/jsToLs/jsToLs');
return function(o, p, i){
var s, indent, def, custom, lsg, k, v;
s = Array(i).join(' ');
indent = i + 2;
def = ['type', 'class', 'x', 'y', 'w', 'h', 'opacity', 'color', 'lineColor', 'lineSize', 'rotate', 'flipX', 'flipY', 'shadow', 'lsg', 'background', 'backgroundLineColor', 'backgroundLineSize', 'locked', 'hidden'];
custom = _.pickBy(o, function(v, k){
return !_.includes(def, k);
});
lsg = '';
if (true) {
lsg += s + "* type: '" + o.type + "'\n";
}
if (o['class']) {
lsg += s + " class: '" + o['class'] + "'\n";
}
if (!_.isObject(o.lsg)) {
lsg += s + " lsg: " + path(p, o.lsg) + "\n";
}
if (true) {
lsg += s + " x: " + _.round(o.x, 2) + " y: " + _.round(o.y, 2) + "\n";
}
if (o.w && o.h) {
lsg += s + " w: " + _.round(o.w) + " h: " + _.round(o.h) + "\n";
} else if (o.w) {
lsg += s + " w: " + _.round(o.w) + "\n";
} else if (o.h) {
lsg += s + " h: " + _.round(o.h) + "\n";
}
if (o.opacity || o.opacity === 0) {
lsg += s + " opacity: " + _.round(o.opacity, 2) + "\n";
}
if (o.color) {
lsg += s + " color: " + object(o.color, indent) + "\n";
}
if (o.lineColor) {
lsg += s + " lineColor: " + object(o.lineColor, indent) + "\n";
}
if (o.lineSize) {
lsg += s + " lineSize: " + object(o.lineSize, indent) + "\n";
}
if (o.lineDash === true) {
lsg += s + " lineDash: true\n";
}
if (o.lineDash > 0) {
lsg += s + " lineDash: " + _.round(o.lineDash) + "\n";
}
if (o.rotate) {
lsg += s + " rotate: " + _.round(o.rotate) + "\n";
}
if (o.flipX || o.flipX === false) {
lsg += s + " flipX: " + !!o.flipX + "\n";
}
if (o.flipY || o.flipY === false) {
lsg += s + " flipY: " + !!o.flipY + "\n";
}
if (o.shadow || o.shadow === false) {
lsg += s + " shadow: " + !!o.shadow + "\n";
}
if (o.locked) {
lsg += s + " locked: " + !!o.locked + "\n";
}
if (o.hidden) {
lsg += s + " hidden: " + !!o.hidden + "\n";
}
if (o.background) {
lsg += s + " background: " + color(o.background) + "\n";
}
if (o.backgroundLineColor) {
lsg += s + " backgroundLineColor: " + color(o.backgroundLineColor) + "\n";
}
if (o.backgroundLineSize) {
lsg += s + " backgroundLineSize: " + _.round(o.backgroundLineSize) + "\n";
}
for (k in custom) {
v = custom[k];
lsg += s + " " + k + ": " + object(v, indent) + "\n";
}
if (_.isObject(o.lsg)) {
lsg += s + " lsg: " + LSG2.fromJS(o.lsg, p, indent);
}
return lsg;
};
})();
lsg/fromJS/objects/oval.ls
(function(){
var color;
color = include('/lib/util/resolveColor/resolveColor');
return function(o, p, i){
var s, indent, lsg;
s = Array(i).join(' ');
indent = i + 2;
lsg = '';
if (true) {
lsg += s + "* type: '" + o.type + "'\n";
}
if (o['class']) {
lsg += s + " class: '" + o['class'] + "'\n";
}
if (true) {
lsg += s + " x: " + _.round(o.x, 2) + " y: " + _.round(o.y, 2) + "\n";
}
if (o.w && o.h) {
lsg += s + " w: " + _.round(o.w) + " h: " + _.round(o.h) + "\n";
} else if (o.w) {
lsg += s + " w: " + _.round(o.w) + "\n";
} else if (o.h) {
lsg += s + " h: " + _.round(o.h) + "\n";
}
if (o.opacity || o.opacity === 0) {
lsg += s + " opacity: " + _.round(o.opacity, 2) + "\n";
}
if (o.color) {
lsg += s + " color: " + color(o.color) + "\n";
}
if (o.lineSize || o.lineSize === 0) {
lsg += s + " lineSize: " + _.round(o.lineSize, 1) + "\n";
}
if (o.lineColor) {
lsg += s + " lineColor: " + color(o.lineColor) + "\n";
}
if (o.lineDash === true) {
lsg += s + " lineDash: true\n";
} else if (o.lineDash === false) {
lsg += s + " lineDash: false\n";
} else if (o.lineDash > 0) {
lsg += s + " lineDash: " + _.round(o.lineDash) + "\n";
}
if (o.rotate) {
lsg += s + " rotate: " + _.round(o.rotate) + "\n";
}
if (o.flipX || o.flipX === false) {
lsg += s + " flipX: " + !!o.flipX + "\n";
}
if (o.flipY || o.flipY === false) {
lsg += s + " flipY: " + !!o.flipY + "\n";
}
if (o.shadow || o.shadow === false) {
lsg += s + " shadow: " + !!o.shadow + "\n";
}
if (o.locked) {
lsg += s + " locked: " + !!o.locked + "\n";
}
if (o.hidden) {
lsg += s + " hidden: " + !!o.hidden + "\n";
}
return lsg;
};
})();
lsg/fromJS/objects/path.ls
(function(){
var color;
color = include('/lib/util/resolveColor/resolveColor');
return function(o, p, i){
var s, indent, lsg;
s = Array(i).join(' ');
indent = i + 2;
lsg = '';
if (true) {
lsg += s + "* type: '" + o.type + "'\n";
}
if (o['class']) {
lsg += s + " class: '" + o['class'] + "'\n";
}
if (true) {
lsg += s + " x: " + _.round(o.x, 2) + " y: " + _.round(o.y, 2) + "\n";
}
if (o.w && o.h) {
lsg += s + " w: " + _.round(o.w) + " h: " + _.round(o.h) + "\n";
} else if (o.w) {
lsg += s + " w: " + _.round(o.w) + "\n";
} else if (o.h) {
lsg += s + " h: " + _.round(o.h) + "\n";
}
if (o.color) {
lsg += s + " color: " + color(o.color) + "\n";
}
if (o.lineColor) {
lsg += s + " lineColor: " + color(o.lineColor) + "\n";
}
if (o.lineSize || o.lineSize === 0) {
lsg += s + " lineSize: " + _.round(o.lineSize, 1) + "\n";
}
if (o.lineDash === true) {
lsg += s + " lineDash: true\n";
} else if (o.lineDash === false) {
lsg += s + " lineDash: false\n";
} else if (o.lineDash > 0) {
lsg += s + " lineDash: " + _.round(o.lineDash) + "\n";
}
if (o.lineDashOffset) {
lsg += s + " lineDashOffset: " + _.round(o.lineDashOffset) + "\n";
}
if (o.arrowStart === true) {
lsg += s + " arrowStart: true\n";
} else if (o.arrowStart === false) {
lsg += s + " arrowStart: false\n";
}
if (o.arrowEnd === true) {
lsg += s + " arrowEnd: true\n";
} else if (o.arrowEnd === false) {
lsg += s + " arrowEnd: false\n";
}
if (o.opacity || o.opacity === 0) {
lsg += s + " opacity: " + _.round(o.opacity, 2) + "\n";
}
if (o.rotate) {
lsg += s + " rotate: " + _.round(o.rotate) + "\n";
}
if (o.flipX || o.flipX === false) {
lsg += s + " flipX: " + !!o.flipX + "\n";
}
if (o.flipY || o.flipY === false) {
lsg += s + " flipY: " + !!o.flipY + "\n";
}
if (o.shadow || o.shadow === false) {
lsg += s + " shadow: " + !!o.shadow + "\n";
}
if (o.locked) {
lsg += s + " locked: " + !!o.locked + "\n";
}
if (o.hidden) {
lsg += s + " hidden: " + !!o.hidden + "\n";
}
if (true) {
lsg += s + " path: '" + o.path + "'\n";
}
return lsg;
};
})();
lsg/fromJS/objects/rect.ls
(function(){
var color;
color = include('/lib/util/resolveColor/resolveColor');
return function(o, p, i){
var s, indent, lsg;
s = Array(i).join(' ');
indent = i + 2;
lsg = '';
if (true) {
lsg += s + "* type: '" + o.type + "'\n";
}
if (o['class']) {
lsg += s + " class: '" + o['class'] + "'\n";
}
if (true) {
lsg += s + " x: " + _.round(o.x, 2) + " y: " + _.round(o.y, 2) + "\n";
}
if (o.w && o.h) {
lsg += s + " w: " + _.round(o.w) + " h: " + _.round(o.h) + "\n";
} else if (o.w) {
lsg += s + " w: " + _.round(o.w) + "\n";
} else if (o.h) {
lsg += s + " h: " + _.round(o.h) + "\n";
}
if (o.opacity || o.opacity === 0) {
lsg += s + " opacity: " + _.round(o.opacity, 2) + "\n";
}
if (o.color) {
lsg += s + " color: " + color(o.color) + "\n";
}
if (o.lineSize || o.lineSize === 0) {
lsg += s + " lineSize: " + _.round(o.lineSize, 1) + "\n";
}
if (o.lineColor) {
lsg += s + " lineColor: " + color(o.lineColor) + "\n";
}
if (o.lineDash === true) {
lsg += s + " lineDash: true\n";
} else if (o.lineDash === false) {
lsg += s + " lineDash: false\n";
} else if (o.lineDash > 0) {
lsg += s + " lineDash: " + _.round(o.lineDash) + "\n";
}
if (o.rounded || o.rounded === 0) {
lsg += s + " rounded: " + _.round(o.rounded) + "\n";
}
if (o.rotate || o.rotate === 0) {
lsg += s + " rotate: " + _.round(o.rotate) + "\n";
}
if (o.flipX || o.flipX === false) {
lsg += s + " flipX: " + !!o.flipX + "\n";
}
if (o.flipY || o.flipY === false) {
lsg += s + " flipY: " + !!o.flipY + "\n";
}
if (o.shadow || o.shadow === false) {
lsg += s + " shadow: " + !!o.shadow + "\n";
}
if (o.locked) {
lsg += s + " locked: " + !!o.locked + "\n";
}
if (o.hidden) {
lsg += s + " hidden: " + !!o.hidden + "\n";
}
return lsg;
};
})();
lsg/fromJS/objects/svg.ls
(function(){
var path, color, object;
path = include('/lib/util/resolveRelativePath/resolveRelativePath');
color = include('/lib/util/resolveColor/resolveColor');
object = include('/lib/util/jsToLs/jsToLs');
return function(o, p, i){
var s, indent, lines, totalLines, lsg, i$, len$, line;
s = Array(i).join(' ');
indent = i + 2;
lines = o.svg.split(/\r?\n/g);
totalLines = lines.length;
lsg = '';
if (true) {
lsg += s + "* type: '" + o.type + "'\n";
}
if (o['class']) {
lsg += s + " class: '" + o['class'] + "'\n";
}
if (totalLines < 2) {
lsg += s + " svg: " + path(p, o.svg) + "\n";
if (o.includeSvg) {
lsg += s + " includeSvg: true\n";
}
} else {
lsg += s + " svg: '''\n";
for (i$ = 0, len$ = lines.length; i$ < len$; ++i$) {
line = lines[i$];
lsg += s + " " + line + "\n";
}
lsg += s + " '''\n";
}
if (true) {
lsg += s + " x: " + _.round(o.x, 2) + " y: " + _.round(o.y, 2) + "\n";
}
if (o.w && o.h) {
lsg += s + " w: " + _.round(o.w) + " h: " + _.round(o.h) + "\n";
} else if (o.w) {
lsg += s + " w: " + _.round(o.w) + "\n";
} else if (o.h) {
lsg += s + " h: " + _.round(o.h) + "\n";
}
if (o.opacity || o.opacity === 0) {
lsg += s + " opacity: " + _.round(o.opacity, 2) + "\n";
}
if (o.color) {
lsg += s + " color: " + object(o.color, indent) + "\n";
}
if (o.lineColor) {
lsg += s + " lineColor: " + object(o.lineColor, indent) + "\n";
}
if (o.lineSize || o.lineSize === 0) {
lsg += s + " lineSize: " + object(o.lineSize, indent) + "\n";
}
if (o.lineDash === true) {
lsg += s + " lineDash: true\n";
}
if (o.lineDash > 0) {
lsg += s + " lineDash: " + _.round(o.lineDash) + "\n";
}
if (o.rotate) {
lsg += s + " rotate: " + _.round(o.rotate) + "\n";
}
if (o.flipX || o.flipX === false) {
lsg += s + " flipX: " + !!o.flipX + "\n";
}
if (o.flipY || o.flipY === false) {
lsg += s + " flipY: " + !!o.flipY + "\n";
}
if (o.shadow || o.shadow === false) {
lsg += s + " shadow: " + !!o.shadow + "\n";
}
if (o.locked) {
lsg += s + " locked: " + !!o.locked + "\n";
}
if (o.hidden) {
lsg += s + " hidden: " + !!o.hidden + "\n";
}
if (o.background) {
lsg += s + " background: " + color(o.background) + "\n";
}
if (o.backgroundLineColor) {
lsg += s + " backgroundLineColor: " + color(o.backgroundLineColor) + "\n";
}
if (o.backgroundLineSize) {
lsg += s + " backgroundLineSize: " + _.round(o.backgroundLineSize) + "\n";
}
if (o.crop === true) {
lsg += s + " crop: true\n";
} else if (o.crop === false) {
lsg += s + " crop: false\n";
}
if (o.align) {
lsg += s + " align: '" + o.align + "'\n";
}
if (o.svgClasses) {
lsg += s + " svgClasses: '" + o.svgClasses + "'\n";
}
return lsg;
};
})();
lsg/fromJS/objects/text.ls
(function(){
var color;
color = include('/lib/util/resolveColor/resolveColor');
return function(o, p, i){
var s, indent, text, lines, totalLines, lsg, i$, len$, line;
s = Array(i).join(' ');
indent = i + 2;
text = o.text.replace(/\'/g, "\\'");
lines = text.split(/\r?\n/g);
totalLines = lines.length;
lsg = '';
if (true) {
lsg += s + "* type: '" + o.type + "'\n";
}
if (o['class']) {
lsg += s + " class: '" + o['class'] + "'\n";
}
if (totalLines < 2) {
lsg += s + " text: '" + text + "'\n";
} else {
lsg += s + " text: '''\n";
for (i$ = 0, len$ = lines.length; i$ < len$; ++i$) {
line = lines[i$];
lsg += s + " " + line + "\n";
}
lsg += s + " '''\n";
}
if (true) {
lsg += s + " x: " + _.round(o.x || 0, 2) + " y: " + _.round(o.y || 0, 2) + "\n";
}
if (o.opacity || o.opacity === 0) {
lsg += s + " opacity: " + _.round(o.opacity, 2) + "\n";
}
if (o.color) {
lsg += s + " color: " + color(o.color) + "\n";
}
if (true) {
lsg += s + " size: " + _.round(o.size) + "\n";
}
if (o.lineHeight) {
lsg += s + " lineHeight: " + _.round(o.lineHeight) + "\n";
}
if (o.align) {
lsg += s + " align: '" + o.align + "'\n";
}
if (o.font) {
lsg += s + " font: '" + o.font + "'\n";
}
if (o.bold || o.italic === false) {
lsg += s + " bold: " + !!o.bold + "\n";
}
if (o.italic || o.italic === false) {
lsg += s + " italic: " + !!o.italic + "\n";
}
if (o.rotate) {
lsg += s + " rotate: " + _.round(o.rotate) + "\n";
}
if (o.flipX || o.flipX === false) {
lsg += s + " flipX: " + !!o.flipX + "\n";
}
if (o.flipY || o.flipY === false) {
lsg += s + " flipY: " + !!o.flipY + "\n";
}
if (o.shadow || o.shadow === false) {
lsg += s + " shadow: " + !!o.shadow + "\n";
}
if (o.locked) {
lsg += s + " locked: " + !!o.locked + "\n";
}
if (o.hidden) {
lsg += s + " hidden: " + !!o.hidden + "\n";
}
return lsg;
};
})();
lsg/lsg.ls
(function(){
return function(){
return {
toJS: inc('toJS/toJS'),
fromJS: inc('fromJS/fromJS'),
toSVG: inc('toSVG/toSVG'),
toDiv: inc('toDiv/toDiv'),
util: inc('/lib/util/util')
};
};
})();
lsg/toDiv/objects/image.ls
(function(){
return function(lsg, o, imageBase64Texts){
var update, div;
update = function(){
var url, ref$, transform, top, ref1$, left, ref2$, bottom, ref3$, right, ref4$, bpx, bpy, backgroundPosition, backgroundSize, filter, pointerEvents;
o.widthCalculated = o.w || o.h;
o.heightCalculated = o.h || o.w;
url = ((ref$ = _.find(imageBase64Texts, {
id: o.image
})) != null ? ref$.base64 : void 8) || "https://images.anton.app/image/small?imageId=" + o.image;
transform = include("util/calcTransform/calc")(o);
top = _.includes((ref1$ = o.align) != null ? ref1$.toLowerCase() : void 8, "top");
left = _.includes((ref2$ = o.align) != null ? ref2$.toLowerCase() : void 8, "left");
bottom = _.includes((ref3$ = o.align) != null ? ref3$.toLowerCase() : void 8, "bottom");
right = _.includes((ref4$ = o.align) != null ? ref4$.toLowerCase() : void 8, "right");
bpx = left
? "0%"
: right ? "100%" : "50%";
bpy = top
? "0%"
: bottom ? "100%" : "50%";
backgroundPosition = bpx + " " + bpy;
backgroundSize = o.crop ? "cover" : "contain";
filter = o.shadow ? "drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3))" : "";
pointerEvents = _.includes(o['class'], "ignore") && !lsg.isEditorMode ? "none" : void 8;
return div.addClass(o['class']).css({
position: "absolute",
left: o.x + "px",
top: o.y + "px",
width: o.widthCalculated + "px",
height: o.heightCalculated + "px",
transform: transform,
backgroundRepeat: "no-repeat",
backgroundImage: "url(" + url + ")",
opacity: o.opacity,
backgroundSize: backgroundSize,
backgroundPosition: backgroundPosition,
filter: filter,
pointerEvents: pointerEvents,
willChange: ""
});
};
div = Div();
div.setParams = function(params){
var name, param;
for (name in params) {
param = params[name];
o[name] = param;
}
return update();
};
div.getParams = function(){
return _.cloneDeep(o);
};
div.lsgObjectParams = o;
update();
return div;
};
})();
lsg/toDiv/objects/line.ls
(function(){
return function(lsg, o){
var update, div;
update = function(){
var left, x1, x2, top, y1, y2, uid, markerWidth, dx, dy, l, markerSize, markerEnd, markerStart, strokeDashArray, strokeDashOffset, svg, transform, filter, pointerEvents;
left = _.min([o.x1, o.x2]);
x1 = o.x1 - left;
x2 = o.x2 - left;
o.widthCalculated = _.max([x1, x2, 1]);
top = _.min([o.y1, o.y2]);
y1 = o.y1 - top;
y2 = o.y2 - top;
o.heightCalculated = _.max([y1, y2, 1]);
if (o.arrowEnd || o.arrowStart) {
uid = helpers.guid(4);
markerWidth = 4;
dx = x2 - x1;
dy = y2 - y1;
l = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
dx /= l;
dy /= l;
markerSize = (markerWidth - 0.5) * o.lineSize;
}
if (o.arrowEnd) {
x2 -= dx * markerSize;
y2 -= dy * markerSize;
markerEnd = "url(#arrowEnd" + uid + ")";
}
if (o.arrowStart) {
x1 += dx * markerSize;
y1 += dy * markerSize;
markerStart = "url(#arrowStart" + uid + ")";
}
strokeDashArray = o.lineDash === true
? "10, 10"
: o.lineDash ? o.lineDash + ", " + o.lineDash : void 8;
strokeDashOffset = o.lineDash === true ? o.lineDashOffset : void 8;
svg = include("/lib/util/makeSvg/makeSvg")("svg", {
"width": o.widthCalculated,
"height": o.heightCalculated,
"viewBox": "0 0 " + o.widthCalculated + " " + o.heightCalculated,
"preserve-aspect-ratio": "none",
"overflow": "visible"
}).append(o.arrowEnd ? include("util/arrowHead/arrowHead")(o, "arrowEnd", markerWidth, uid) : void 8, o.arrowStart ? include("util/arrowHead/arrowHead")(o, "arrowStart", markerWidth, uid) : void 8, include("/lib/util/makeSvg/makeSvg")("line", {
"x1": x1,
"y1": y1,
"x2": x2,
"y2": y2,
"stroke": o.lineColor,
"stroke-width": o.lineSize || 5,
"stroke-dasharray": strokeDashArray,
"stroke-dashoffset": strokeDashOffset,
"marker-end": markerEnd,
"marker-start": markerStart
}));
transform = include("util/calcTransform/calc")(o);
filter = o.shadow ? "drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3))" : "";
pointerEvents = _.includes(o['class'], "ignore") && !lsg.isEditorMode ? "none" : void 8;
div.setSvg(svg);
return div.addClass(o['class']).css({
position: "absolute",
left: left + "px",
top: top + "px",
width: o.widthCalculated + "px",
height: o.heightCalculated + "px",
transform: transform,
opacity: o.opacity,
filter: filter,
pointerEvents: pointerEvents,
willChange: ""
});
};
div = Svg({
svg: path("/lib/svg/error.svg")
});
div.setParams = function(params){
var name, param;
for (name in params) {
param = params[name];
o[name] = param;
}
return update();
};
div.getParams = function(){
return _.cloneDeep(o);
};
div.lsgObjectParams = o;
update();
return div;
};
})();
lsg/toDiv/objects/lsg.ls
(function(){
return function(lsg, o, svgTexts, lsgTexts, renderLanguage){
var update, div;
update = function(){
var inheritBackground, lsg, svg, ref$, renderer, o2, i$, ref1$, len$, object, classes, ref2$, lsgDiv, r, scaleX, scaleY, transform, filter, pointerEvents;
inheritBackground = function(o, lsg){
var that;
if (that = o.background) {
lsg.background = that;
}
if (that = o.backgroundLineColor) {
lsg.backgroundLineColor = that;
}
if (that = o.backgroundLineSize) {
return lsg.backgroundLineSize = that;
}
};
if (o.lsg && _.isObject(o.lsg)) {
lsg = o.lsg;
inheritBackground(o, lsg);
svg = LSG2.toSVG(o.lsg, svgTexts, lsgTexts);
} else if (o.lsg && ((ref$ = o.lsg) != null ? ref$.slice(0, 4) : void 8) === '/../' && _.includes(o.lsg, '.lsr')) {
renderer = include(o.lsg);
o2 = _.cloneDeep(o);
o2.renderLanguage = renderLanguage;
lsg = renderer.render
? renderer.render(o2)
: renderer(o2);
inheritBackground(o, lsg);
if (_.includes(o['class'], "ignore") || lsg.isEditorMode) {
for (i$ = 0, len$ = (ref1$ = _.ensureArray(lsg.objects)).length; i$ < len$; ++i$) {
object = ref1$[i$];
classes = ((ref2$ = object['class']) != null ? ref2$.split(" ") : void 8) || [];
classes.push("ignore");
object['class'] = classes.join(" ");
}
}
lsgDiv = LSG2.toDiv(lsg, svgTexts, lsgTexts);
} else if (o.lsg && ((ref1$ = o.lsg) != null ? ref1$.slice(0, 4) : void 8) === '/../') {
lsg = (lsgTexts != null ? lsgTexts[o.lsg] : void 8) || include(o.lsg);
inheritBackground(o, lsg);
lsgDiv = LSG2.toDiv(lsg, svgTexts, lsgTexts);
} else {
helpers.errorHandler("lsg not found: " + o.lsg, '/../lsg2/lsg/toSVG/objects/lsg.ls');
return;
}
r = lsg.width / lsg.height;
if (o.w && o.h) {
o.widthCalculated = o.w;
o.heightCalculated = o.h;
} else if (o.w) {
o.widthCalculated = o.w;
o.heightCalculated = o.w / r;
} else {
o.widthCalculated = o.h / r;
o.heightCalculated = o.h;
}
scaleX = o.widthCalculated / lsg.width;
scaleY = o.heightCalculated / lsg.height;
transform = include("util/calcTransform/calc")(o, scaleX, scaleY);
filter = o.shadow ? "drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3))" : "";
pointerEvents = _.includes(o['class'], "ignore") && !lsg.isEditorMode ? "none" : void 8;
return div.addClass(o['class']).css({
position: "absolute",
display: "flex",
left: o.x + "px",
top: o.y + "px",
width: o.widthCalculated + "px",
height: o.heightCalculated + "px",
transform: transform,
opacity: o.opacity,
filter: filter,
pointerEvents: pointerEvents,
willChange: ""
}).html(lsgDiv);
};
div = Div();
div.setParams = function(params){
var name, param;
for (name in params) {
param = params[name];
o[name] = param;
}
return update();
};
div.getParams = function(){
return _.cloneDeep(o);
};
div.lsgObjectParams = o;
update();
return div;
};
})();
lsg/toDiv/objects/oval.ls
(function(){
return function(lsg, o){
var update, div;
update = function(){
var transform, border, borderType, lineSize, filter, pointerEvents;
transform = include("util/calcTransform/calc")(o);
border = o.lineSize && o.lineColor ? (borderType = o.lineDash ? "dashed" : "solid", lineSize = _.min([o.lineSize, o.w / 2, o.h / 2]), lineSize + "px " + borderType + " " + o.lineColor) : "";
filter = o.shadow ? "drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3))" : "";
pointerEvents = _.includes(o['class'], "ignore") && !lsg.isEditorMode ? "none" : void 8;
o.widthCalculated = o.w;
o.heightCalculated = o.h;
return div.addClass(o['class']).css({
position: "absolute",
left: o.x + "px",
top: o.y + "px",
width: o.w + "px",
height: o.h + "px",
transform: transform,
opacity: o.opacity,
background: o.color,
borderRadius: "50%",
strokeDasharray: "20px",
filter: filter,
border: border,
pointerEvents: pointerEvents,
willChange: ""
});
};
div = Div();
div.setParams = function(params){
var name, param;
for (name in params) {
param = params[name];
o[name] = param;
}
return update();
};
div.getParams = function(){
return _.cloneDeep(o);
};
div.lsgObjectParams = o;
update();
return div;
};
})();
lsg/toDiv/objects/path.ls
(function(){
return function(lsg, o){
var svg, childSvg, update, div;
update = function(){
var path, w, h, r, scaleX, scaleY, uid, markerWidth, transform, filter;
path = include("/lib/util/pathApi/pathApi")(o.path);
w = path.w() || 1;
h = path.h() || 1;
r = w / h;
o.widthCalculated = o.w
? o.w
: o.h ? o.h * r : w;
o.heightCalculated = o.h
? o.h
: o.w ? o.w / r : h;
scaleX = o.widthCalculated / w;
scaleY = o.heightCalculated / h;
if (o.arrowEnd || o.arrowStart) {
uid = helpers.guid(4);
markerWidth = 4;
}
if (!svg) {
svg = include("/lib/util/makeSvg/makeSvg")("svg", {
"preserve-aspect-ratio": "none",
"overflow": "visible",
"width": o.widthCalculated,
"height": o.heightCalculated,
"viewBox": "0 0 " + o.widthCalculated + " " + o.heightCalculated
}).append(o.arrowEnd ? include("util/arrowHead/arrowHead")(o, "arrowEnd", markerWidth, uid) : void 8, o.arrowStart ? include("util/arrowHead/arrowHead")(o, "arrowStart", markerWidth, uid) : void 8, childSvg = include("/lib/util/makeSvg/makeSvg")("path", {
"vector-effect": "non-scaling-stroke"
}));
div.setSvg(svg);
}
svg.attr({
"width": o.widthCalculated,
"height": o.heightCalculated,
"viewBox": "0 0 " + o.widthCalculated + " " + o.heightCalculated
});
childSvg.attr({
"x": o.x,
"y": o.y,
"d": o.path,
"fill": o.color || "transparent",
"stroke": o.lineColor,
"stroke-width": o.lineSize,
"transform": "scale(" + scaleX + "," + scaleY + ")",
"stroke-dasharray": o.lineDash === true
? "10, 10"
: o.lineDash ? o.lineDash + ", " + o.lineDash : void 8,
"stroke-dashoffset": o.lineDash === true ? o.lineDashOffset : void 8,
"marker-end": o.arrowEnd ? "url(#arrowEnd" + uid + ")" : void 8,
"marker-start": o.arrowStart ? "url(#arrowStart" + uid + ")" : void 8
}).css({
pointerEvents: !_.includes(o['class'], "ignore") && !lsg.isEditorMode ? "auto" : void 8
});
transform = include("util/calcTransform/calc")(o);
filter = o.shadow ? "drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3))" : "";
return div.addClass(o['class']).css({
position: "absolute",
left: (o.x || 0) + "px",
top: (o.y || 0) + "px",
width: o.widthCalculated + "px",
height: o.heightCalculated + "px",
transform: transform,
overflow: "visible",
opacity: o.opacity,
filter: filter,
pointerEvents: "none",
willChange: ""
});
};
div = Svg({
svg: path("/lib/svg/error.svg")
});
div.setParams = function(params){
var name, param;
for (name in params) {
param = params[name];
o[name] = param;
}
return update();
};
div.getParams = function(){
return _.cloneDeep(o);
};
div.lsgObjectParams = o;
update();
return div;
};
})();
lsg/toDiv/objects/rect.ls
(function(){
return function(lsg, o){
var update, div;
update = function(){
var transform, border, borderType, lineSize, filter, borderRadius, pointerEvents;
transform = include("util/calcTransform/calc")(o);
border = o.lineSize && o.lineColor ? (borderType = o.lineDash ? "dashed" : "solid", lineSize = _.min([o.lineSize, o.w / 2, o.h / 2]), lineSize + "px " + borderType + " " + o.lineColor) : "";
filter = o.shadow ? "drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3))" : "";
borderRadius = o.rounded ? o.rounded + "px" : void 8;
pointerEvents = _.includes(o['class'], "ignore") && !lsg.isEditorMode ? "none" : void 8;
o.widthCalculated = o.w;
o.heightCalculated = o.h;
return div.addClass(o['class']).css({
position: "absolute",
left: o.x + "px",
top: o.y + "px",
width: o.w + "px",
height: o.h + "px",
transform: transform,
opacity: o.opacity,
background: o.color,
borderRadius: borderRadius,
strokeDasharray: "20px",
filter: filter,
border: border,
pointerEvents: pointerEvents,
willChange: ""
});
};
div = Div();
div.setParams = function(params){
var name, param;
for (name in params) {
param = params[name];
o[name] = param;
}
return update();
};
div.getParams = function(){
return _.cloneDeep(o);
};
div.lsgObjectParams = o;
update();
return div;
};
})();
lsg/toDiv/objects/svg.ls
(function(){
return function(lsg, o, svgTexts){
var svg, backgroundDiv, addBackground, update, div;
addBackground = function(o, svg){
var width, height, rect;
if (o.background || o.backgroundLineSize) {
width = svg.attr('lsg:w');
height = svg.attr('lsg:h');
rect = include('rect')(lsg, {
x: 0,
y: 0,
w: width,
h: height,
color: o.background,
lineColor: o.backgroundLineColor,
lineSize: o.backgroundLineSize
});
return svg.prepend(rect);
}
};
update = function(){
var ref$, svgPath, ref1$, path, ref2$, i$, ref3$, len$, elem, transform, filter, width, height, border, background;
if (!svg) {
if (_.includes(o.svg, '')) {
svg = o.svg;
} else if (((ref$ = o.svg) != null ? ref$.slice(0, 4) : void 8) === '/../' && o.includeSvg === true) {
svgPath = o.svg;
svg = include(svgPath);
} else if (((ref1$ = o.svg) != null ? ref1$.slice(0, 4) : void 8) === '/../') {
path = o.svg;
svg = _.isArray(svgTexts)
? (ref2$ = _.find(svgTexts, {
path: path
})) != null ? ref2$.svgText : void 8
: LSG2.util.remoteSvgCache.svg(path);
} else {
helpers.errorHandler("svg not found: " + o.svg, '/../lsg2/lsg/toSVG/objects/svg.ls');
return;
}
svg = Svg({
svg: svg
}).svgElement;
if (!_.includes(o['class'], "ignore") || lsg.isEditorMode) {
for (i$ = 0, len$ = (ref3$ = svg.childrenAll()).length; i$ < len$; ++i$) {
elem = ref3$[i$];
elem.css({
pointerEvents: "auto"
});
}
}
transform = include("util/calcTransform/calc")(o);
include('/lib/util/prepareSvg/prepareSvg')(o, svg, true);
filter = o.shadow ? "drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3))" : "";
if (o.w && o.h) {
width = o.w;
height = o.h;
} else {
width = svg.attr("width");
height = svg.attr("height");
}
o.widthCalculated = width;
o.heightCalculated = height;
div.setSvg(svg, o.w, o.h);
}
include('/lib/util/resolveOverrides/resolveOverrides')(o, svg);
div.addClass(o['class']).css({
position: "absolute",
left: o.x + "px",
top: o.y + "px",
width: width + "px",
height: height + "px",
transform: transform,
opacity: o.opacity,
filter: filter,
willChange: ""
});
border = o.backgroundLineSize ? o.backgroundLineSize + "px solid " + o.backgroundLineColor : "";
background = o.background ? o.background : "";
return backgroundDiv.css({
background: background,
border: border
});
};
div = Svg({
svg: path("/lib/svg/error.svg")
}).css({
pointerEvents: "none"
}).append(backgroundDiv = Div().css({
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: -999
}));
div.setParams = function(params){
var name, param;
for (name in params) {
param = params[name];
o[name] = param;
}
return update();
};
div.getParams = function(){
return _.cloneDeep(o);
};
div.lsgObjectParams = o;
update();
return div;
};
})();
lsg/toDiv/objects/text.ls
(function(){
return function(lsg, o){
var update, div;
update = function(){
var fontFamily, textAlign, lineHeight, marginTop, filter, fontWeight, fontStyle, pointerEvents, text;
fontFamily = o.font === 'Solocode School' ? 'Solocode School, sans-serif' : 'Source Sans Pro Solocode, Source Sans Pro, sans-serif';
textAlign = o.align === "center"
? "center"
: o.align === "right" ? "right" : "left";
lineHeight = o.lineHeight || o.size;
marginTop = 0.145 * o.size - (lineHeight - o.size - o.size * 0.145) / 2;
filter = o.shadow ? "drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3))" : "";
fontWeight = o.bold ? "bold" : "normal";
fontStyle = o.italic ? "italic" : "normal";
pointerEvents = _.includes(o['class'], "ignore") && !lsg.isEditorMode ? "none" : void 8;
text = o.text.replace("(\r\n|\r|\n)", "
");
return div.addClass(o['class']).css({
position: "absolute",
display: "inline-block",
color: o.color,
left: o.x + "px",
top: o.y + "px",
fontSize: o.size + "px",
lineHeight: lineHeight + "px",
fontFamily: fontFamily,
textAlign: textAlign,
fontWeight: fontWeight,
fontStyle: fontStyle,
marginTop: marginTop + "px",
opacity: o.opacity,
filter: filter,
pointerEvents: pointerEvents,
whiteSpace: "nowrap",
willChange: ""
}).onDomAppendAndVisible(function(){
var translateX, transform;
o.widthCalculated = div.offsetWidth;
o.heightCalculated = div.offsetHeight;
translateX = o.align === "center"
? -1 * o.widthCalculated / 2
: o.align === "right" ? -1 * o.widthCalculated : 0;
transform = include("util/calcTransform/calc")(o, null, null, translateX);
return div.css({
transform: transform
});
}).html(text);
};
div = Div();
div.setParams = function(params){
var name, param;
for (name in params) {
param = params[name];
o[name] = param;
}
return update();
};
div.getParams = function(){
return _.cloneDeep(o);
};
div.lsgObjectParams = o;
update();
return div;
};
})();
lsg/toDiv/objects/util/arrowHead/arrowHead.ls
(function(){
return function(o, type, markerWidth, uid){
var id, refX, transform;
id = type === "arrowStart"
? "arrowStart" + uid
: "arrowEnd" + uid;
refX = type === "arrowStart" ? markerWidth - 0.5 : 0.5;
transform = type === "arrowStart" ? "rotate(180 2 2)" : void 8;
return include("/lib/util/makeSvg/makeSvg")("marker", {
"id": id,
"orient": "auto",
"markerWidth": markerWidth,
"markerHeight": markerWidth,
"refX": refX,
"refY": markerWidth / 2
}).append(include("/lib/util/makeSvg/makeSvg")("path", {
"d": "M0,0 L0," + markerWidth + " L" + markerWidth + "," + markerWidth / 2 + " z",
"fill": o.lineColor,
"transform": transform
}));
};
})();
lsg/toDiv/objects/util/calcTransform/calc.ls
(function(){
return function(o, scaleX, scaleY, translateX, translateY){
var transforms, transform;
scaleX = scaleX || 1;
scaleY = scaleY || 1;
transforms = [];
if (translateX) {
transforms.push("translateX(" + translateX + "px)");
}
if (translateY) {
transforms.push("translateY(" + -1 * translateY + "px)");
}
if (o.flipX) {
transforms.push("scaleX(" + -1 * scaleX + ")");
} else if (scaleX !== 1) {
transforms.push("scaleX(" + scaleX + ")");
}
if (o.flipY) {
transforms.push("scaleY(" + -1 * scaleY + ")");
} else if (scaleY !== 1) {
transforms.push("scaleY(" + scaleY + ")");
}
if (o.rotate) {
transforms.push("rotate(" + o.rotate + "deg)");
}
transform = transforms.length ? transforms.join(" ") : void 8;
return transform;
};
})();
lsg/toDiv/toDiv.ls
(function(){
return function(o, svgTexts, lsgTexts, imageBase64Texts){
var update, setScale, lsgTap, lsgMove, setEditorMode, setLsgDescription, div, handleEvent;
update = function(){
var border, i$, ref$, len$, object, elem;
o.lsgDiv = Div().css({
display: "block",
overflow: "hidden",
width: o.width + "px",
height: o.height + "px",
background: o.background,
border: border
});
border = o.backgroundLineSize && o.backgroundLineColor ? o.backgroundLineSize + "px solid " + o.backgroundLineColor : void 8;
if (border) {
o.lsgDiv.html(Div({
width: "100%",
height: "100%",
border: border,
pointerEvents: "none"
}));
}
for (i$ = 0, len$ = (ref$ = _.ensureArray(o.objects)).length; i$ < len$; ++i$) {
object = ref$[i$];
elem = (fn$());
o.lsgDiv.append(elem);
}
include("/lib/util/resolveOverrides/resolveOverrides")(o, o.lsgDiv);
return div.html(o.lsgDiv).onDomAppendAndVisible(setScale);
function fn$(){
switch (object.type) {
case 'line':
return include('objects/line')(o, object);
case 'path':
return include('objects/path')(o, object);
case 'oval':
return include('objects/oval')(o, object);
case 'rect':
return include('objects/rect')(o, object);
case 'text':
return include('objects/text')(o, object);
case 'svg':
return include('objects/svg')(o, object, svgTexts);
case 'lsg':
return include('objects/lsg')(o, object, svgTexts, lsgTexts, o.renderLanguage);
case 'image':
return include('objects/image')(o, object, imageBase64Texts);
default:
return debug("unknown LSG object type: " + object.type);
}
}
};
setScale = function(){
var w, h, s;
w = div.offsetWidth;
h = div.offsetHeight;
if (w / h > o.width / o.height) {
s = h / o.height;
} else {
s = w / o.width;
}
return o.lsgDiv.css({
transform: "scale(" + s + ")"
});
};
lsgTap = function(onLsgTap){
if (_.isFunction(onLsgTap)) {
o.onTapUp = onLsgTap;
return;
}
if (onLsgTap.up) {
o.onTapUp = onLsgTap.up;
}
if (onLsgTap.down) {
return o.onTapDown = onLsgTap.down;
}
};
lsgMove = function(onLsgMove){
return o.onMove = onLsgMove;
};
setEditorMode = function(isEditorMode){
o.isEditorMode = isEditorMode;
return update();
};
setLsgDescription = function(lsgDescription){
o['class'] = lsgDescription['class'];
o.width = lsgDescription.width;
o.height = lsgDescription.height;
o.background = lsgDescription.background;
o.backgroundLineColor = lsgDescription.backgroundLineColor;
o.backgroundLineSize = lsgDescription.backgroundLineSize;
o.color = lsgDescription.color;
o.lineColor = lsgDescription.lineColor;
o.lineSize = lsgDescription.lineSize;
o.isEditorMode = lsgDescription.isEditorMode;
o.objects = lsgDescription.objects;
return update();
};
div = Div().css({
display: "inline-flex"
});
handleEvent = inc("util/handleEvent/handle");
div.bind("mousedown touchstart", function(e){
return handleEvent(o.onTapDown, e);
});
div.bind("mouseup touchend", function(e){
return handleEvent(o.onTapUp, e);
});
div.bind("mousemove touchmove", function(e){
return handleEvent(o.onMove, e);
});
div.lsgTap = lsgTap;
div.lsgMove = lsgMove;
div.setEditorMode = setEditorMode;
div.setScale = setScale;
div.setLsgDescription = setLsgDescription;
update();
return div;
};
})();
lsg/toDiv/util/handleEvent/findEventLsgObjectElement/find.ls
(function(){
return function(e){
var elem, parentElem;
elem = e.target;
if (elem.tagName.toLowerCase() === "svg" || (elem.tagName.toLowerCase() === "div" && !elem.lsgObjectParams)) {
return;
}
parentElem = elem;
while (parentElem) {
if (parentElem.lsgObjectParams) {
return parentElem;
} else {
parentElem = parentElem.parentElement;
}
}
};
})();
lsg/toDiv/util/handleEvent/handle.ls
(function(){
return function(onEvent, e){
var elem;
if (!onEvent) {
return;
}
elem = inc("findEventLsgObjectElement/find")(e);
return onEvent(elem, e);
};
})();
lsg/toJS/toJS.ls
(function(){
return function(lsgString){
var jsgString, error, jsg;
try {
jsgString = Livescript.compile(lsgString, {
bare: true
}).replace('// Generated by LiveScript 1.4.0\n', '');
} catch (e$) {
error = e$;
setTimeout(function(){
return helpers.errorHandler(error, '/../lsg2/lsg/toJS/toJS/');
});
}
try {
jsg = eval(jsgString);
} catch (e$) {
error = e$;
setTimeout(function(){
return helpers.errorHandler(error, '/../lsg2/lsg/toJS/toJS/');
});
}
if (!jsg) {
return;
}
if (!_.isArray(jsg.objects)) {
jsg.objects = [jsg.objects];
}
return jsg;
};
})();
lsg/toSVG/defs/defs.ls
(function(){
return function(){
return inc('/lib/util/makeSvg/makeSvg')('defs').html(inc("filterDropShadow/filter")());
};
})();
lsg/toSVG/defs/filterDropShadow/filter.ls
(function(){
return function(){
return "\n \n ";
};
})();
lsg/toSVG/objects/avatar.ls
(function(){
return function(o){
var addBackground, svg;
addBackground = function(o, svg){
var w, h, rect;
if (o.background) {
w = svg.attr('width');
h = svg.attr('height');
rect = include('rect')({
x: 0,
y: 0,
w: w,
h: h,
color: o.background,
lineColor: o.backgroundLineColor,
lineSize: o.backgroundLineSize
});
svg = svg.prepend(rect);
return svg;
} else {
return svg;
}
};
svg = LSG2.toSVG(Avatar.toLSG(Avatar.validate(o.avatar).avatar));
svg = addBackground(o, svg);
return include('/lib/util/prepareSvg/prepareSvg')(o, svg);
};
})();
lsg/toSVG/objects/image.ls
(function(){
return function(o, imageBase64Texts){
var isSafariLt13, url, ref$, w, h, rx, ry, sx, sy, tx, ty, transform, svg;
isSafariLt13 = include("/lib/util/isSafariLt13/isSafariLt13")();
url = ((ref$ = _.find(imageBase64Texts, {
id: o.image
})) != null ? ref$.base64 : void 8) || "https://images.anton.app/image/small?imageId=" + o.image;
w = o.w || o.h;
h = o.h || o.w;
rx = w / 2;
ry = h / 2;
sx = o.flipX ? -1 : 1;
sy = o.flipY ? -1 : 1;
tx = o.flipX
? o.x + w
: o.x;
ty = o.flipY
? o.y + h
: o.y;
transform = "translate(" + tx + " " + ty + ")";
transform += " scale(" + sx + " " + sy + ")";
transform += " rotate(" + (o.rotate || 0) + " " + rx + " " + ry + ")";
svg = include('/lib/util/makeSvg/makeSvg')('image', {
'class': o['class'],
'href': url,
'opacity': o.opacity || 1,
'width': w,
'height': h,
'rx': o.rounded || 0,
'ry': o.rounded || 0,
'transform': transform,
'lsg:x': o.x,
'lsg:y': o.y,
'lsg:w': o.w || o.h,
'lsg:h': o.h || o.w,
'xlink:href': isSafariLt13 ? url : void 8,
'preserveAspectRatio': o.align === "topLeft"
? "xMinYMin " + (o.crop ? "slice" : "meet")
: o.align === "top"
? "xMidYMin " + (o.crop ? "slice" : "meet")
: o.align === "topRight"
? "xMaxYMin " + (o.crop ? "slice" : "meet")
: o.align === "right"
? "xMaxYMid " + (o.crop ? "slice" : "meet")
: o.align === "bottomRight"
? "xMaxYMax " + (o.crop ? "slice" : "meet")
: o.align === "bottom"
? "xMidYMax " + (o.crop ? "slice" : "meet")
: o.align === "bottomLeft"
? "xMinYMax " + (o.crop ? "slice" : "meet")
: o.align === "left"
? "xMinYMid " + (o.crop ? "slice" : "meet")
: "xMidYMid " + (o.crop ? "slice" : "meet")
});
return svg;
};
})();
lsg/toSVG/objects/line.ls
(function(){
return function(o, defs){
var markerWidth, lineSize, x, y, w, h, tx, ty, rx, ry, sx, sy, transform, strokeDasharray, minX, minY, x1, y1, x2, y2, dx, dy, l, markerSize, uid, svg;
markerWidth = 4;
lineSize = o.lineSize || 5;
x = Math.min(o.x1, o.x2);
y = Math.min(o.y1, o.y2);
w = Math.max(o.x1, o.x2) - x;
h = Math.max(o.y1, o.y2) - y;
tx = o.flipX ? x + w : x;
ty = o.flipY ? y + h : y;
rx = w / 2;
ry = h / 2;
sx = o.flipX ? -1 : 1;
sy = o.flipY ? -1 : 1;
transform = "translate(" + tx + " " + ty + ")";
transform += " scale(" + sx + " " + sy + ")";
transform += " rotate(" + (o.rotate || 0) + " " + rx + " " + ry + ")";
strokeDasharray = o.lineDash === true
? "10, 10"
: o.lineDash ? o.lineDash + ", " + o.lineDash : void 8;
minX = Math.min(o.x1, o.x2);
minY = Math.min(o.y1, o.y2);
w = Math.max(o.x1, o.x2) - minX;
h = Math.max(o.y1, o.y2) - minY;
x1 = o.x1 - minX;
y1 = o.y1 - minY;
x2 = o.x2 - minX;
y2 = o.y2 - minY;
dx = x2 - x1;
dy = y2 - y1;
l = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
dx /= l;
dy /= l;
markerSize = (markerWidth - 0.5) * lineSize;
uid = helpers.guid(4);
if (o.arrowEnd && defs) {
x2 -= dx * markerSize;
y2 -= dy * markerSize;
defs.append(include('/lib/util/makeSvg/makeSvg')('marker', {
id: "arrowEnd" + uid,
orient: 'auto',
markerWidth: markerWidth,
markerHeight: markerWidth,
refX: 0.5,
refY: markerWidth / 2
}).append(include('/lib/util/makeSvg/makeSvg')('path', {
d: "M0,0 L0," + markerWidth + " L" + markerWidth + "," + markerWidth / 2 + " z",
fill: o.lineColor
})));
}
if (o.arrowStart && defs) {
x1 += dx * markerSize;
y1 += dy * markerSize;
defs.append(include('/lib/util/makeSvg/makeSvg')('marker', {
id: "arrowStart" + uid,
orient: 'auto',
markerWidth: markerWidth,
markerHeight: markerWidth,
refX: markerWidth - 0.5,
refY: markerWidth / 2
}).append(include('/lib/util/makeSvg/makeSvg')('path', {
d: "M0,0 L0," + markerWidth + " L" + markerWidth + "," + markerWidth / 2 + " z",
transform: 'rotate(180 2 2)',
fill: o.lineColor
})));
}
svg = include('/lib/util/makeSvg/makeSvg')('line', {
'class': o['class'],
'x1': x1,
'y1': y1,
'x2': x2,
'y2': y2,
'stroke': o.lineColor,
'stroke-width': lineSize,
'stroke-opacity': o.opacity,
'stroke-dasharray': strokeDasharray,
'stroke-dashoffset': o.lineDashOffset,
'transform': transform,
'lsg:x': x,
'lsg:y': y,
'lsg:w': w,
'lsg:h': h,
'marker-end': o.arrowEnd ? 'url(#arrowEnd' + uid + ')' : void 8,
'marker-start': o.arrowStart ? 'url(#arrowStart' + uid + ')' : void 8
});
return svg;
};
})();
lsg/toSVG/objects/lsg.ls
(function(){
return function(o, svgTexts, lsgTexts, imageBase64Texts, renderLanguage){
var inheritBackground, lsg, svg, ref$, renderer, o2, ref1$;
inheritBackground = function(o, lsg){
var that;
if (that = o.background) {
lsg.background = that;
}
if (that = o.backgroundLineColor) {
lsg.backgroundLineColor = that;
}
if (that = o.backgroundLineSize) {
return lsg.backgroundLineSize = that;
}
};
if (o.lsg && _.isObject(o.lsg)) {
lsg = o.lsg;
inheritBackground(o, lsg);
svg = LSG2.toSVG(o.lsg, svgTexts, lsgTexts, imageBase64Texts);
} else if (o.lsg && ((ref$ = o.lsg) != null ? ref$.slice(0, 4) : void 8) === '/../' && _.includes(o.lsg, '.lsr')) {
renderer = include(o.lsg);
o2 = _.cloneDeep(o);
o2.renderLanguage = renderLanguage;
lsg = renderer.render
? renderer.render(o2)
: renderer(o2);
inheritBackground(o, lsg);
svg = LSG2.toSVG(lsg, svgTexts, lsgTexts, imageBase64Texts);
} else if (o.lsg && ((ref1$ = o.lsg) != null ? ref1$.slice(0, 4) : void 8) === '/../') {
lsg = (lsgTexts != null ? lsgTexts[o.lsg] : void 8) || include(o.lsg);
inheritBackground(o, lsg);
svg = LSG2.toSVG(lsg, svgTexts, lsgTexts, imageBase64Texts);
} else {
helpers.errorHandler("lsg not found: " + o.lsg, '/../lsg2/lsg/toSVG/objects/lsg.ls');
return;
}
svg = include('/lib/util/prepareSvg/prepareSvg')(o, svg);
return svg;
};
})();
lsg/toSVG/objects/oval.ls
(function(){
return function(o){
var w, h, tx, ty, cx, rx, cy, ry, sx, sy, strokeDasharray, transform, svg;
w = o.w || o.h;
h = o.h || o.w;
if (o.lineSize) {
tx = o.flipX
? o.x + w - o.lineSize / 2
: o.x + o.lineSize / 2;
} else {
tx = o.flipX
? o.x + w
: o.x;
}
if (o.lineSize) {
ty = o.flipY
? o.y + h - o.lineSize / 2
: o.y + o.lineSize / 2;
} else {
ty = o.flipY
? o.y + h
: o.y;
}
cx = rx = o.lineSize
? w / 2 - o.lineSize / 2
: w / 2;
cy = ry = o.lineSize
? h / 2 - o.lineSize / 2
: h / 2;
sx = o.flipX ? -1 : 1;
sy = o.flipY ? -1 : 1;
strokeDasharray = o.lineDash === true
? "10, 10"
: o.lineDash ? o.lineDash + ", " + o.lineDash : void 8;
transform = "translate(" + tx + " " + ty + ")";
transform += " scale(" + sx + " " + sy + ")";
transform += " rotate(" + (o.rotate || 0) + " " + rx + " " + ry + ")";
svg = include('/lib/util/makeSvg/makeSvg')('ellipse', {
'class': o['class'],
'cx': cx,
'cy': cy,
'rx': rx,
'ry': ry,
'fill': o.color || "transparent",
'stroke': o.lineColor,
'stroke-width': o.lineSize || 0,
'stroke-dasharray': strokeDasharray,
'stroke-dashoffset': o.lineDashOffset,
'opacity': o.opacity,
'transform': transform,
'lsg:x': o.x,
'lsg:y': o.y,
'lsg:w': w,
'lsg:h': h
});
return svg;
};
})();
lsg/toSVG/objects/path.ls
(function(){
return function(o, defs){
var markerWidth, path, x, y, wo, ho, r, w, h, wr, hr, sx, sy, tx, ty, rx, ry, strokeDasharray, transform, lineSize, uid, svg;
markerWidth = 4;
path = include('/lib/util/pathApi/pathApi')(o.path);
x = o.x;
y = o.y;
wo = path.w() || 1;
ho = path.h() || 1;
r = wo / ho;
w = o.w
? o.w
: o.h ? o.h * r : wo;
h = o.h
? o.h
: o.w ? o.w / r : ho;
wr = w / wo;
hr = h / ho;
sx = o.flipX
? -1 * wr
: 1 * wr;
sy = o.flipY
? -1 * hr
: 1 * hr;
tx = (o.flipX ? x + w : x) || 0;
ty = (o.flipY ? y + h : y) || 0;
rx = wo / 2;
ry = ho / 2;
strokeDasharray = o.lineDash === true
? "10, 10"
: o.lineDash ? o.lineDash + ", " + o.lineDash : void 8;
transform = "translate(" + tx + " " + ty + ")";
transform += " scale(" + sx + " " + sy + ")";
transform += " rotate(" + (o.rotate || 0) + " " + rx + " " + ry + ")";
lineSize = o.lineSize / Math.max(Math.abs(sx), Math.abs(sy));
uid = helpers.guid(4);
if (o.arrowEnd && defs) {
defs.append(include('/lib/util/makeSvg/makeSvg')('marker', {
id: "arrowEnd" + uid,
orient: 'auto',
markerWidth: markerWidth,
markerHeight: markerWidth,
refX: 0.5,
refY: markerWidth / 2
}).append(include('/lib/util/makeSvg/makeSvg')('path', {
d: "M0,0 L0," + markerWidth + " L" + markerWidth + "," + markerWidth / 2 + " z",
fill: o.lineColor
})));
}
if (o.arrowStart && defs) {
defs.append(include('/lib/util/makeSvg/makeSvg')('marker', {
id: "arrowStart" + uid,
orient: 'auto',
markerWidth: markerWidth,
markerHeight: markerWidth,
refX: markerWidth - 0.5,
refY: markerWidth / 2
}).append(include('/lib/util/makeSvg/makeSvg')('path', {
d: "M0,0 L0," + markerWidth + " L" + markerWidth + "," + markerWidth / 2 + " z",
transform: 'rotate(180 2 2)',
fill: o.lineColor
})));
}
svg = include('/lib/util/makeSvg/makeSvg')('path', {
'class': o['class'],
'd': o.path,
'fill': o.color || 'transparent',
'stroke': o.lineColor,
'stroke-width': lineSize,
'stroke-opacity': o.opacity,
'stroke-dasharray': strokeDasharray,
'stroke-dashoffset': o.lineDashOffset,
'opacity': o.opacity,
'transform': transform,
'lsg:x': o.x,
'lsg:y': o.y,
'lsg:w': w,
'lsg:h': h,
'marker-end': o.arrowEnd ? 'url(#arrowEnd' + uid + ')' : void 8,
'marker-start': o.arrowStart ? 'url(#arrowStart' + uid + ')' : void 8
});
return svg;
};
})();
lsg/toSVG/objects/rect.ls
(function(){
return function(o){
var w, h, tx, ty, rx, ry, sx, sy, wl, hl, transform, strokeDasharray, svg;
w = o.w || o.h;
h = o.h || o.w;
if (o.lineSize) {
tx = o.flipX
? o.x + w - o.lineSize / 2
: o.x + o.lineSize / 2;
} else {
tx = o.flipX
? o.x + w
: o.x;
}
if (o.lineSize) {
ty = o.flipY
? o.y + h - o.lineSize / 2
: o.y + o.lineSize / 2;
} else {
ty = o.flipY
? o.y + h
: o.y;
}
rx = o.lineSize
? w / 2 - o.lineSize / 2
: w / 2;
ry = o.lineSize
? h / 2 - o.lineSize / 2
: h / 2;
sx = o.flipX ? -1 : 1;
sy = o.flipY ? -1 : 1;
if (o.lineSize) {
wl = w - o.lineSize;
hl = h - o.lineSize;
}
transform = "translate(" + tx + " " + ty + ")";
transform += " scale(" + sx + " " + sy + ")";
transform += " rotate(" + (o.rotate || 0) + " " + rx + " " + ry + ")";
strokeDasharray = o.lineDash === true
? "10, 10"
: o.lineDash ? o.lineDash + ", " + o.lineDash : void 8;
svg = include('/lib/util/makeSvg/makeSvg')('rect', {
'class': o['class'],
'opacity': o.opacity,
'width': wl || o.w,
'height': hl || o.h,
'fill': o.color || "transparent",
'stroke': o.lineColor,
'stroke-width': o.lineSize || 0,
'stroke-dasharray': strokeDasharray,
'stroke-dashoffset': o.lineDashOffset,
'rx': o.rounded || 0,
'ry': o.rounded || 0,
'transform': transform,
'lsg:x': o.x,
'lsg:y': o.y,
'lsg:w': w,
'lsg:h': h
});
return svg;
};
})();
lsg/toSVG/objects/svg.ls
(function(){
return function(o, svgTexts){
var addBackground, svg, ref$, svgPath, ref1$, path, ref2$, border, borderType, lineSize, filter;
addBackground = function(o, svg){
var w, h, rect;
if (o.background || o.backgroundLineSize) {
w = svg.attr('lsg:w');
h = svg.attr('lsg:h');
rect = include('rect')({
x: 0,
y: 0,
w: w,
h: h,
color: o.background,
lineColor: o.backgroundLineColor,
lineSize: o.backgroundLineSize
});
return svg.prepend(rect);
}
};
if (_.includes(o.svg, '')) {
svg = o.svg;
} else if (((ref$ = o.svg) != null ? ref$.slice(0, 4) : void 8) === '/../' && o.includeSvg === true) {
svgPath = o.svg;
svg = include(svgPath);
} else if (((ref1$ = o.svg) != null ? ref1$.slice(0, 4) : void 8) === '/../') {
path = o.svg;
svg = _.isArray(svgTexts)
? (ref2$ = _.find(svgTexts, {
path: path
})) != null ? ref2$.svgText : void 8
: LSG2.util.remoteSvgCache.svg(path);
} else {
helpers.errorHandler("svg not found: " + o.svg, '/../lsg2/lsg/toSVG/objects/svg.ls');
return;
}
border = o.lineSize && o.lineColor ? (borderType = o.lineDash ? "dashed" : "solid", lineSize = _.min([o.lineSize, o.w / 2, o.h / 2]), lineSize + "px " + borderType + " " + o.lineColor) : "";
filter = o.shadow ? "drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3))" : "";
svg = Svg({
svg: svg
}).firstChild;
svg = include('/lib/util/prepareSvg/prepareSvg')(o, svg);
addBackground(o, svg);
return svg;
};
})();
lsg/toSVG/objects/text.ls
(function(){
return function(o){
var textAnchor, align, lineHeight, text, lines, t, svg, w, h, sx, sy, ry, tx, ty, rx, transform;
textAnchor = (function(){
switch (o.align) {
case 'center':
return align = 'middle';
case 'right':
return align = 'end';
default:
return align = 'start';
}
}());
lineHeight = o.lineHeight ? o.lineHeight / o.size : 1;
text = o.text + '';
text = text.replace(/ /g, '\u00a0');
lines = text.split('\n');
t = include('/lib/util/textSize/textSize')(o, text);
svg = t.element;
w = t.w;
h = t.h;
svg.attr({
'lsg:x': o.x,
'lsg:y': o.y,
'lsg:w': w,
'lsg:h': h
});
sx = o.flipX ? -1 : 1;
sy = o.flipY ? -1 : 1;
ry = h / 2 - o.size;
if (textAnchor === 'middle') {
svg.attr({
'lsg:x': o.x - w / 2
});
tx = o.x;
ty = o.flipY
? o.y + (lines.length - 2) * (o.lineHeight || o.size) + o.size
: o.y + o.size;
rx = 0;
} else if (textAnchor === 'start') {
svg.attr({
'lsg:x': o.x
});
tx = o.flipX
? o.x + w
: o.x;
ty = o.y + o.size;
rx = w / 2;
} else if (textAnchor === 'end') {
svg.attr({
'lsg:x': o.x - w
});
tx = o.flipX
? o.x - w
: o.x;
ty = o.y + o.size;
rx = -w / 2;
}
transform = "translate(" + tx + " " + ty + ")";
transform += " scale(" + sx + " " + sy + ")";
transform += " rotate(" + (o.rotate || 0) + " " + rx + " " + ry + ")";
svg.attr({
transform: transform
});
return svg;
};
})();
lsg/toSVG/toSVG.ls
(function(){
return function(o, svgTexts, lsgTexts, imageBase64Texts){
var isSafariLt13, width, height, x, y, svg, defs, objects, i$, ref$, len$, i, object, el;
isSafariLt13 = include("/lib/util/isSafariLt13/isSafariLt13")();
width = o.backgroundLineSize
? o.width - o.backgroundLineSize / 2
: o.width;
height = o.backgroundLineSize
? o.height - o.backgroundLineSize / 2
: o.height;
x = o.backgroundLineSize ? o.backgroundLineSize / 4 : 0;
y = o.backgroundLineSize ? o.backgroundLineSize / 4 : 0;
svg = include('/lib/util/makeSvg/makeSvg')('svg', {
'width': o.width,
'height': o.height,
'viewBox': "0 0 " + o.width + " " + o.height,
'preserve-aspect-ratio': 'none',
'overflow': 'hidden',
'xmlns:lsg': "http://anton.com/lsg",
'xmlns:xlink': isSafariLt13 ? "http://www.w3.org/1999/xlink" : void 8
}).css({
webkitTextSizeAdjust: "100%"
}).append(defs = include('defs/defs')(), include('/lib/util/makeSvg/makeSvg')('rect', {
'width': width,
'height': height,
'x': x,
'y': y,
'class': o['class'],
'fill': o.background || 'transparent',
'stroke': o.backgroundLineColor,
'stroke-width': o.backgroundLineSize || 0
}));
objects = o.objects;
if (objects) {
for (i$ = 0, len$ = (ref$ = _.ensureArray(objects)).length; i$ < len$; ++i$) {
i = i$;
object = ref$[i$];
el = (fn$());
if (object.hidden) {
el.attr({
visibility: "hidden"
});
}
if (object.shadow) {
el.attr({
filter: 'URL(#dropShadow)'
});
}
svg.append(el);
}
}
include("/lib/util/resolveOverrides/resolveOverrides")(o, svg);
if (isSafariLt13) {
return Svg({
svg: svg.outerHTML
}).svgElement;
} else {
return svg;
}
function fn$(){
switch (object.type) {
case 'line':
return include('objects/line')(object, defs);
case 'path':
return include('objects/path')(object, defs);
case 'oval':
return include('objects/oval')(object);
case 'rect':
return include('objects/rect')(object);
case 'text':
return include('objects/text')(object);
case 'svg':
return include('objects/svg')(object, svgTexts);
case 'lsg':
return include('objects/lsg')(object, svgTexts, lsgTexts, imageBase64Texts, o.renderLanguage);
case 'avatar':
return include('objects/avatar')(object);
case 'image':
return include('objects/image')(object, imageBase64Texts);
default:
return helpers.errorHandler("unknown LSG object type: " + object.type, '/../lsg2/lsg/toSVG/toSVG.ls');
}
}
};
})();
lsg3Div/createObjects/_shared/addClassAndPointerEvents/add.ls
(function(){
return function(el, o){
var c;
c = o['class'];
if (!c) {
return;
}
el.addClass(c);
if (c !== "ignore") {
return el.css({
pointerEvents: "auto"
});
}
};
})();
lsg3Div/createObjects/_shared/layerDiv/div.ls
(function(){
return function(o){
var x, y, rotate, ref$, opacity, scaleX, scaleY, filter, visibility;
x = o.x;
y = o.y;
rotate = (ref$ = o.rotate) != null ? ref$ : 0;
opacity = (ref$ = o.opacity) != null ? ref$ : 1;
scaleX = 1;
scaleY = 1;
if (o.flipX) {
rotate = -rotate;
scaleX = -1;
}
if (o.flipY) {
rotate = -rotate;
scaleY = -1;
}
if (o.shadow) {
filter = "drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3))";
}
if (o.hidden) {
visibility = "hidden";
}
return Div({
display: "flex",
position: "absolute",
top: 0,
left: 0,
opacity: opacity,
filter: filter,
visibility: visibility,
pointerEvents: "none",
transform: "translate(" + x + "px, " + y + "px) rotate(" + rotate + "deg)scale(" + scaleX + ", " + scaleY + ")"
});
};
})();
lsg3Div/createObjects/_shared/overwriteSvgAttributes/overwrite.ls
(function(){
return function(el, o){
var setAttr, that;
setAttr = inc("setAttr/set");
if (that = o.color) {
setAttr({
element: el,
attribute: "fill",
defaultClass: "color1",
values: that
});
}
if (that = o.lineColor) {
setAttr({
element: el,
attribute: "stroke",
defaultClass: "lineColor1",
values: that
});
}
if (that = o.lineSize) {
setAttr({
element: el,
attribute: "stroke-width",
defaultClass: "lineSize1",
values: that
});
}
if (that = o.lineDash) {
return setAttr({
element: el,
attribute: "stroke-dasharray",
defaultClass: "lineDash1",
values: that,
convertValue: function(v){
if (v === true) {
return "10, 10";
} else if (v > -1) {
return v + ", " + v;
}
}
});
}
};
})();
lsg3Div/createObjects/_shared/overwriteSvgAttributes/setAttr/set.ls
(function(){
return function(p){
var values, id, v, lresult$, p2, v2, ref$, i$, len$, el, lresult1$, ref1$, j$, len1$, el2, results$ = [];
if (_.isObject(p.values)) {
values = p.values;
} else {
values = {};
values[p.defaultClass] = p.values;
}
for (id in values) {
v = values[id];
lresult$ = [];
if (_.isObject(v)) {
p2 = _.clone(p);
p2.values = v;
lresult$.push(inc(THISFILE)(p2));
} else {
v2 = (ref$ = typeof p.convertValue == 'function' ? p.convertValue(v) : void 8) != null ? ref$ : v;
for (i$ = 0, len$ = (ref$ = p.element.findAll("." + id)).length; i$ < len$; ++i$) {
el = ref$[i$];
lresult1$ = [];
el.setAttribute(p.attribute, v2);
if ((ref1$ = el.tagName) === "svg" || ref1$ === "g") {
for (j$ = 0, len1$ = (ref1$ = el.findAll("." + p.defaultClass)).length; j$ < len1$; ++j$) {
el2 = ref1$[j$];
lresult1$.push(el2.setAttribute(p.attribute, v2));
}
}
lresult$.push(lresult1$);
}
}
results$.push(lresult$);
}
return results$;
};
})();
lsg3Div/createObjects/_shared/svg/svg.ls
(function(){
return function(p){
var ns, svg, w, h;
ns = "http://www.w3.org/2000/svg";
svg = document.createElementNS(ns, "svg").attr({
width: w = p.width,
height: h = p.height,
viewBox: "0 0 " + w + " " + h,
overflow: "visible"
});
svg.createElement = function(s){
return document.createElementNS(ns, s);
};
return svg;
};
})();
lsg3Div/createObjects/create.ls
(function(){
return function(l){
var o, f;
l.contentDiv.append((function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = _.ensureArray(l.lsgData.objects)).length; i$ < len$; ++i$) {
o = ref$[i$];
f = inc(o.type + "/" + o.type);
results$.push(typeof f == 'function' ? f(o, l) : void 8);
}
return results$;
}()));
return inc("_shared/overwriteSvgAttributes/overwrite")(l.contentDiv, l.lsgData);
};
})();
lsg3Div/createObjects/image/calcAlignAndJustify/calc.ls
(function(){
return function(o){
var align, ref$, has;
align = (ref$ = o.align) != null ? ref$ : "centerMiddle";
has = function(s){
return _.includes(align.toLowerCase(), s);
};
return {
align: o.align,
alignItems: has("top")
? "flex-start"
: has("bottom") ? "flex-end" : "center",
justifyContent: has("left")
? "flex-start"
: has("right") ? "flex-end" : "center"
};
};
})();
lsg3Div/createObjects/image/getImage/get.ls
(function(){
return function(o, l){
var id, images, image;
id = o.image;
images = l.mediaParams.images;
image = _.find(images, {
id: id
});
return image;
};
})();
lsg3Div/createObjects/image/image.ls
(function(){
return function(o, l){
var image, w, h, aj, div;
image = inc("getImage/get")(o, l);
w = o.w;
h = o.h || o.w;
aj = inc("calcAlignAndJustify/calc")(o);
div = inc("../_shared/layerDiv/div")(o).css({
display: "flex",
width: w + "px",
height: h + "px",
overflow: "hidden",
alignItems: aj.alignItems,
justifyContent: aj.justifyContent
}).html(image = Img({
flex: "0 0 auto"
}).attr({
src: image.base64,
preserveAspectRatio: "none",
draggable: "false"
}).bind("load", function(){
return inc("setImageSize/set")(w, h, o, this);
}));
inc("../_shared/addClassAndPointerEvents/add")(image, o);
return div;
};
})();
lsg3Div/createObjects/image/setImageSize/set.ls
(function(){
return function(w, h, o, image){
var wN, hN, scaleX, scaleY, scale;
wN = image.naturalWidth;
hN = image.naturalHeight;
scaleX = w / wN;
scaleY = h / hN;
scale = _.isNaN(scaleX)
? scaleY
: _.isNaN(scaleY)
? scaleX
: o.crop
? Math.max(scaleX, scaleY)
: Math.min(scaleX, scaleY);
return image.css({
width: wN * scale + "px",
height: hN * scale + "px"
});
};
})();
lsg3Div/createObjects/line/calcPoints/calc.ls
(function(){
var cos, sin;
cos = function(deg){
return Math.cos(deg * Math.PI / 180);
};
sin = function(deg){
return Math.sin(deg * Math.PI / 180);
};
return function(n, o, markerSize){
var r, startMarkerLength, endMarkerLength, l1, l2;
r = n.rotate;
startMarkerLength = o.arrowStart ? (markerSize - 1) * o.lineSize : 0;
endMarkerLength = o.arrowEnd ? (markerSize - 1) * o.lineSize : 0;
l1 = startMarkerLength;
l2 = n.length - endMarkerLength;
return {
x1: _.round(l1 * cos(r), 2),
y1: _.round(l1 * sin(r), 2),
x2: _.round(l2 * cos(r), 2),
y2: _.round(l2 * sin(r), 2)
};
};
})();
lsg3Div/createObjects/line/line.ls
(function(){
return function(o){
var l, markerSize, n, points, o2, div;
l = o.lineSize || 0;
markerSize = l === 1
? 6
: l === 2 ? 5 : 4;
n = inc("normalizeToLengthAngle/normalize")(o);
points = inc("calcPoints/calc")(n, o, markerSize);
o2 = {
x: n.x,
y: n.y,
rotate: 0,
opacity: o.opacity
};
return div = inc("../_shared/layerDiv/div")(o2).html(inc("svgLine/svg")(points, o, markerSize));
};
})();
lsg3Div/createObjects/line/normalizeToLengthAngle/calcLengthAndAngle/calc.ls
(function(){
return function(points){
var start, end, w, h, length, hypo, angle;
start = points.start;
end = points.end;
w = end.x - start.x;
h = end.y - start.y;
length = Math.hypot(h, w);
hypo = Math.hypot(h, w);
angle = Math.asin(h / hypo);
angle = angle / (Math.PI / 180);
if (w < 0) {
angle = 180 - angle;
w = -w;
}
return {
angle: _.round(angle, 2),
length: length
};
};
})();
lsg3Div/createObjects/line/normalizeToLengthAngle/fixFlip/fix.ls
(function(){
return function(points, o){
var points2;
if (!o.flipX && !o.flipY) {
return points;
}
points2 = _.cloneDeep(points);
if (o.flipX) {
points2.start.x = points.end.x;
points2.end.x = points.start.x;
}
if (o.flipY) {
points2.start.y = points.end.y;
points2.end.y = points.start.y;
}
return points2;
};
})();
lsg3Div/createObjects/line/normalizeToLengthAngle/normalize.ls
(function(){
return function(o){
var xCenter, yCenter, rotate, ref$, r, points, la, n;
xCenter = o.x1 + (o.x2 - o.x1) / 2;
yCenter = o.y1 + (o.y2 - o.y1) / 2;
rotate = (ref$ = o.rotate) != null ? ref$ : 0;
r = inc("rotatePointWithOrigin/rotate");
points = {
start: r(o.x1, o.y1, rotate, xCenter, yCenter),
end: r(o.x2, o.y2, rotate, xCenter, yCenter)
};
points = inc("fixFlip/fix")(points, o);
la = inc("calcLengthAndAngle/calc")(points);
return n = {
x: points.start.x,
y: points.start.y,
length: la.length,
rotate: la.angle
};
};
})();
lsg3Div/createObjects/line/normalizeToLengthAngle/rotatePointWithOrigin/rotate.ls
(function(){
var cos, sin;
cos = function(deg){
return Math.cos(deg * Math.PI / 180);
};
sin = function(deg){
return Math.sin(deg * Math.PI / 180);
};
return function(x, y, angle, originX, originY){
var x2, y2, deltaX, deltaY, p;
x2 = cos(angle) * (x - originX) - sin(angle) * (y - originY) + originX;
y2 = sin(angle) * (x - originX) + cos(angle) * (y - originY) + originY;
deltaX = x2 - x;
deltaY = y2 - y;
return p = {
x: x + deltaX,
y: y + deltaY
};
};
})();
lsg3Div/createObjects/line/svgLine/markerArrow/marker.ls
(function(){
var markerId;
markerId = 0;
return function(type, svg, o, markerSize){
var id, s, m;
if (!o[type]) {
return;
}
id = type + markerId++;
s = markerSize;
m = svg.createElement("marker").attr({
id: id,
orient: "auto",
markerWidth: s,
markerHeight: s,
refY: s / 2,
refX: type === "arrowStart"
? s - 1
: type === "arrowEnd" ? 1 : 0
}).append(svg.createElement("path").attr({
d: "M0,0 L0," + s + " L" + s + "," + s / 2 + " z",
fill: o.lineColor,
transform: type === "arrowStart" ? "rotate(180 " + s / 2 + " " + s / 2 + ")" : void 8
}));
m.markerUrl = 'url(#' + id + ')';
return m;
};
})();
lsg3Div/createObjects/line/svgLine/svg.ls
(function(){
return function(points, o, markerSize){
var lineColor, lineSize, lineDash, m, svg, mStart, mEnd, line;
lineColor = o.lineColor || "transparent";
lineSize = o.lineSize || 0;
lineDash = o.lineDash === true
? "10, 10"
: o.lineDash ? o.lineDash + ", " + o.lineDash : void 8;
m = function(t){
return inc("markerArrow/marker")(t, svg, o, markerSize);
};
svg = inc("../../_shared/svg/svg")({
width: 100,
height: 100
});
svg.append(svg.createElement("defs").html(mStart = m("arrowStart"), mEnd = m("arrowEnd")), line = svg.createElement("line").attr({
x1: points.x1,
y1: points.y1,
x2: points.x2,
y2: points.y2,
stroke: lineColor,
"stroke-width": lineSize,
"stroke-dasharray": lineDash,
"marker-start": mStart != null ? mStart.markerUrl : void 8,
"marker-end": mEnd != null ? mEnd.markerUrl : void 8
}));
inc("../../_shared/addClassAndPointerEvents/add")(line, o);
return svg;
};
})();
lsg3Div/createObjects/lsg/calcSettings/calc.ls
(function(){
return function(o, childLsgData){
var r, w, h;
r = childLsgData.height / childLsgData.width;
w = o.w
? o.w
: o.h / r;
h = o.h
? o.h
: o.w * r;
return {
w: w,
h: h,
scaleX: w / childLsgData.width,
scaleY: h / childLsgData.height
};
};
})();
lsg3Div/createObjects/lsg/getChildLsgData/get.ls
(function(){
return function(l, o){
var f, o2, lsg;
if (_.isPlainObject(o.lsg)) {
return o.lsg;
}
if (_.endsWith(o.lsg, ".lsr")) {
f = inc(o.lsg);
o2 = _.cloneDeep(o);
o2.renderLanguage = l.lsgData.renderLanguage;
return (typeof f.render == 'function' ? f.render(o2) : void 8) || f(o2);
}
if (_.endsWith(o.lsg, ".lsg")) {
lsg = l.mediaParams.lsgs[o.lsg];
return _.cloneDeep(lsg);
}
};
})();
lsg3Div/createObjects/lsg/inheritIgnoreClass/inherit.ls
(function(){
return function(childLsgData, o){
var objects, i$, len$, classes, ref$, results$ = [];
if (!_.includes(o['class'], "ignore")) {
return;
}
objects = _.ensureArray(childLsgData.objects);
for (i$ = 0, len$ = objects.length; i$ < len$; ++i$) {
o = objects[i$];
classes = ((ref$ = o['class']) != null ? ref$.split(" ") : void 8) || [];
classes.push("ignore");
results$.push(o['class'] = classes.join(" "));
}
return results$;
};
})();
lsg3Div/createObjects/lsg/inheritProperties/inherit.ls
(function(){
return function(childLsgData, o){
var props, i$, len$, s, that, results$ = [];
props = ["background", "backgroundLineColor", "backgroundLineSize", "color", "lineColor", "lineSize", "lineDash"];
for (i$ = 0, len$ = props.length; i$ < len$; ++i$) {
s = props[i$];
if (that = o[s]) {
results$.push(childLsgData[s] = that);
}
}
return results$;
};
})();
lsg3Div/createObjects/lsg/lsg.ls
(function(){
return function(o, l){
var childLsgData, s, div, lsgDiv;
childLsgData = inc("getChildLsgData/get")(l, o);
inc("inheritProperties/inherit")(childLsgData, o);
inc("inheritIgnoreClass/inherit")(childLsgData, o);
s = inc("calcSettings/calc")(o, childLsgData);
div = inc("../_shared/layerDiv/div")(o).css({
display: "flex",
width: s.w + "px",
height: s.h + "px",
overflow: "hidden"
}).html(lsgDiv = inc("../../div")({
lsg: childLsgData,
mediaParams: l.mediaParams,
hideDebugTag: l.params.hideDebugTag
}).css({
flex: "0 0 auto",
transform: "scale(" + s.scaleX + ", " + s.scaleY + ")"
}));
inc("../_shared/addClassAndPointerEvents/add")(lsgDiv, o);
return div;
};
})();
lsg3Div/createObjects/oval/oval.ls
(function(){
return function(o){
var o2;
o2 = _.clone(o);
o2.rounded = "50%";
return inc("../rect/rect")(o2);
};
})();
lsg3Div/createObjects/path/calcScale/calc.ls
(function(){
return function(o, svgDetails){
var scaleX, scaleY;
if (o.w && o.h) {
scaleX = o.w / svgDetails.width;
scaleY = o.h / svgDetails.height;
} else if (o.w) {
scaleX = o.w / svgDetails.width;
scaleY = scaleX;
} else if (o.h) {
scaleY = o.h / svgDetails.height;
scaleX = scaleY;
} else {
scaleX = 1;
scaleY = 1;
}
return {
x: scaleX,
y: scaleY
};
};
})();
lsg3Div/createObjects/path/generateTrimmedSvgFromPath/generate.ls
(function(){
var cache;
cache = {};
return function(pathString){
var that, div, svgEl, translateGroup, pathEl, b, svg, svgWithViewBox;
if (that = cache[pathString]) {
return that;
}
div = Div().html("");
svgEl = div.findFirst("svg");
translateGroup = div.findFirst('#translateGroup');
pathEl = div.findFirst("path");
b = inc("/lib/util/svgPathHelper/helper")(pathString).getBBox();
translateGroup.attr({
transform: "translate(" + (-b.x) + ", " + (-b.y) + ")"
});
svgEl.attr({
width: b.width,
height: b.height
});
svg = svgEl.outerHTML;
svgEl.attr({
viewbox: "0 0 " + b.width + " " + b.height
});
svgWithViewBox = svgEl.outerHTML;
return cache[pathString] = {
svg: svg,
svgWithViewBox: svgWithViewBox,
width: b.width || 1,
height: b.height || 1,
offsetX: b.x,
offsetY: b.y
};
};
})();
lsg3Div/createObjects/path/path.ls
(function(){
return function(o){
var svgDetails, svg, pathEl, x, ref$, y, scale, fillColor, lineColor, lineSize, lineDash, o2, div;
svgDetails = inc("generateTrimmedSvgFromPath/generate")(o.path);
svg = Div().html(svgDetails.svg).firstChild;
pathEl = svg.findFirst("path");
x = ((ref$ = o.x) != null ? ref$ : 0) + svgDetails.offsetX;
y = ((ref$ = o.y) != null ? ref$ : 0) + svgDetails.offsetY;
scale = inc("calcScale/calc")(o, svgDetails);
fillColor = o.color || "transparent";
lineColor = o.lineColor || "transparent";
lineSize = o.lineSize || 0;
lineDash = o.lineDash === true
? "10, 10"
: o.lineDash ? o.lineDash + ", " + o.lineDash : void 8;
o2 = _.clone(o);
o2.x = x;
o2.y = y;
div = inc("../_shared/layerDiv/div")(o2).html(svg.css({
width: svgDetails.width * scale.x + "px",
height: svgDetails.height * scale.y + "px"
}).attr({
fill: fillColor,
stroke: lineColor,
"stroke-width": lineSize,
"stroke-dasharray": lineDash
}));
svg.findFirst('#scaleGroup').attr({
transform: "scale(" + scale.x + ", " + scale.y + ")"
});
inc("../_shared/addClassAndPointerEvents/add")(pathEl, o);
return div;
};
})();
lsg3Div/createObjects/rect/rect.ls
(function(){
return function(o){
var div;
return div = inc("../_shared/layerDiv/div")(o).css({
overflow: "visible"
}).html(inc("svgRect/svg")(o));
};
})();
lsg3Div/createObjects/rect/svgRect/svg.ls
(function(){
return function(o){
var w, h, fillColor, lineColor, lineSize, rounded, lineDash, svg, rect;
w = o.w || o.h;
h = o.h || o.w;
fillColor = o.color || "transparent";
lineColor = o.lineColor || "transparent";
lineSize = o.lineSize || 0;
rounded = o.rounded || 0;
lineDash = o.lineDash === true
? "10, 10"
: o.lineDash ? o.lineDash + ", " + o.lineDash : void 8;
svg = inc("../../_shared/svg/svg")({
width: w,
height: h
});
svg.append(rect = svg.createElement("rect").attr({
x: 0 + lineSize / 2,
y: 0 + lineSize / 2,
width: w - lineSize,
height: h - lineSize,
fill: fillColor,
stroke: lineColor,
rx: rounded,
"stroke-width": lineSize,
"stroke-dasharray": lineDash
}));
inc("../../_shared/addClassAndPointerEvents/add")(rect, o);
return svg;
};
})();
lsg3Div/createObjects/svg/addSvgClassesPointerEvents/add.ls
(function(){
return function(o, div){
var i$, ref$, len$, svgClass, lresult$, j$, ref1$, len1$, el, results$ = [];
if (!o.svgClasses) {
return;
}
for (i$ = 0, len$ = (ref$ = o.svgClasses.split(" ")).length; i$ < len$; ++i$) {
svgClass = ref$[i$];
lresult$ = [];
for (j$ = 0, len1$ = (ref1$ = div.findAll("." + svgClass)).length; j$ < len1$; ++j$) {
el = ref1$[j$];
lresult$.push(el.css({
pointerEvents: "auto"
}));
}
results$.push(lresult$);
}
return results$;
};
})();
lsg3Div/createObjects/svg/calcDimensions/calc.ls
(function(){
return function(svg){
var clean, viewBoxValues, ref$, that;
clean = function(s){
return s.replace(/[^0-9.]/g, '');
};
viewBoxValues = (ref$ = svg.attr("viewBox")) != null ? ref$.split(" ") : void 8;
return {
width: (that = svg.attr("width"))
? +clean(that)
: +viewBoxValues[2],
height: (that = svg.attr("height"))
? +clean(that)
: +viewBoxValues[3]
};
};
})();
lsg3Div/createObjects/svg/calcSettings/calc.ls
(function(){
return function(o, dimensions){
if (o.crop && o.w && o.h) {
return inc("calcCrop/calc")(o, dimensions);
} else {
return inc("calcNormal/calc")(o, dimensions);
}
};
})();
lsg3Div/createObjects/svg/calcSettings/calcCrop/calc.ls
(function(){
return function(o, dimensions){
var align, ref$, scaleX, scaleY, scale, has;
align = ((ref$ = o.align) != null ? ref$.toLowerCase() : void 8) || "centermiddle";
scaleX = o.w / dimensions.width;
scaleY = o.h / dimensions.height;
scale = Math.max(scaleX, scaleY);
has = function(s){
return _.includes(align, s);
};
return {
align: align,
scaleX: scale,
scaleY: scale,
alignItems: has("top")
? "flex-start"
: has("bottom") ? "flex-end" : "center",
justifyContent: has("left")
? "flex-start"
: has("right") ? "flex-end" : "center"
};
};
})();
lsg3Div/createObjects/svg/calcSettings/calcNormal/calc.ls
(function(){
return function(o, dimensions){
var scaleX, scaleY;
if (o.w && o.h) {
scaleX = o.w / dimensions.width;
scaleY = o.h / dimensions.height;
} else if (o.w) {
scaleX = o.w / dimensions.width;
scaleY = scaleX;
} else if (o.h) {
scaleY = o.h / dimensions.height;
scaleX = scaleY;
} else {
scaleX = 1;
scaleY = 1;
}
return {
scaleX: scaleX,
scaleY: scaleY
};
};
})();
lsg3Div/createObjects/svg/getSvg/get.ls
(function(){
return function(o, l){
var id, svgs, svg;
if (_.startsWith(o.svg, "