Skip to content

Commit 8c123ab

Browse files
authored
Merge pull request #14 from ItsNickBarry/prettier
Format with `prettier`
2 parents 55da956 + 2dee16a commit 8c123ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4736
-3269
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
jasmine/lib/
2+
node_modules/

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn run lint-staged

.lintstagedrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"*.{js,ts,json,md}": ["prettier --write"]
3+
}

.prettierrc.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"bracketSpacing": true,
6+
"plugins": ["@trivago/prettier-plugin-sort-imports"]
7+
}

API.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# API
2+
23
## Exposed Variables and Constants
4+
35
An object containing all Canvas objects is exposed through the `HyperbolicCanvas` namespace.
46

57
```javascript
@@ -24,11 +26,13 @@ Math.TAU;
2426
[manifesto]: http://tauday.com/tau-manifesto
2527

2628
## Geometric Object Classes and Their Functions
29+
2730
The hyperbolic canvas makes use of several geometric object classes, defined relative to the Euclidean plane.
2831

29-
When instantiating objects, it is **not recommended to call the constructor directly**. Instead, use the provided factory methods.
32+
When instantiating objects, it is **not recommended to call the constructor directly**. Instead, use the provided factory methods.
3033

3134
### Angle
35+
3236
A non-function object which contains convenience functions related to angles.
3337

3438
Functions:
@@ -52,6 +56,7 @@ Angle.random(quadrant);
5256
```
5357

5458
### Point
59+
5560
A representation of a point on the Canvas, where the center is defined as (0, 0) and the radius is defined as 1, and the y axis is not inverted.
5661

5762
Constants:
@@ -139,7 +144,8 @@ Point.prototype.opposite();
139144
```
140145

141146
### Line
142-
The relationship between two Points. Contains various functions which act on either the Euclidean or the hyperbolic plane. Can represent a line, line segment, or ray.
147+
148+
The relationship between two Points. Contains various functions which act on either the Euclidean or the hyperbolic plane. Can represent a line, line segment, or ray.
143149

144150
Constants:
145151

@@ -163,6 +169,7 @@ Line.givenAnglesOfIdealPoints(someAngle, someOtherAngle);
163169
```
164170

165171
Class functions:
172+
166173
```javascript
167174
Line.euclideanIntersect(someLine, someOtherLine);
168175
// calculate the point of intersection of two Euclidean lines
@@ -212,6 +219,7 @@ Line.prototype.getEuclideanUnitCircleIntersects();
212219
```
213220

214221
### Circle
222+
215223
A Euclidean center Point and a Euclidean radius; potentially also a hyperbolic center Point and a hyperbolic radius.
216224

217225
Constants:
@@ -293,6 +301,7 @@ Circle.prototype.getUnitCircleIntersects();
293301
```
294302

295303
### Polygon
304+
296305
An ordered collection of Points.
297306

298307
Factory methods:
@@ -328,6 +337,7 @@ Polygon.prototype.getVertices();
328337
```
329338

330339
## The Canvas Class and Its Functions
340+
331341
The canvas class is used to draw hyperbolic lines and shapes.
332342

333343
Instance functions:

README.md

+19-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ npm install --save hyperbolic-canvas
2020

2121
## Usage
2222

23-
Pass a unique selector of a div element, to the function `HyperbolicCanvas.create`. Nonzero width and height styling must be specified. Absolute px values in a 1:1 ratio are recommended:
23+
Pass a unique selector of a div element, to the function `HyperbolicCanvas.create`. Nonzero width and height styling must be specified. Absolute px values in a 1:1 ratio are recommended:
2424

