Skip to content

ibsenleo/pixelizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pixelizer

Script that pixelize a picture

Usage

HTML

Has to exists this html structure. (Could be created by code or static)

<!-- In this div, the image will be copied and readed -->
<div id="container" style="width:auto;height: auto;"></div>

<!-- In this div, the image will be loaded as pixelized SVG  -->
<div id="canvas-container">
  <img id="image" 
  src="./images/grito.jpg"
  alt="The Scream" 
  width="auto" 
  height="auto" 
  style="display:none;"/>
</div>

Javascript

$(document).ready(function(){
    //Creates the SVG Canvas
    var s = SVG("container")
    
    //Listen when image is ready
    $img = $('#image')
    $img.on('load', function(){
        console.log('LOADED')
        var r = new Reader("#image") //Reads the image and return the "map" of pixels
        var arr = r.read()
        var b = new Board(s, arr) //Load the map into the SVG
    })
    .each(function(){
        if(this.complete) {
          $(this).trigger('load');
        }
    });
    
})

About

Script that pixelize a picture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published