{"size": 1143, "ext": "js", "max_stars_repo_path": "src/renderer.js", "max_stars_repo_name": "ADVENCHER4/RainyLofi", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/renderer.js", "max_issues_repo_name": "ADVENCHER4/RainyLofi", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/renderer.js", "max_forks_repo_name": "ADVENCHER4/RainyLofi", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.8780487805, "max_line_length": 79, "alphanum_fraction": 0.5704286964}
import { Rain } from "./rain.js";
import { settings } from "./values.js";

var rain = new Rain();
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");

function clear() {
    ctx.clearRect(0, 0, window.innerWidth, window.innerHeight);
}
export function initCanvas() {
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    ctx.strokeStyle = settings["color"];
    ctx.lineWidth = settings["width"];

}
export function redrawRain() {
    clear();
    for (var i = 0; i < rain.drops.length; i++) {
        var drop = rain.drops[i];
        var offset = drop.length * Math.tan(settings["angle"] * Math.PI / 180);
        ctx.beginPath();
        ctx.moveTo(drop.x, drop.y);
        ctx.lineTo(drop.x + offset, drop.y + drop.length);
        ctx.stroke();
        drop.y += drop.speed;
        drop.x += offset /drop.speed;
        if (drop.x < 0) {
            drop.x += canvas.width;
        } else if (drop.x > canvas.width) {
            drop.x -= canvas.width;
        }
        if (drop.y >= canvas.height) {
            rain.deleteDrop(i);
        }

    }
    rain.createDrops();
}
