-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactiveObject_Text.js
More file actions
31 lines (30 loc) · 1.02 KB
/
Copy pathactiveObject_Text.js
File metadata and controls
31 lines (30 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function activeObject_Text (activeObject,text,textSize){
activeObject.text = text;
activeObject.textSize = textSize;
activeObject.showClickPlane = false;
activeObject.extendContext = function (){
var fontHeight = this.textSize;//px
this.setHeightAndLenght(this.TextWidth,fontHeight);
StageContext = this.Stage.context;
if ( this.showClickPlane ){
StageContext.fillStyle = '#f00';
StageContext.fillRect(this.PosX, this.PosY, this.height, this.width );
}
StageContext.fillStyle = this.fillColor;
StageContext.textBaseline = "top";
StageContext.font = fontHeight+"px sans-serif";
StageContext.fillText(this.text, this.PosX, this.PosY );
}
this.getTextLength = function (text,textSize) {
$('#tempElement').text(text);
$("#tempElement").css({
position: 'absolute',
visibility: 'hidden',
display: 'block',
fontSize: textSize,
fontFamily: 'sans-serif'
});
return $("#tempElement").width();
}
activeObject.TextWidth = this.getTextLength(text,textSize);
}