Example #1
0
	function removeRedundantPoints(points) {
		var lastPoint = last(points);
		return lazy(last(-1, points))
			.consecutive(2)
			.reduce( argumentizeReduce(function (r, point, next) {
				var prev = last(r);
				if (inflects(prev, point, next, lastPoint))
					return r.concat([point]);
				return r;
			}), [first(points)])
			.concat([lastPoint]);
	}
Example #2
0
File: joinEnds.js Project: agj/nui
		return strokes.map( function (points) {
			var isFirstOrLast = within([first(points), last(points)]);
			return lazy(points)
				.map( provided( not(isFirstOrLast), to.id,
					function (point) {
						var ptIndex = findIndex(refPoints, seq(distance(point), λ('/' + cfg.SVG_SIZE), is.lt(1 / 20)));
						if (ptIndex === -1) {
							return point;
						} else {
							return refPoints[ptIndex];
						}
					}
				))
				.toArray();
		});
Example #3
0
			.reduce( argumentizeReduce(function (r, point, next) {
				var prev = last(r);
				if (inflects(prev, point, next, lastPoint))
					return r.concat([point]);
				return r;
			}), [first(points)])