Skip to content

Instantly share code, notes, and snippets.

View anuraghazra's full-sized avatar
:electron:
Learning

Anurag Hazra anuraghazra

:electron:
Learning
View GitHub Profile
@anuraghazra
anuraghazra / index.html
Created November 5, 2018 11:47
Long shadow
<canvas id="canvas"></canvas>
@anuraghazra
anuraghazra / variableBinding.js
Created November 23, 2018 06:28
Calling a variable inside of a function like a global variable but without polluting the global scope.
// Calling a variable inside of a function
// like a global variable but without polluting the global scope.
// main function
function setup() {
console.log(ADD);
console.log(SUB);
console.log(sum(100,50))
}
// init the variables in another function (you can hide the function in an external js file)
@anuraghazra
anuraghazra / license-badges.md
Created December 11, 2018 12:08 — forked from lukas-h/license-badges.md
Markdown License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file.
This list includes the most common open source and open data licenses.
Easily copy and paste the code under the badges into your Markdown files.

Notes

@anuraghazra
anuraghazra / HappyHoli.js
Created March 21, 2019 15:23
Happy Holi 2019 | Brackets
// Happy Holi 2019
// BY ANURAG HAZRA
{{{{}}}} {{{{}}}} {{{{}}}}{{{{}}}} {{{{}}}}{{{{}}}}{{{{}}}} {{{{}}}}{{{{}}}}{{{{}}}} {{{{}}}} {{{{}}}}
{{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}}
{{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}}
{{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}}{{{{}}}}
{{{{}}}}{{{{}}}}{{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}}
{{{{}}}}{{{{}}}}{{{{}}}} {{{{}}}} {{{{}}}}{{{{}}}} {{{{}}}} {{{{}}}}{{{{}}}}{{{{}}}} {{{{}}}}{{{{}}}}{{{{}}}} {{{{}}}}
{{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}} {{{{}}}}
@anuraghazra
anuraghazra / Exclude-node_modules.md
Last active January 9, 2024 20:00
Exclude node_modules folder when copying directory.

Handy Trick To Get Rid Of node_modules

This one is a simple and handy trick when you want to copy your directories without node_modules folder.

Enter this command in your terminal.

robocopy SOURCE DEST /mir /xd node_modules
class Dot {
constructor(x, y) {
this.pos = new Vector(x, y);
this.oldpos = new Vector(x, y);
this.friction = 0.97;
this.groundFriction = 0.7;
this.gravity = new Vector(0, 1);
update() {
let vel = Vector.sub(this.pos, this.oldpos);
vel.mult(this.friction);
// if the point touches the ground set groundFriction
if (this.pos.y >= CANVAS_HEIGHT - this.radius && vel.magSq() > 0.000001) {
var m = vel.mag();
vel.x /= m;
vel.y /= m;
vel.mult(m * this.groundFriction);
@anuraghazra
anuraghazra / Dot.js
Created May 16, 2019 12:23
Rendering the dots.
render() {
ctx.beginPath();
ctx.fillStyle = this.color;
ctx.arc(this.pos.x, this.pos.y, this.radius, 0, Math.PI * 2);
ctx.fill();
ctx.closePath();
}
constrain() {
if (this.pos.x > CANVAS_WIDTH - this.radius) {
this.pos.x = CANVAS_WIDTH - this.radius;
}
if (this.pos.x < this.radius) {
this.pos.x = this.radius;
}
if (this.pos.y > CANVAS_HEIGHT - this.radius) {
this.pos.y = CANVAS_HEIGHT - this.radius;
}
constrain() {
if (this.pos.x > CANVAS_WIDTH - this.radius) {
this.pos.x = CANVAS_WIDTH - this.radius;
}
if (this.pos.x < this.radius) {
this.pos.x = this.radius;
}
if (this.pos.y > CANVAS_HEIGHT - this.radius) {
this.pos.y = CANVAS_HEIGHT - this.radius;
}