Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

atlaspack

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atlaspack - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

31

index.js

@@ -38,2 +38,3 @@ /*

this._cache = [];
this._uvcache = Object.create(null);
}

@@ -51,2 +52,3 @@ module.exports = function() {

this._cache = [];
this._uvcache = [];
rect = this._toRect(rect);

@@ -127,2 +129,31 @@ if (this.left !== null) {

Atlas.prototype.uv = function() {
var self = this;
if (self._uvcache.length > 0) {
return self._uvcache;
}
(function loop(atlas) {
if (atlas.left !== null) {
loop(atlas.left);
loop(atlas.right);
} else if (atlas.rect.name) {
self._uvcache[atlas.rect.name] = [
[atlas.rect.x, atlas.rect.y],
[atlas.rect.x + atlas.rect.w, atlas.rect.y],
[atlas.rect.x + atlas.rect.w, atlas.rect.y + atlas.rect.h],
[atlas.rect.x, atlas.rect.y + atlas.rect.h],
].map(function(uv) {
if (uv[0] !== 0) {
uv[0] = uv[0] / self.rect.w;
}
if (uv[1] !== 0) {
uv[1] = uv[1] / self.rect.h;
}
return uv;
});
}
}(self));
return self._uvcache;
};
// if has an image and canvas, draw to the canvas as we go

@@ -129,0 +160,0 @@ Atlas.prototype._ontoCanvas = function(node) {

2

package.json
{
"name": "atlaspack",
"description": "Pack rectangles (or images) into a rectangle (or canvas texture atlas).",
"version": "0.2.0",
"version": "0.2.1",
"homepage": "https://github.com/shama/atlaspack",

@@ -6,0 +6,0 @@ "author": {

@@ -127,2 +127,14 @@ # atlaspack

#### `atlas.uv()`
Returns an object with rect names as keys containing an array of UV mapping
coordinates between 0-1 with TRBL:
```js
var uvmap = atlas.uv();
/* {
TOP RIGHT BOTTOM LEFT
'name': [ [0,0], [1,0], [1,1], [0,1] ],
} */
```
### `atlaspack.Rect(x, y, w, h)`

@@ -145,2 +157,3 @@ Creates a rectangle instance.

## release history
* 0.2.1 - Add uv method for uv coordinates.
* 0.2.0 - Add expand and index methods.

@@ -147,0 +160,0 @@ * 0.1.0 - initial release

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc