Skip to content

Commit

Permalink
style: format many files
Browse files Browse the repository at this point in the history
  • Loading branch information
lajbel committed May 27, 2024
1 parent 2fa5759 commit d6b39da
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 65 deletions.
18 changes: 5 additions & 13 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@ labels: 'bug'
assignees: ''
---

**Describe the bug**
A clear and concise description of what the bug is.
-
## **Describe the bug**A clear and concise description of what the bug is.

**Version**
What version are you running?
-
## **Version**What version are you running?

**To Reproduce**
Steps to reproduce the behavior:
1.
1.

**Expected behavior**
A clear and concise description of what you expected to happen.
-
## **Expected behavior**A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.
-
## **Screenshots**If applicable, add screenshots to help explain your problem.
16 changes: 4 additions & 12 deletions .github/ISSUE_TEMPLATE/feat.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@ labels: 'enhancement'
assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
-
## **Is your feature request related to a problem? Please describe.**A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
-
## **Describe the solution you'd like**A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
-
## **Describe alternatives you've considered**A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
-
## **Additional context**Add any other context or screenshots about the feature request here.
27 changes: 25 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
1. `pnpm install` to install dependencies.

## Editing examples

1. Pick on example to test and edit the corresponding `/examples/[name].js`, or create a new file under `/examples` to test anything you're working on.
1. The source entry point is `src/kaboom.ts`, editing any files referenced will automatically trigger rebuild. **Make sure not to break any existing examples**.

## Before commit

1. follow conventional [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) format. You can see how seeing
the commit history.
1. `npm run check` to check typescript.
Expand All @@ -32,52 +34,73 @@ A commit starts with a type, a scope, and a subject:

- The **type** is mandatory. [Should be one of the following](#commit-types).
- We don't use the **scope** right now, you must omit it. This may change in the future.
- The subject must be a short description of the change.
Use the imperative, present tense: "change" not "changed" nor "changes".
- The subject must be a short description of the change.
Use the imperative, present tense: "change" not "changed" nor "changes".

### Commit types

`feat`: a new feature or part of a feature

```
feat: add hello() component
```

`fix`: a bug fix

```
fix: fix platformer example
```

`docs`: changes to documentation (jsDoc, md files, etc)

```
docs: update add() component jsDoc example
```

`style`: changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)

```
style: format all files
```

`refactor`: a code change that neither fixes a bug nor adds a feature

```
refactor: move assets to src/assets
```

`test`: adding missing tests or correcting existing tests

```
test: added tests for add() component
```

`build`: changes that affect the build system or external dependencies (esbuild, typescript)

```
build: update esbuild to 0.12.0
```

`ci`: changes to our CI configuration files and scripts (Github Actions)

```
ci: add examples test workflow
```

`revert`: reverts a previous commit

```
revert: feat: add hello() component
```

`chore`: updating tasks, general maintenance, etc (anything that doesn't fit in the above types)

```
chore: update README.md
```

`example`: adding a new example

```
example: add firework example
```
17 changes: 8 additions & 9 deletions examples/polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ let dragging = null;
let hovering = null;

poly.onDraw(() => {
const triangles = triangulate(poly.pts)
const triangles = triangulate(poly.pts);
for (const triangle of triangles) {
drawTriangle({
p1: triangle[0],
p2: triangle[1],
p3: triangle[2],
fill: false,
outline: { color: BLACK }
})
outline: { color: BLACK },
});
}
if (hovering !== null) {
drawCircle({
Expand All @@ -55,14 +55,13 @@ poly.onDraw(() => {
}
});

onUpdate(()=>{
onUpdate(() => {
if (isConvex(poly.pts)) {
poly.color = WHITE
}
else {
poly.color = rgb(192, 192, 192)
poly.color = WHITE;
} else {
poly.color = rgb(192, 192, 192);
}
})
});

onMousePress(() => {
dragging = hovering;
Expand Down
2 changes: 1 addition & 1 deletion src/components/draw/shader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function shader(
uniform: uniform,
}),
inspect() {
return `shader: ${id}`
return `shader: ${id}`;
},
};
}
51 changes: 25 additions & 26 deletions src/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2343,8 +2343,8 @@ function isOrientedCcw(a: Vec2, b: Vec2, c: Vec2) {

// true if the polygon is oriented counter clockwise
function isOrientedCcwPolygon(polygon: Vec2[]) {
let total =0;
let prev:Vec2 = polygon[polygon.length-1];
let total = 0;
let prev: Vec2 = polygon[polygon.length - 1];
for (let i = 0; i < polygon.length; i++) {
total += (polygon[i].x - prev.x) * (polygon[i].y + prev.y);
prev = polygon[i];
Expand Down Expand Up @@ -2453,32 +2453,31 @@ export function triangulate(pts: Vec2[]): Vec2[][] {
return triangles;
}

export function isConvex(pts: Vec2[])
{
if (pts.length < 3)
return false;
export function isConvex(pts: Vec2[]) {
if (pts.length < 3) {
return false;
}

// a polygon is convex if all corners turn in the same direction
// turning direction can be determined using the cross-product of
// the forward difference vectors
let i = pts.length - 2
let j = pts.length - 1
// a polygon is convex if all corners turn in the same direction
// turning direction can be determined using the cross-product of
// the forward difference vectors
let i = pts.length - 2;
let j = pts.length - 1;
let k = 0;
let p = pts[j].sub(pts[i]);
let q = pts[k].sub(pts[j]);
let winding = p.cross(q);

while (k+1 < pts.length)
{
i = j;
j = k;
let p = pts[j].sub(pts[i]);
let q = pts[k].sub(pts[j]);
let winding = p.cross(q);

while (k + 1 < pts.length) {
i = j;
j = k;
k++;
p = pts[j].sub(pts[i]);
q = pts[k].sub(pts[j]);
p = pts[j].sub(pts[i]);
q = pts[k].sub(pts[j]);

if (p.cross(q) * winding < 0) {
return false;
if (p.cross(q) * winding < 0) {
return false;
}
}
return true;
}
}
return true;
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"paths": {
"@/*": [
"./src/*"
],
]
}
},
"include": [
"src/**/*",
"scripts/**/*"
]
}
}

0 comments on commit d6b39da

Please sign in to comment.