src/video/texture.js
function (data) {
            var atlas = {};
            var image = data.image;
            var spacing = data.spacing || 0;
            var margin = data.margin || 0;

            var width = image.width;
            var height = image.height;

            // calculate the sprite count (line, col)
            var spritecount = me.pool.pull("me.Vector2d",
                ~~((width - margin + spacing) / (data.framewidth + spacing)),
                ~~((height - margin + spacing) / (data.frameheight + spacing))
            );

            // verifying the texture size
            if ((width % (data.framewidth + spacing)) !== 0 ||
                (height % (data.frameheight + spacing)) !== 0) {
                // "truncate size"
                width = spritecount.x * (data.framewidth + spacing);
                height = spritecount.y * (data.frameheight + spacing);
                // warning message
                console.warn(
                    "Spritesheet Texture for image: " + image.src +
                    " is not divisible by " + (data.framewidth + spacing) +
                    "x" + (data.frameheight + spacing) +
                    ", truncating effective size to " + width + "x" + height
                );
            }

            // build the local atlas
            for (var frame = 0, count = spritecount.x * spritecount.y; frame < count; frame++) {
                var name = "" + frame;
                atlas[name] = {
                    name        : name,
                    texture     : "default", // the source texture
                    offset      : new me.Vector2d(
                        margin + (spacing + data.framewidth) * (frame % spritecount.x),
                        margin + (spacing + data.frameheight) * ~~(frame / spritecount.x)
                    ),
                    anchorPoint : (data.anchorPoint || null),
                    trimmed     : false,
                    width       : data.framewidth,
                    height      : data.frameheight,
                    angle       : 0
                };
                this.addUvsMap(atlas, name, width, height);
            }

            me.pool.push(spritecount);

            return atlas;
        }
function (data) {
            var atlas = {};
            var image = data.image;
            var spacing = data.spacing || 0;
            var margin = data.margin || 0;

            var width = image.width;
            var height = image.height;

            // calculate the sprite count (line, col)
            var spritecount = me.pool.pull("me.Vector2d",
                ~~((width - margin + spacing) / (data.framewidth + spacing)),
                ~~((height - margin + spacing) / (data.frameheight + spacing))
            );

            // verifying the texture size
            if ((width % (data.framewidth + spacing)) !== 0 ||
                (height % (data.frameheight + spacing)) !== 0) {
                // "truncate size"
                width = spritecount.x * (data.framewidth + spacing);
                height = spritecount.y * (data.frameheight + spacing);
                // warning message
                console.warn(
                    "Spritesheet Texture for image: " + image.src +
                    " is not divisible by " + (data.framewidth + spacing) +
                    "x" + (data.frameheight + spacing) +
                    ", truncating effective size to " + width + "x" + height
                );
            }

            // build the local atlas
            for (var frame = 0, count = spritecount.x * spritecount.y; frame < count; frame++) {
                var name = "" + frame;
                atlas[name] = {
                    name        : name,
                    texture     : "default", // the source texture
                    offset      : new me.Vector2d(
                        margin + (spacing + data.framewidth) * (frame % spritecount.x),
                        margin + (spacing + data.frameheight) * ~~(frame / spritecount.x)
                    ),
                    anchorPoint : (data.anchorPoint || null),
                    trimmed     : false,
                    width       : data.framewidth,
                    height      : data.frameheight,
                    angle       : 0
                };
                this.addUvsMap(atlas, name, width, height);
            }

            me.pool.push(spritecount);

            return atlas;
        }
function ( data ) { var atlas = { } ; var image = data . image ; var spacing = data . spacing || 0 ; var margin = data . margin || 0 ; var width = image . width ; var height = image . height ; // calculate the sprite count (line, col) var spritecount = me . pool . pull ( "me.Vector2d" , ~ ~ ( ( width - margin + spacing ) / ( data . framewidth + spacing ) ) , ~ ~ ( ( height - margin + spacing ) / ( data . frameheight + spacing ) ) ) ; // verifying the texture size if ( ( width % ( data . framewidth + spacing ) ) !== 0 || ( height % ( data . frameheight + spacing ) ) !== 0 ) { // "truncate size" width = spritecount . x * ( data . framewidth + spacing ) ; height = spritecount . y * ( data . frameheight + spacing ) ; // warning message console . warn ( "Spritesheet Texture for image: " + image . src + " is not divisible by " + ( data . framewidth + spacing ) + "x" + ( data . frameheight + spacing ) + ", truncating effective size to " + width + "x" + height ) ; } // build the local atlas for ( var frame = 0 , count = spritecount . x * spritecount . y ; frame < count ; frame ++ ) { var name = "" + frame ; atlas [ name ] = { name : name , texture : "default" , // the source texture offset : new me . Vector2d ( margin + ( spacing + data . framewidth ) * ( frame % spritecount . x ) , margin + ( spacing + data . frameheight ) * ~ ~ ( frame / spritecount . x ) ) , anchorPoint : ( data . anchorPoint || null ) , trimmed : false , width : data . framewidth , height : data . frameheight , angle : 0 } ; this . addUvsMap ( atlas , name , width , height ) ; } me . pool . push ( spritecount ) ; return atlas ; }
build an atlas from the given spritesheet
@ignore
build an atlas from the given spritesheet