Code Monkey home page Code Monkey logo

pict2pix's Introduction

Pict2Pix.js

Last release Languages License Author

Pict2Pix.js is a creative coding library to apply fancy pixel animations to images.

Screenshot example

Get started with Pict2Pix

Setting up a basic skeleton

To get started with Pict2Pix.js library, follow the next steps:

  • Include the prict2pix.min.js file.
<script src="https://cdn.jsdelivr.net/gh/evaristocuesta/[email protected]/dist/pict2pix.min.js"></script>
  • Place an image inside a container because the library will replace the image by a canvas.
<div id="div1">
    <img id="image-jh" src="images/jimi-hendrix.jpg">
</div>
  • Get the image element and call to pict2pix.animate function.
const image = document.getElementById('image-jh');
window.onload = function initialize() {
    pict2pix.animate({
        image: image,
        numberOfParticles: 800,
        horizontalSpeed: 1,
        verticalSpeed: -1,
        particleType: 'twisted-particle'
    });
}

Full basic skeleton code

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" media="screen" href="css/style.css"/>
</head>
<body>
    <div id="div1">
        <img id="image-jh" src="images/jimi-hendrix.jpg">
    </div>
    <script src="https://cdn.jsdelivr.net/gh/evaristocuesta/[email protected]/dist/pict2pix.min.js"></script>
    <script src="js/app.js"></script>
</body>
</html>

JavaScript

const image = document.getElementById('image-jh');
window.onload = function initialize() {
    pict2pix.animate({
        image: image,
        numberOfParticles: 800,
        horizontalSpeed: 1,
        verticalSpeed: -1,
        particleType: 'twisted-particle'
    });
}

Take a look at https://evaristocuesta.github.io/pict2pix/ for more examples code.

Contributors

pict2pix's People

Contributors

evaristocuesta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pict2pix's Issues

The library throws an error when the image variable passed to the config is not called image

const imagejh = document.getElementById('image-jh');
window.onload = function initialize() {
    pict2pix.animate({
        image: imagejh,
        numberOfParticles: 3000,
        horizontalSpeed: -1,
        verticalSpeed: -1,
        particleType: 'twisted-particle'
    });
}

This code throws an error because the variable passed to image is called imagejh. It only works when the image variable is called image.

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.