Skip to content

Instantly share code, notes, and snippets.

@mactive
Created September 13, 2012 08:40
Show Gist options
  • Save mactive/3712931 to your computer and use it in GitHub Desktop.
Save mactive/3712931 to your computer and use it in GitHub Desktop.
drawQuadrant
/*
* countPerLine 每行个数
* qWidth 象限宽度 qHeight 象限高度
* sHeihgt 象限间隔
* x1,y1 左上角 x2,y2 右上角
*/
File.prototype.drawQuadrant = function( countPerLine, qWidth, qHeight, sHeight){
var self = this;
countPerLine = countPerLine ? countPerLine : 4 ;
qWidth = qWidth ? qWidth : 150 ;
qHeight = qHeight ? qHeight : 150 ;
sHeight = sHeight ? sHeight : 220 ;
self.quadrant = [];
var countQuad = self.fileList.find('li[id^=file-id]').length;
for( i = 0; i < countQuad; i++){
var x1 = qWidth * ( i % countPerLine ) ;
var y1 = sHeight * parseInt( i / countPerLine ) ;
var x2 = x1 + qWidth ;
var y2 = y1 + qHeight ;
var tmp = {'index': i , 'x1':x1, 'y1':y1, 'x2':x2, 'y2':y2 };
self.quadrant.push(tmp);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment