- commit
- 44e2421f1d71a375f5191d82f73ac88d732667b8
- parent
- def3414774f82384ef856e2b1c8fb85ef9b22674
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2024-09-07 10:58
reuse canvas context
Diffstat
| M | contrast.js | 2 | +- |
1 files changed, 1 insertions, 1 deletions
diff --git a/contrast.js b/contrast.js
@@ -7,6 +7,7 @@ var swapButton = document.querySelector('#swap');
7 7 var gradient = document.querySelector('#output .gradient');
8 8 var description = document.querySelector('#output .description');
9 9 var canvas = document.querySelector('canvas');
-1 10 var context = canvas.getContext('2d');
10 11
11 12 var score = function(linRange, linLevels) {
12 13 // Estimate home many color combinations fall into each category,
@@ -65,7 +66,6 @@ var makeGradient = function(scores) {
65 66 };
66 67
67 68 var parseColor = function(s) {
68 -1 var context = canvas.getContext('2d');
69 69 context.fillStyle = s;
70 70 context.fillRect(0,0,1,1);
71 71 var data = context.getImageData(0, 0, 1, 1, {colorSpace: 'srgb'}).data;