Giter Site home page Giter Site logo

rc-review-group's People

Contributors

a-mozeak avatar

Watchers

 avatar  avatar

rc-review-group's Issues

First Review

https://lines.glitch.me/

let text = "GLITCH";
let canvas;
let ctx;
let w, h;
let imageBuffer;
let ticker;

function setup() {
  ticker = 0;
  canvas = document.querySelector("#canvas");
  ctx = canvas.getContext("2d");
  reset();
  window.addEventListener("resize", reset);
  document.querySelector("#text").addEventListener("input", input);
}

function reset() {
  w = canvas.width = window.innerWidth;
  h = canvas.height = window.innerHeight;
  initBufferFromText();
}

function input(event) {
  text = event.target.value;
  initBufferFromText();
}

function initBufferFromText() {
  clear();
  let fontSize = w * 0.2;
  ctx.font = "bold " + fontSize + "px Arial, Helvetica, sans-serif";
  ctx.textAlign = "center";
  ctx.textBaseline = "middle"
  ctx.fillText(text, w/2, h/2);
  let image = ctx.getImageData(0, 0, w, h);
  imageBuffer = new Uint32Array(image.data.buffer);
}

function draw() {
  ticker += 1;
  requestAnimationFrame(draw);
  clear();
  drawLines();
}

function clear() {
  ctx.clearRect(0, 0, w, h);
}

function drawLines() {
  let yDistance = 12;
  let yOffset = ticker % yDistance;
  for(let x = 0; x < w; x++) {
    for(let y = yOffset; y < h; y += yDistance) {
      let index = Math.round(y) * w + x;
      let color = imageBuffer[index];
      let height = 1;
      if (color) {
        height = 3;
      }
      ctx.fillRect(x, y, 1, height);
    }
  }
}

setup();
draw();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.