-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
2,768 additions
and
32,238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
example/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"rust-analyzer.linkedProjects": ["./Cargo.toml"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import a from "fallingjs"; | ||
|
||
window.onload = () => { | ||
console.log(a); | ||
// const fallingjs = new FallingJS(); | ||
// fallingjs.start(); | ||
}; |
File renamed without changes
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "example", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"fallingjs": "^0.0.7" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
<style> | ||
* { | ||
user-select: none; | ||
outline: 0; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
html, | ||
body, | ||
canvas { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
body { | ||
background-color: #292931; | ||
overflow: hidden; | ||
} | ||
</style> | ||
|
||
<script type="module"> | ||
import FallingJS from "./dist/index.js"; | ||
window.onload = () => { | ||
const fallingjs = new FallingJS({ wasm: true }); | ||
fallingjs.start(); | ||
}; | ||
</script> | ||
</head> | ||
<body></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import SceneFromJS from "./scene.js"; | ||
import * as FallingRS from "fallingrs"; | ||
|
||
export default class FallingJS { | ||
constructor({ | ||
frequency = 1, | ||
minRadius = 1, | ||
maxRadius = 3, | ||
minSpeed = 1, | ||
maxSpeed = 3, | ||
minAngle = -0.1, | ||
maxAngle = 0.1, | ||
colors = ["#FFF"], | ||
type_ = "Square", | ||
text = "*", | ||
el = "body", | ||
wasm = false, | ||
} = {}) { | ||
this.scene = !wasm | ||
? new SceneFromJS({ | ||
frequency, | ||
minRadius, | ||
maxRadius, | ||
minSpeed, | ||
maxSpeed, | ||
minAngle, | ||
maxAngle, | ||
colors, | ||
type_, | ||
text, | ||
el, | ||
}) | ||
: new FallingRS.Scene( | ||
new FallingRS.FallingConfig( | ||
frequency, | ||
minRadius, | ||
maxRadius, | ||
minSpeed, | ||
maxSpeed, | ||
minAngle, | ||
maxAngle, | ||
colors, | ||
0, | ||
text, | ||
el | ||
) | ||
); | ||
} | ||
|
||
async start() { | ||
this.scene.resize(); | ||
window.addEventListener("resize", () => { | ||
console.log(this.scene); | ||
console.log(this.scene.config); | ||
console.log(this.scene.stageWidth); | ||
}); | ||
|
||
function animate() { | ||
this.scene.render(); | ||
requestAnimationFrame(animate.bind(this)); | ||
} | ||
requestAnimationFrame(animate.bind(this)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { FallingObject } from "./object.js"; | ||
|
||
export default class { | ||
constructor(config) { | ||
this.config = config; | ||
this.canvas = document.createElement("canvas"); | ||
this.ctx = this.canvas.getContext("2d"); | ||
this.objects = []; | ||
this.elem = document.querySelector(config.el); | ||
this.elem.appendChild(this.canvas); | ||
this.elem.style.pointerEvents = "none"; | ||
this.resize(); | ||
window.addEventListener("resize", this.resize.bind(this)); | ||
} | ||
start() { | ||
this.objects = []; | ||
requestAnimationFrame(this.animate.bind(this)); | ||
} | ||
addObjects() { | ||
var i = 0; | ||
do { | ||
i++; | ||
this.objects.push( | ||
new FallingObject(this.stageWidth, this.stageHeight, this.config) | ||
); | ||
} while (i <= this.config.frequency); | ||
} | ||
resize() { | ||
this.stageWidth = this.elem.clientWidth; | ||
this.stageHeight = this.elem.clientHeight; | ||
this.canvas.width = this.stageWidth * 2; | ||
this.canvas.height = this.stageHeight * 2; | ||
this.ctx.scale(2, 2); | ||
} | ||
render(t) { | ||
this.ctx.clearRect(0, 0, this.stageWidth, this.stageHeight); | ||
this.objects = this.objects.filter((obj) => obj.deleted != true); | ||
this.addObjects(); | ||
for (let i = 0; i < this.objects.length; i++) { | ||
if (this.objects[i].update() > this.stageHeight) { | ||
this.objects[i].deleted = true; | ||
} | ||
this.objects[i].render(this.ctx); | ||
} | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.