auto-sprites
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -106,3 +106,3 @@ var path = require('path'), | ||
next(); | ||
}); | ||
}); | ||
} | ||
@@ -109,0 +109,0 @@ |
@@ -1,18 +0,25 @@ | ||
var VerticalPacker = function(){ | ||
var DialonalPacker = function(){ | ||
}; | ||
//自下而上的拼图 | ||
VerticalPacker.prototype = { | ||
DialonalPacker.prototype = { | ||
//[w:10,h:10] | ||
fit:function(blocks){ | ||
var n, node, block, len = blocks.length; | ||
var w = len > 0 ? blocks[0].w : 0; | ||
var h = len > 0 ? blocks[0].h : 0; | ||
var n, block, len = blocks.length, prevBlock; | ||
// this.root = { x: 0, y: 0, w: w, h: h }; | ||
for (n = 0; n < len ; n++) { | ||
block = blocks[n]; | ||
if(!this.root){ | ||
this.root = {x:0,y:0,w:block.w,h:block.h}; | ||
this.root = { | ||
x:0, | ||
y:0, | ||
w:block.w, | ||
h:block.h | ||
}; | ||
block.fit = this.root; | ||
@@ -23,7 +30,7 @@ }else{ | ||
y:0, | ||
w:this.root.w+Math.abs(this.root.w-block.w), | ||
h:this.root.h+block.h, | ||
down:{ | ||
x:0, | ||
y:this.root.h, | ||
w:block.w+this.root.w, | ||
h:block.h+this.root.h, | ||
rightTop:{ | ||
x:this.root.w, | ||
y:0, | ||
w:block.w, | ||
@@ -33,4 +40,12 @@ h:block.h | ||
} | ||
block.fit = this.root.down; | ||
block.fit = this.root.rightTop; | ||
} | ||
for(var j=0;j<n;j++){ | ||
prevBlock = blocks[j]; | ||
if(prevBlock.fit){ | ||
prevBlock.fit.y += block.h; | ||
} | ||
} | ||
} | ||
@@ -40,2 +55,2 @@ } | ||
module.exports = VerticalPacker; | ||
module.exports = DialonalPacker; |
@@ -18,3 +18,3 @@ var pegasus = require('pegasus'), | ||
console.log(req.path); | ||
this.autoSprites = new AutoSprites({ | ||
@@ -21,0 +21,0 @@ data:res.body('utf-8'), |
var util = require('pegasus').util, | ||
path = require('path'), | ||
im = require('./image-magick'), | ||
gd = require('node-gd'), | ||
@@ -132,2 +132,3 @@ fs = require('fs'), | ||
createPng: function (w, h) { | ||
var img = gd.createTrueColor(w, h); | ||
@@ -176,6 +177,8 @@ if (img) { | ||
item = result[key]; | ||
if (item.imageMeta && item.imageMeta.hasDraw) { | ||
hasDrawImages.push(item); | ||
} else { | ||
newDrawImages.push(item); | ||
if(item.imageMeta){ | ||
if (item.imageMeta.hasDraw) { | ||
hasDrawImages.push(item); | ||
} else { | ||
newDrawImages.push(item); | ||
} | ||
} | ||
@@ -234,2 +237,7 @@ } | ||
(position[1] - style.fit.y) + 'px', ''); | ||
//合并样式 替换成background的形式 | ||
rule.removeProperty('background-layout'); | ||
}); | ||
@@ -236,0 +244,0 @@ } |
{ | ||
"name": "auto-sprites", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "一个用于天马的自动合并图片的模块", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,5 +13,20 @@ var util = require('pegasus').util, | ||
{ | ||
reg:/\?diagonal/, | ||
callback:function(result){ | ||
result['background-layout'] = 'diagonal'; | ||
} | ||
}, | ||
{ | ||
reg: /(url\(['"]?.*?['"]?\))/, | ||
callback: function (result, match) { | ||
result['background-image'] = match[0]; | ||
//去除时间戳等其他标识 | ||
var timeStampReg = /(\?.*)\)$/, | ||
timeStampMatch = match[0].match(timeStampReg); | ||
if(timeStampMatch) { | ||
result['background-image'] = match[0].replace(timeStampMatch[1],''); | ||
}else{ | ||
result['background-image'] = match[0]; | ||
} | ||
} | ||
@@ -18,0 +33,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
5
0
28137
11
791