modify gap
This commit is contained in:
parent
27a0bb9e66
commit
434bb974a6
@ -55,7 +55,7 @@ define(
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置坐标信参数
|
* 设置坐标参数
|
||||||
*
|
*
|
||||||
* @param {Object} options 坐标选项
|
* @param {Object} options 坐标选项
|
||||||
* @see editor/options
|
* @see editor/options
|
||||||
@ -68,9 +68,9 @@ define(
|
|||||||
lang.overwrite(this.options.axis, options);
|
lang.overwrite(this.options.axis, options);
|
||||||
|
|
||||||
// 设置gap
|
// 设置gap
|
||||||
this.options.axis.graduation.gap = options.graduation && options.graduation.gap
|
if (options.graduation && options.graduation.gap) {
|
||||||
? options.graduation.gap
|
this.options.axis.graduation.gap = options.graduation.gap
|
||||||
: this.options.unitsPerEm / 512 * 100;
|
}
|
||||||
|
|
||||||
// 设置当前的axis
|
// 设置当前的axis
|
||||||
var axisOpt = lang.clone(this.options.axis);
|
var axisOpt = lang.clone(this.options.axis);
|
||||||
|
@ -192,9 +192,8 @@ define(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示
|
* 显示
|
||||||
* @param {Object} font font对象
|
|
||||||
*/
|
*/
|
||||||
GLYFEditor.prototype.show = function (font) {
|
GLYFEditor.prototype.show = function () {
|
||||||
// 这里注意显示顺序,否则editor创建的时候计算宽度会错误
|
// 这里注意显示顺序,否则editor创建的时候计算宽度会错误
|
||||||
this.main.show();
|
this.main.show();
|
||||||
|
|
||||||
@ -203,11 +202,6 @@ define(
|
|||||||
bindEditor.call(this);
|
bindEditor.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (font) {
|
|
||||||
this.editor.setFont(font);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.editor.refresh();
|
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -192,9 +192,8 @@ define(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示
|
* 显示
|
||||||
* @param {Object} font font对象
|
|
||||||
*/
|
*/
|
||||||
GLYFEditor.prototype.show = function (font) {
|
GLYFEditor.prototype.show = function () {
|
||||||
// 这里注意显示顺序,否则editor创建的时候计算宽度会错误
|
// 这里注意显示顺序,否则editor创建的时候计算宽度会错误
|
||||||
this.main.show();
|
this.main.show();
|
||||||
|
|
||||||
@ -203,11 +202,6 @@ define(
|
|||||||
bindEditor.call(this);
|
bindEditor.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (font) {
|
|
||||||
this.editor.setFont(font);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.editor.refresh();
|
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,12 +45,9 @@ define(
|
|||||||
|
|
||||||
draw: function (ctx, shape, camera) {
|
draw: function (ctx, shape, camera) {
|
||||||
|
|
||||||
shape.gap = (shape.graduation.gap || 100) * camera.scale;
|
shape.scale = camera.scale;
|
||||||
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
|
|
||||||
drawAxis(ctx, shape);
|
drawAxis(ctx, shape);
|
||||||
|
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,14 @@ define(
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
draw: function (ctx, shape) {
|
draw: function (ctx, shape, camera) {
|
||||||
|
|
||||||
|
shape.scale = camera.scale;
|
||||||
ctx.save();
|
ctx.save();
|
||||||
|
|
||||||
// 绘制刻度线
|
// 绘制刻度线
|
||||||
drawGraduation(ctx, shape.config);
|
drawGraduation(ctx, shape.config);
|
||||||
|
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
function drawAxis(ctx, config) {
|
function drawAxis(ctx, config) {
|
||||||
|
|
||||||
var gap = Math.round(config.gap);
|
var gap = Math.round(config.graduation.gap * config.scale);
|
||||||
var xMax = Math.round(ctx.canvas.width + gap);
|
var xMax = Math.round(ctx.canvas.width + gap);
|
||||||
var yMax = Math.round(ctx.canvas.height + gap);
|
var yMax = Math.round(ctx.canvas.height + gap);
|
||||||
var x = Math.round(config.x);
|
var x = Math.round(config.x);
|
||||||
|
@ -43,20 +43,21 @@ define(
|
|||||||
|
|
||||||
|
|
||||||
var originGap = config.graduation.gap;
|
var originGap = config.graduation.gap;
|
||||||
|
var curGap = config.graduation.gap * config.scale;
|
||||||
var scale;
|
var scale;
|
||||||
var gap;
|
var gap;
|
||||||
var markSize;
|
var markSize;
|
||||||
var axis;
|
var axis;
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
if (originGap >= config.gap) {
|
if (originGap >= curGap) {
|
||||||
scale = originGap / config.gap;
|
scale = originGap / curGap;
|
||||||
gap = Math.floor(scale) * originGap / 20; // 每个格子大小
|
gap = Math.floor(scale) * originGap / 20; // 每个格子大小
|
||||||
markSize = originGap / 20 * Math.floor(scale) / scale;
|
markSize = originGap / 20 * Math.floor(scale) / scale;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
scale = config.gap / originGap;
|
scale = curGap / originGap;
|
||||||
gap = Math.floor(originGap / 20 / scale); // 每个格子大小, 5的倍数
|
gap = Math.floor(originGap / 20 / scale); // 每个格子大小, 5的倍数
|
||||||
|
|
||||||
if (gap >= 2) {
|
if (gap >= 2) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user