Merge branch 'YoruNoHikage-master'

This commit is contained in:
Лаврёнов Антон
2014-08-21 07:51:17 +08:00
2 changed files with 28 additions and 15 deletions

View File

@@ -184,7 +184,7 @@
pointerDirection = this.getPointerDirection(),
pointerWidth = this.getPointerWidth(),
pointerHeight = this.getPointerHeight();
//cornerRadius = this.getCornerRadius();
cornerRadius = this.getCornerRadius();
context.beginPath();
context.moveTo(0,0);
@@ -195,29 +195,49 @@
context.lineTo((width + pointerWidth)/2, 0);
}
context.lineTo(width, 0);
if(!cornerRadius) {
context.lineTo(width, 0);
} else {
context.lineTo(width - cornerRadius, 0);
context.arc(width - cornerRadius, cornerRadius, cornerRadius, Math.PI * 3 / 2, 0, false);
}
if (pointerDirection === RIGHT) {
context.lineTo(width, (height - pointerHeight)/2);
context.lineTo(width + pointerWidth, height/2);
context.lineTo(width, (height + pointerHeight)/2);
}
context.lineTo(width, height);
if(!cornerRadius) {
context.lineTo(width, height);
} else {
context.lineTo(width, height - cornerRadius);
context.arc(width - cornerRadius, height - cornerRadius, cornerRadius, 0, Math.PI / 2, false);
}
if (pointerDirection === DOWN) {
context.lineTo((width + pointerWidth)/2, height);
context.lineTo(width/2, height + pointerHeight);
context.lineTo((width - pointerWidth)/2, height);
}
context.lineTo(0, height);
if(!cornerRadius) {
context.lineTo(0, height);
} else {
context.lineTo(cornerRadius, height);
context.arc(cornerRadius, height - cornerRadius, cornerRadius, Math.PI / 2, Math.PI, false);
}
if (pointerDirection === LEFT) {
context.lineTo(0, (height + pointerHeight)/2);
context.lineTo(-1 * pointerWidth, height/2);
context.lineTo(0, (height - pointerHeight)/2);
}
if(cornerRadius) {
context.lineTo(0, cornerRadius);
context.arc(cornerRadius, cornerRadius, cornerRadius, Math.PI, Math.PI * 3 / 2, false);
}
context.closePath();
context.fillStrokeShape(this);

View File

@@ -40,12 +40,8 @@ suite('Label', function() {
stage.add(layer);
var beforeTextWidth = label.getText().getWidth();
label.getText().setFontSize(100);
var afterTextWidth = label.getText().getWidth();
label.getText().setFontSize(50);
label.getText().setText('Hello big world');
@@ -56,13 +52,10 @@ suite('Label', function() {
assert.equal(label.getType(), 'Group');
assert.equal(label.getClassName(), 'Label');
var json = label.toJSON();
//console.log(json);
// use relaxed trace because text can be a slightly different size in different browsers,
// resulting in slightly different tag dimensions
var relaxedTrace = layer.getContext().getTrace(true);
//console.log(relaxedTrace);
assert.equal(relaxedTrace, 'clearRect();save();save();globalAlpha;shadowColor;shadowBlur;shadowOffsetX;shadowOffsetY;drawImage();restore();drawImage();restore();save();transform();font;textBaseline;textAlign;save();translate();translate();save();fillStyle;fillText();restore();translate();restore();restore();clearRect();save();save();globalAlpha;shadowColor;shadowBlur;shadowOffsetX;shadowOffsetY;drawImage();restore();drawImage();restore();save();transform();font;textBaseline;textAlign;save();translate();translate();save();fillStyle;fillText();restore();translate();restore();restore();');
@@ -87,7 +80,7 @@ suite('Label', function() {
var label = new Kinetic.Label({
x: 100,
y: 100,
y: 100
});
// add a tag to the label