Skip to content

Commit

Permalink
:neckbeard: 💻
Browse files Browse the repository at this point in the history
  • Loading branch information
ZTF666 committed Jun 25, 2020
1 parent d334984 commit d40ead7
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
index.html
canvatrix.js
package.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $ npm i canvatrix
## Usage

```javascript
import { ZTF } from "canvatrix";
import { ZTF } from "canvatrix/canvatrix";

ZTF(YOUR_CANVAS_ID).matrix(SPEED, CANVAS_WIDTH, CANVAS_HEIGHT);
```
Expand Down
26 changes: 26 additions & 0 deletions canvatrix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function ZTF(selector) {
const self = {
el: document.querySelector(selector),
matrix: (speed, width, height) => {
// let s = window.screen

let letters = Array(256).join(1).split("");

function draw() {
self.el.getContext("2d").fillStyle = "rgba(0,0,0,.05)";
self.el.getContext("2d").fillRect(0, 0, width, height);
self.el.getContext("2d").fillStyle = "#0F0";
letters.map(function (y_pos, index) {
let text = String.fromCharCode(3e4 + Math.random() * 50);
let x_pos = index * 10;
self.el.getContext("2d").fillText(text, x_pos, y_pos);
letters[index] = y_pos > 758 + Math.random() * 1e4 ? 0 : y_pos + 10;
});
}
setInterval(draw, speed);
},
};
return self;
}

module.exports.ZTF = ZTF;
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "canvatrix",
"version": "1.0.1",
"description": "Turns your html canvas into fancy matrix like screens",
"main": "script.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ZTF666/CanvaTrix.git"
},
"keywords": [
"canvas",
"matrix",
"effect",
"javascript"
],
"author": "ZTF666",
"license": "MIT",
"bugs": {
"url": "https://github.com/ZTF666/CanvaTrix/issues"
},
"homepage": "https://github.com/ZTF666/CanvaTrix#readme"
}

0 comments on commit d40ead7

Please sign in to comment.