2525
```html
2626
<div id="hyperbolic-canvas" style="width: 600px; height: 600px;"></div>
@@ -36,22 +36,36 @@ See `API.md` for a list of functions and their descriptions.
3636

3737
## Scope
3838

39-
This library prioritizes the visualization of hyperbolic geometry over precise mathematical calculation. Due to the less-than-infinite precision of floating-point numbers, and because certain trigonometric functions are [ill-conditioned](https://en.wikipedia.org/wiki/Condition_number), these goals are often at odds.
39+
This library prioritizes the visualization of hyperbolic geometry over precise mathematical calculation. Due to the less-than-infinite precision of floating-point numbers, and because certain trigonometric functions are [ill-conditioned](https://en.wikipedia.org/wiki/Condition_number), these goals are often at odds.
4040

4141
### Accuracy Thresholds
4242

43-
The arbitrary constants `HyperbolicCanvas.INFINITY` and `HyperbolicCanvas.ZERO` have been defined for use in internal comparisons in place of `Infinity` and `0`, respectively. Their values may be overridden, but increased accuracy will tend to lead to more unpredictable behavior.
43+
The arbitrary constants `HyperbolicCanvas.INFINITY` and `HyperbolicCanvas.ZERO` have been defined for use in internal comparisons in place of `Infinity` and `0`, respectively. Their values may be overridden, but increased accuracy will tend to lead to more unpredictable behavior.
4444

4545
### Jasmine Specs
4646

4747
This library uses [Jasmine specs][jasmine] to validate the code and prevent regressions.
4848

49-
The specs have been written to use random input values. While this approach is unconventional, it provides more confidence than would an attempt to test an effectively infinite number of edge cases<!-- ha! Get it? -->. Some specs do occasionally fail; the frequency at which this occurs is determined by the accuracy of the constants `HyperbolicCanvas.INFINITY` and `HyperbolicCanvas.ZERO`.
49+
The specs have been written to use random input values. While this approach is unconventional, it provides more confidence than would an attempt to test an effectively infinite number of edge cases<!-- ha! Get it? -->. Some specs do occasionally fail; the frequency at which this occurs is determined by the accuracy of the constants `HyperbolicCanvas.INFINITY` and `HyperbolicCanvas.ZERO`.
5050

51-
The Jasmine library itself has been modified to run each spec multiple times, and a random number seed is used so that errors may be reproduced. The seed and the spec run count can be set in the options menu on the [SpecRunner][jasmine] page.
51+
The Jasmine library itself has been modified to run each spec multiple times, and a random number seed is used so that errors may be reproduced. The seed and the spec run count can be set in the options menu on the [SpecRunner][jasmine] page.
5252

5353
[jasmine]: https://ItsNickBarry.github.io/hyperbolic-canvas/jasmine/SpecRunner.html
5454

5555
### Browser Support
5656

5757
Certain browsers do not provide support for the hyperbolic trigonometric functions. Polyfills are available.
58+
59+
## Development
60+
61+
Install dependencies via Yarn:
62+
63+
```bash
64+
yarn install
65+
```
66+
67+
Setup Husky to format code on commit:
68+
69+
```bash
70+
yarn prepare
71+
```

about.html

+80-62
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,99 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
3-
<head>
4-
5-
<!-- Basic Page Needs
3+
<head>
4+
<!-- Basic Page Needs
65
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
7-
<meta charset="utf-8">
8-
<title>Hyperbolic Canvas</title>
9-
<meta name="description" content="The Poincaré disk model of the hyperbolic plane, in Javascript">
10-
<meta name="author" content="Nick Barry">
6+
<meta charset="utf-8" />
7+
<title>Hyperbolic Canvas</title>
8+
<meta
9+
name="description"
10+
content="The Poincaré disk model of the hyperbolic plane, in Javascript"
11+
/>
12+
<meta name="author" content="Nick Barry" />
1113

12-
<!-- Mobile Specific Metas
14+
<!-- Mobile Specific Metas
1315
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
14-
<meta name="backdrop" content="width=device-width, initial-scale=1">
16+
<meta name="backdrop" content="width=device-width, initial-scale=1" />
1517

16-
<!-- FONT
18+
<!-- FONT
1719
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
18-
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
20+
<link
21+
href="//fonts.googleapis.com/css?family=Raleway:400,300,600"
22+
rel="stylesheet"
23+
type="text/css"
24+
/>
1925

20-
<!-- CSS
26+
<!-- CSS
2127
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
22-
<link rel="stylesheet" href="css/normalize.css">
23-
<link rel="stylesheet" href="css/skeleton.css">
24-
<link rel="stylesheet" href="css/hyperbolic-canvas.css">
28+
<link rel="stylesheet" href="css/normalize.css" />
29+
<link rel="stylesheet" href="css/skeleton.css" />
30+
<link rel="stylesheet" href="css/hyperbolic-canvas.css" />
2531

26-
<!-- Favicon
32+
<!-- Favicon
2733
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
28-
<link rel="icon" type="image/png" href="images/favicon.png">
29-
30-
</head>
31-
<body class="about">
32-
33-
<!-- Primary Page Layout
34+
<link rel="icon" type="image/png" href="images/favicon.png" />
35+
</head>
36+
<body class="about">
37+
<!-- Primary Page Layout
3438
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
35-
<div class="container">
36-
<div class="row">
37-
<nav>
38-
<div class="nav-button three columns">
39-
<a href="index.html">Home</a>
40-
</div>
41-
<div class="nav-button three columns">
42-
<a href="about.html">About</a>
43-
</div>
44-
<div class="nav-button three columns">
45-
<a href="documentation.html">Documentation</a>
46-
</div>
47-
<div class="nav-button three columns">
48-
<a href="examples.html">Examples</a>
49-
</div>
50-
</nav>
51-
</div>
39+
<div class="container">
40+
<div class="row">
41+
<nav>
42+
<div class="nav-button three columns">
43+
<a href="index.html">Home</a>
44+
</div>
45+
<div class="nav-button three columns">
46+
<a href="about.html">About</a>
47+
</div>
48+
<div class="nav-button three columns">
49+
<a href="documentation.html">Documentation</a>
50+
</div>
51+
<div class="nav-button three columns">
52+
<a href="examples.html">Examples</a>
53+
</div>
54+
</nav>
55+
</div>
5256

53-
<div class="row">
54-
<div class="content">
55-
<h1>About</h1>
56-
<p>
57-
Read about hyperbolic geometry on <a href="https://en.wikipedia.org/wiki/Hyperbolic_geometry">Wikipedia</a>.
58-
</p>
59-
<p>
60-
Hyperbolic Canvas is a Javscript library which uses the Poincaré disk model of the hyperbolic plane to map hyperbolic space onto an HTML canvas.
61-
</p>
62-
<p>
63-
View the source code on <a href="https://github.com/ItsNickBarry/hyperbolic-canvas">GitHub</a>.
64-
</p>
65-
<p>
66-
Automated tests running on a modified version of <a href="https://jasmine.github.io/">Jasmine</a> can be found <a href="jasmine/SpecRunner.html">here</a>.
67-
</p>
68-
<p>
69-
Released under the <a href="https://github.com/ItsNickBarry/hyperbolic-canvas/blob/gh-pages/LICENSE.md">MIT License</a>.
70-
</p>
57+
<div class="row">
58+
<div class="content">
59+
<h1>About</h1>
60+
<p>
61+
Read about hyperbolic geometry on
62+
<a href="https://en.wikipedia.org/wiki/Hyperbolic_geometry"
63+
>Wikipedia</a
64+
>.
65+
</p>
66+
<p>
67+
Hyperbolic Canvas is a Javscript library which uses the Poincaré
68+
disk model of the hyperbolic plane to map hyperbolic space onto an
69+
HTML canvas.
70+
</p>
71+
<p>
72+
View the source code on
73+
<a href="https://github.com/ItsNickBarry/hyperbolic-canvas"
74+
>GitHub</a
75+
>.
76+
</p>
77+
<p>
78+
Automated tests running on a modified version of
79+
<a href="https://jasmine.github.io/">Jasmine</a> can be found
80+
<a href="jasmine/SpecRunner.html">here</a>.
81+
</p>
82+
<p>
83+
Released under the
84+
<a
85+
href="https://github.com/ItsNickBarry/hyperbolic-canvas/blob/gh-pages/LICENSE.md"
86+
>MIT License</a
87+
>.
88+
</p>
89+
</div>
7190
</div>
7291
</div>
73-
</div>
7492

75-
<!-- Scripts
93+
<!-- Scripts
7694
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
7795

78-
<!-- End Document
96+
<!-- End Document
7997
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
80-
</body>
98+
</body>
8199
</html>

css/example.css

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
A hyperbolic-canvas div with a percentage-based size must have a parent with non-zero size.
33
Margin is removed for simplicity.
44
*/
5-
html, body {
5+
html,
6+
body {
67
height: 100%;
78
margin: 0;
8-
background-color: #2C001E;
9+
background-color: #2c001e;
910
}
1011

1112
/*
@@ -24,7 +25,7 @@ It is automatically scaled to fill its parent, and cropped to a 1:1 ratio.
2425
It is not recommended to apply styling beyond background color.
2526
*/
2627
div#hyperbolic-canvas div.backdrop {
27-
background-color: #2C001E;
28+
background-color: #2c001e;
2829
}
2930

3031
/*
@@ -33,5 +34,5 @@ It is automatically scaled to fit its parent.
3334
It is not recommended to apply styling beyond background color.
3435
*/
3536
div#hyperbolic-canvas div.backdrop div.underlay {
36-
background-color: #D6D3CF;
37+
background-color: #d6d3cf;
3738
}

css/hyperbolic-canvas.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ div.content {
5858
}
5959

6060
div.example:hover {
61-
background: #FBECE7;
61+
background: #fbece7;
6262
}
6363

6464
div.example {
@@ -87,7 +87,7 @@ It is automatically scaled to fill its parent, and cropped to a 1:1 ratio.
8787
It is not recommended to apply styling beyond background color.
8888
*/
8989
div#hyperbolic-canvas div.backdrop {
90-
background-color: #2C001E;
90+
background-color: #2c001e;
9191
}
9292

9393
/*
@@ -96,5 +96,5 @@ It is automatically scaled to fit its parent.
9696
It is not recommended to apply styling beyond background color.
9797
*/
9898
div#hyperbolic-canvas div.backdrop div.underlay {
99-
background-color: #D6D3CF;
99+
background-color: #d6d3cf;
100100
}

0 commit comments

Comments
 (0)