-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
86 lines (72 loc) · 3.16 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Color Swatch</title>
<meta name="description" content="A simple color swatch that fits to the available view window on load">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/style.css">
<!-- Paper.js include -->
<script type="text/javascript" src="assets/lib/paper-full.min.js"></script>
<script type="text/javascript" src="assets/lib/jquery-3.5.1.min.js"></script>
<script type="text/paperscript" canvas="mycanvas">
var maxPoint = new Point(view.size.width, view.size.height);
for (var x=0; x <= maxPoint.x; x += 10){
for (var y = 0; y <= maxPoint.y; y += 10){
var origin = new Point(x, y);
var termination = new Point(x+10, y+10);
var rectangle = new Rectangle(origin, termination);
var path = new Path.Rectangle(rectangle);
path.fillColor = rgbCode(origin);
path.selected = false;
}
}
$('#loader').fadeOut(2000, function(evt){
$(this).removeClass('animate');
$('#loading').css("display","none");
})
$('canvas').css('opacity', '1');
// Create a circle shaped path with a radius of 10 at {x: 0, y: 0}:
var text = new PointText(new Point(200, 50));
text.justification = 'left';
text.fillColor = 'black';
function rgbCode(pnt){
var r = (pnt.x / maxPoint.x) * 255;
var g = (pnt.y / maxPoint.y) * 255;
var b = 255 - (Math.max((pnt.x / maxPoint.x), (pnt.y / maxPoint.y)) * 255);
return "rgb(" + Math.ceil(r) + ", " + Math.ceil(g) + "," + Math.ceil(b) + ")";
}
var path = new Path.Circle({
center: [0, 0],
radius: 2,
fillColor: 'black'
});
tool.onMouseMove = function(event) {
// Whenever the user moves the mouse, move the path
// to that position:
var maxPoint = new Point(view.size.width, view.size.height);
var shift = new Point(60, 0);
var size = new Size(shift);
path.position = event.point;
// text.content = event.point;
text.content = rgbCode(event.point);
if (event.point.x + shift.x + size.width >= maxPoint.x) {
text.position = event.point - shift;
} else {
text.position = event.point + shift;
}
}
</script>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div id="loading"><img id="loader" class="animate" src="https://anthony-kyle.github.io/images/PilcrowMicroLogo.png" alt="PilcrowMicro"></div>
<canvas id="mycanvas" resize="true"></canvas>
</body>
</html>