From d40ead750c6d9476ea66d4f5aa283932e66e28f4 Mon Sep 17 00:00:00 2001 From: ZTF666 Date: Thu, 25 Jun 2020 12:48:28 +0100 Subject: [PATCH] :neckbeard: :computer: --- .gitignore | 2 -- README.md | 2 +- canvatrix.js | 26 ++++++++++++++++++++++++++ package.json | 25 +++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 canvatrix.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore index b707e27..dcaf716 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ index.html -canvatrix.js -package.json \ No newline at end of file diff --git a/README.md b/README.md index 6b5d813..79055a5 100644 --- a/README.md +++ b/README.md @@ -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); ``` diff --git a/canvatrix.js b/canvatrix.js new file mode 100644 index 0000000..3530d4a --- /dev/null +++ b/canvatrix.js @@ -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; diff --git a/package.json b/package.json new file mode 100644 index 0000000..7cc4cb9 --- /dev/null +++ b/package.json @@ -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" +} \ No newline at end of file