Giter Site home page Giter Site logo

fzliweiliang / photomosaic.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ritz078/photomosaic.js

0.0 1.0 0.0 1.62 MB

A pure JavaScript plugin to create a mosaic of an image.

Home Page: http://riteshkr.com/photomosaic.js

JavaScript 94.54% HTML 5.46%

photomosaic.js's Introduction

photomosaic.js Travis

A javascript plugin that creates a photomosaic of an image. Demo is available here.

Screen

Getting started

Install via npm npm install photomosaic.js

Install via bower bower install photomosaic.js

Or Load the file manually

<script src="path/to/photomosaic.js"></script>

Basic Usage

The minimum set of options required to use this plugin are as follows.

var photomosaic = new PhotoMosaic({
  image         : document.getElementById('image'),
  targetElement : document.getElementById('target'),
  width         : 500,
  height        : 500
})

Advanced Options

Option Default Value Description
image null [Mandatory] Image element selector
targetElement null [Mandatory] Target element selector
tileWidth 5 The tile division width for creating mosaic (in px)
tileHeight 5 The tile division height for creating mosaic (in px)
tileShape ‘circle' The shape of the tiles (circle or rectangle)
opacity 1 Opacity of the resulting image
width null [Mandatory] Width of the resulting image
height null [Mandatory] Height of the resulting image
defaultBackground 'rgba(0, 0, 0, 0' Default background to optimize result for png or other image with opacity

Example

var photomosaic = new PhotoMosaic({
  image         : document.getElementById('image'),
  targetElement : document.getElementById('target'),
  width         : 500,
  height        : 500,
  tileHeight    : 16,
  tileWidth     : 16,
  tileShape     : 'rectangle',
  opacity       : 0.5
})

Contributing

  1. Fork and clone the repo.
  2. Run npm install to install all build dependencies(including Grunt).
  3. Create a new branch, please DON'T work in your master branch directly.
  4. Fix stuff or add new feature.
  5. This repo follows Angular commit guidelines. For this we are using commitizen. So instead of git commit, prefer using npm run commit and everything will be automatically done.
  6. Update the documentation to reflect any changes.
  7. Push to your fork and submit a pull request.

License

MIT © Ritesh Kumar

photomosaic.js's People

Contributors

ritz078 avatar greenkeeperio-bot avatar mondogao avatar

Watchers

James Cloos avatar

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.