Skip to content

devdynam0507/funny-js-effect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Javascript Particle!

Look at the particles with physics applied! it tracks your mouse

Supported Effects

  • Water drop effect
  • Parabola Effect
  • Rainbow color

Create Particle Provider

import { ParticleProvider } from "./animation/animation.js";

// You need to pass the html cavans id to use to the provider.
let provider = new ParticleProvider('canvas');
provider.init();

Create Shape Example

import { Parabola, createParabolaEffect } from "./parabola.js";
import Circle from "./shapes/circle.js";

// Define a function that creates a particle. It takes x and y as arguments.
let circle = (x, y) => {
    let attribute = new ShapeAttribute(); // If you do not put a color in the constructor, it is automatically assigned as a rainbow color. You can enter the color as a string.
    let shape = new Circle(2, x ,y , attribute);
    shape.attachEffect(createParabolaEffect());

    return shape;
}

Enable Event listener

import { OnMouseTracingListener, OnMouseClickListener } from "./listener/animation-listner.js";
import { Parabola, createParabolaEffect } from "./parabola.js";

let provider = new ParticleProvider('canvas');
provider.init();

let circle = (x, y) => {
    let attribute = new ShapeAttribute(); // If you do not put a color in the constructor, it is automatically assigned as a rainbow color. You can enter the color as a string.
    let shape = new Circle(2, x ,y , attribute);
    shape.attachEffect(createParabolaEffect());

    return shape;
}

let mouseTrackingListener = new OnMouseTrackerListener(
    provider.defaultObserver, circle
);

let mouseClickListener = new OnMouseClickListener(
    provider.defaultObserver, circle
);

// listning
mouseTrackingListener.listen();
mouseClickListener.listen();

// dispose listener
mouseTrackingListener.dispose();
mouseClickListener.dispose();

Water drop effect

ezgif com-gif-maker

Parabola

ezgif com-gif-maker

About

funny/cute javascript particle effect

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published