paper.js/examples/Scripts/HSLColor.html

37 lines
1.1 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>HSLColor</title>
<link rel="stylesheet" href="../css/style.css">
<script type="text/javascript" src="../../dist/paper.js"></script>
<script type="text/paperscript" canvas="canvas">
2011-07-08 08:47:34 -04:00
var path;
var r = view.size.width * .12;
var offset = new Point(view.size.width / 3, 0);
var hCount = 40;
var sCount = 18;
for (var s = 0; s < sCount; s++) {
for (var h = 0; h < hCount; h++) {
var saturation = s / sCount;
var hue = (h / hCount) * 360;
var vector = new Point({
angle: hue - 90,
length: r * saturation
});
var color = new HSLColor(hue, saturation, 0.75);
var radius = Math.max(r / 10 * Math.sqrt(saturation), 5);
for (var i = 0; i < 3; i++) {
var center = view.center + vector + offset * (i - 1);
path = new Path.Circle(center, radius);
color.lightness = 0.25 + 0.25 * (2 - i);
path.fillColor = color.clone();
}
}
2011-07-07 10:09:02 -04:00
}
</script>
</head>
<body>
<canvas id="canvas" resize></canvas>
</body>
</html>