paper.js/examples/Scripts/BlendModes.html

78 lines
179 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
2014-08-16 13:24:54 -04:00
<meta charset="UTF-8">
<title>BlendModes</title>
<script type="text/javascript" src="../../dist/paper-full.js"></script>
<script type="text/paperscript" canvas="canvas">
var stops = [];
for (var i = 0; i < 6; i++)
stops.push({ hue: (i - 3) * 60, saturation: 1, brightness: 1 });
var size = new Size(150, 150)
var background = new Path.Rectangle({
rectangle: new Rectangle(size),
fillColor: {
stops: stops,
origin: [0, 0],
destination: [size.width, 0]
}
});
2014-08-16 13:24:54 -04:00
var image = new Raster('ducky');
image.fitBounds(background.bounds);
background = new SymbolDefinition(background);
image = new SymbolDefinition(image);
2014-08-16 13:24:54 -04:00
var all = new Group();
function makeExample(point, blendMode) {
var rect = background.place();
// var img = new Raster('ducky');
var img = image.place();
img.fitBounds(rect.bounds);
img.blendMode = blendMode;
var text = new PointText({
point: [0, size.height / 2 + 15],
fontSize: 14,
justification: 'center',
content: mode + (paper.support.nativeBlendModes[mode] ? ' (native)' : '')
})
var group = new Group(rect, img, text);
group.position = point;
all.addChild(group);
}
2014-08-16 13:24:54 -04:00
var modes = [ 'normal', 'multiply', 'screen', 'overlay', 'soft-light',
'hard-light', 'color-dodge', 'color-burn', 'darken', 'lighten',
'difference', 'exclusion', 'hue', 'saturation', 'luminosity',
'color', 'add', 'subtract', 'average', 'pin-light', 'negation'];
var columns = 5;
var rows = Math.ceil(modes.length / columns);
for (var y = 0, i = 0; y < rows; y++) {
for (var x = 0; x < columns; x++) {
var mode = modes[i];
if (!mode)
break;
var point = (new Point(x, y) + 0.5) * (size + 20);
makeExample(point, mode);
i++;
}
}
2014-08-16 13:24:54 -04:00
// all.opacity = 0.5;
all.position = view.center;
2014-08-16 13:24:54 -04:00
var svg = project.exportSVG();
document.body.appendChild(svg);
//console.log(svg, new XMLSerializer().serializeToString(svg));
</script>
</head>
<body>
2014-08-16 13:24:54 -04:00
<h2>Paper.js Canvas</h2>
<canvas id="canvas" width="800" height="850"></canvas>
<h2>SVG Export</h2>
<div class id="svg"></div>
<img id="ducky" style="display:none;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAa4AAAGuCAYAAADI9eKaAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo5NkVDMDNGM0QwMDUxMUUyQkRGM0NGMDU0QjY0MTQ5MCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo5NkVDMDNGNEQwMDUxMUUyQkRGM0NGMDU0QjY0MTQ5MCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjk2RU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