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