modify render comments

This commit is contained in:
kekee000 2014-12-25 23:22:17 +08:00
parent 287ef03a85
commit 8326083b5e
6 changed files with 60 additions and 25 deletions

View File

@ -18,6 +18,9 @@ define(
* 创建一个shape对象这里仅创建数据结构具体绘制由Shape对象完成
*
* @param {Object} options shape参数
* @param {string} options.id 编号
* @param {string} options.type 类型
*
* @return {Object} shape数据结构
*/
function createShape(options) {
@ -31,6 +34,9 @@ define(
/**
* 设置canvas的绘制样式
*
* @param {Canvas2D} context canvas context
* @param {Object} options 绘制参数
*/
function setContextStyle(context, options) {
context.fillStyle = options.fillColor || 'black';
@ -43,6 +49,14 @@ define(
* 层级基础对象
*
* @constructor
* @param {Canvas2D} context canvas context
* @param {Object} options 绘制参数
* @param {boolean} options.stroke 是否描边
* @param {boolean} options.fill 是否填充
* @param {boolean} options.thin 是否细线模式
* @param {Painter} options.painter 父级Painter对象
* @param {string} options.id 对象编号
* @param {number} options.level 层级
*/
function Layer(context, options) {
this.context = context;
@ -247,9 +261,7 @@ define(
* 获取当前坐标下的shape
*
* @param {Object} p 坐标值
*
*
* @return {Array} 选中的shapes
* @return {Array|boolean} 选中的shapes 或者false
*/
getShapeIn: function(p) {
var support = this.painter.support;
@ -268,7 +280,7 @@ define(
/**
* 根据镜头调整shape
*
* @param {Object|string|number} shape shape对象
* @return {this}
*/
adjust: function(shape) {
@ -304,7 +316,7 @@ define(
* 移动指定的偏移量
* @param {number} x 偏移
* @param {number} y 偏移
*
* @param {Object|string|number} shape shape对象
* @return {this}
*/
move: function(x, y, shape) {
@ -338,7 +350,7 @@ define(
*
* @param {number} x 偏移
* @param {number} y 偏移
*
* @param {Object|string|number} shape shape对象
* @return {this}
*/
moveTo: function(x, y, shape) {
@ -373,7 +385,7 @@ define(
/**
* 获取Layer bound
*
* @param {Array?} shape对象数组
* @return {Object} bound对象
*/
getBound: function(shapes) {
@ -397,7 +409,9 @@ define(
var bound = drawer.getRect(shape);
if (bound) {
boundPoints.push(bound);
boundPoints.push({x: bound.x + bound.width, y: bound.y + bound.height});
boundPoints.push(
{x: bound.x + bound.width, y: bound.y + bound.height}
);
}
}
}

View File

@ -20,7 +20,12 @@ define(
/**
* 创建一个canvas对象
*
* @param {Object} options 参数选项
* @param {string} options.id 编号
* @param {number} options.level 层级
* @param {number} options.width 宽度
* @param {number} options.height 高度
*
* @return {Canvas} canvas对象
*/
function createCanvas(options) {
@ -43,6 +48,11 @@ define(
/**
* 创建一个Layer对象
* @param {Object} options 参数选项
* @param {string} options.id 编号
* @param {number} options.level 层级
* @param {number} options.width 宽度
* @param {number} options.height 高度
*
* @return {Layer} Layer对象
*/
@ -63,6 +73,9 @@ define(
* 画布对象
*
* @constructor
* @param {HTMLElement} main 主元素
* @param {Object} options 参数选项
*
*/
function Painter(main, options){
this.main = main;
@ -76,6 +89,7 @@ define(
y: this.height /2
});
// 保存支持的shape类型
var support = {};
Object.keys(SupportShape).forEach(function(shape) {
support[shape] = new SupportShape[shape]();
@ -91,7 +105,7 @@ define(
* 增加一个支持的shape类型
*
* @param {Object} shape 支持类型
*
* @see ./shape/Shape
* @return {this}
*/
addSupport: function(shape) {
@ -116,7 +130,7 @@ define(
/**
* 根据编号或索引获取一个Layer
*
* @param {string|number} layer id或者layer index
* @param {Object|string|number} layer对象 或者layer id或者layer index
*
* @return {Layer} layer对象
*/
@ -138,7 +152,7 @@ define(
* 添加一个Layer
*
* @param {Layer|string} layer layer对象或者layer id
*
* @param {Object} options 参数
* @return {Layer?} layer对象
*/
addLayer: function(layer, options) {
@ -184,7 +198,7 @@ define(
throw 'need layer id to be removed';
}
if(id >=0 && id < this.layers.length) {
if(id >= 0 && id < this.layers.length) {
layer = this.layers[id];
layer.dispose();
// 移除canvas
@ -199,8 +213,9 @@ define(
/**
* 获取当前坐标下的shape
*
* @param {string} p [p description]
*
* @param {Object} p 坐标对象
* @param {number} p.x 坐标对象
* @param {number} p.y 坐标对象
* @return {Array} 选中的shape
*/
getShapeIn: function(p) {
@ -218,7 +233,7 @@ define(
/**
* 根据镜头调整坐标
*
* @param {Layer} layerId
* @param {Object|number|string} layerId layer对象
*
* @return {this}
*/
@ -245,7 +260,7 @@ define(
*
* @param {number} x 偏移
* @param {number} y 偏移
* @param {Layer} layerId
* @param {Object|number|string} layerId layer对象
*
* @return {this}
*/
@ -273,7 +288,7 @@ define(
*
* @param {number} x 偏移
* @param {number} y 偏移
* @param {Layer} layerId
* {Object|number|string} layerId layer对象
*
* @return {this}
*/

View File

@ -78,7 +78,7 @@ define(
if(this.options.enableResize) {
this.resizeCapture = new ResizeCapture(this.main);
this.resizeCapture.on('resize', function(e) {
// 对象被隐藏, 不做处理
// 对象被隐藏不做处理仅作标记refresh之后再处理
if (me.main.style.display === 'none') {
me.hasResized = true;
return;
@ -100,8 +100,14 @@ define(
/**
* Render 构造函数
*
* @constructor
* @param {HTMLElement} main 主元素
* @param {Object} options 参数选项
* @param {number} options.defaultRatio 默认的缩放比例
* @param {number} options.minScale 最小缩放
* @param {number} options.maxScale 最大缩放
* @param {boolean} options.enableScale 是否允许缩放
* @param {boolean} options.enableResize 是否允许大小改变
* @constructor
*/
function Render(main, options) {

View File

@ -16,7 +16,7 @@ define(
* 创建一个render
* @param {HTMLElement} main 主控区域
* @param {Object} options 创建参数
* @param {Controller} controller 控制器函数
* @param {Controller} options.controller 控制器
* @return {Render} render对象
*/
exports.create = function(main, options) {
@ -30,7 +30,6 @@ define(
controller = new Controller();
}
controller.setRender(render);
return render;

View File

@ -3,11 +3,10 @@
* @author mengke01
* @date
* @description
* unicode 编码名字
* unicode 编码与postName对照
*
* see:
* http://www.microsoft.com/typography/otspec/WGL4.htm
* test
*/

View File

@ -25,7 +25,9 @@ define(
if (u < 0x20) {
return '';
}
return u >= 0x20 && u <= 255 ? string.encodeHTML(String.fromCharCode(u).toLowerCase()) : '&#x' + u.toString(16) + ';';
return u >= 0x20 && u <= 255
? string.encodeHTML(String.fromCharCode(u).toLowerCase())
: '&#x' + u.toString(16) + ';';
}).join('');
}