Skip to content

Commit f70ac1a

Browse files
committed
Add a pre-commit hook configuration to check YAML and whitespace.
These are minor, but avoids those coming up during reviews at all. Signed-off-by: Diego Elio Pettenò <[email protected]>
1 parent 2077d83 commit f70ac1a

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ bundles
1212
*.DS_Store
1313
.eggs
1414
dist
15-
**/*.egg-info
15+
**/*.egg-info

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ repos:
1111
rev: latest
1212
hooks:
1313
- id: reuse
14+
- repo: https://github.com/pre-commit/pre-commit-hooks
15+
rev: v2.3.0
16+
hooks:
17+
- id: check-yaml
18+
- id: end-of-file-fixer
19+
- id: trailing-whitespace

examples/server/static/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
<h1>LED color picker demo!</h1>
1414
<canvas id="colorPicker" height="300px" width="300px"></canvas>
1515
</body>
16-
</html>
16+
</html>

examples/server/static/led_color_picker_example.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ctx.height = 300;
99

1010
function drawColorPicker() {
1111
/**
12-
* Color picker inspired by:
12+
* Color picker inspired by:
1313
* https://medium.com/@bantic/hand-coding-a-color-wheel-with-canvas-78256c9d7d43
1414
*/
1515
let radius = 150;
@@ -18,30 +18,30 @@ function drawColorPicker() {
1818

1919
for (let x = -radius; x < radius; x++) {
2020
for (let y = -radius; y < radius; y++) {
21-
21+
2222
let [r, phi] = xy2polar(x, y);
23-
23+
2424
if (r > radius) {
2525
// skip all (x,y) coordinates that are outside of the circle
2626
continue;
2727
}
28-
28+
2929
let deg = rad2deg(phi);
30-
30+
3131
// Figure out the starting index of this pixel in the image data array.
3232
let rowLength = 2*radius;
3333
let adjustedX = x + radius; // convert x from [-50, 50] to [0, 100] (the coordinates of the image data array)
3434
let adjustedY = y + radius; // convert y from [-50, 50] to [0, 100] (the coordinates of the image data array)
3535
let pixelWidth = 4; // each pixel requires 4 slots in the data array
3636
let index = (adjustedX + (adjustedY * rowLength)) * pixelWidth;
37-
37+
3838
let hue = deg;
3939
let saturation = r / radius;
4040
let value = 1.0;
41-
41+
4242
let [red, green, blue] = hsv2rgb(hue, saturation, value);
4343
let alpha = 255;
44-
44+
4545
data[index] = red;
4646
data[index+1] = green;
4747
data[index+2] = blue;
@@ -127,4 +127,3 @@ function getCursorPosition(canvas, event) {
127127

128128
drawColorPicker();
129129
canvas.addEventListener('mousedown', onColorPick);
130-

0 commit comments

Comments
 (0)