- 注册时间
- 2013-10-14
- 最后登录
- 2013-12-16
- 阅读权限
- 20
- 积分
- 132
- 精华
- 0
- 帖子
- 44
|
构造函数中添加
s.attachStroke = false;//填充并且描边。
s.attachStrokeColor = "#ffffff";
重写
show:function (){
var s = this,c = LGlobal.canvas;
if(!s.visible)return;
c.save();
c.font = s.weight + " " + s.size+"pt "+s.font;
c.textAlign = s.textAlign;
c.textBaseline = s.textBaseline;
c.lineWidth = s.lineWidth;
if(s.filters){
s.setShadow();
}
if(s.alpha < 1){
c.globalAlpha = s.alpha;
}
if(s.mask != null && s.mask.show){
s.mask.show();
c.clip();
}
if(s.blendMode){
c.globalCompositeOperation = s.blendMode;
}
s._transformScale();
s._transformRotate();
if(s.x != 0 || s.y != 0)c.transform(1,0,0,1,s.x,s.y);
if(s.texttype == LTextFieldType.INPUT){
if(s.x != 0 || s.y != 0){
s.inputBackLayer.show();
}
var rc = s.getRootCoordinate();
if(LGlobal.inputBox.name == "input"+s.objectIndex){
LGlobal.inputBox.style.marginTop = (rc.y) + "px";
LGlobal.inputBox.style.marginLeft = (rc.x) + "px";
}
}
var lbl = s.text;
if(s.displayAsPassword){
lbl = '';
for(var i=0,l=s.text.length;i<l;i++)lbl+='*';
}
var d;
var ds; // 专门描绘附加描边
if(s.stroke){
c.strokeStyle = s.color;
d = c.strokeText;
}else{
//附加描边
if(s.attachStroke){
ds = c.strokeText;
}
c.fillStyle = s.color;
d = c.fillText;
}
if(s.wordWrap){
var i,l,j=0,k=0,m=0;
for(i=0,l=s.text.length;i<l;i++){
j = c.measureText(s.text.substr(k,i-k)).width;
if(j > s.width){
j = 0;
k = i;
m++;
}
d.apply(c,[lbl.substr(i,1),j,m*s.wordHeight,c.measureText(lbl).width]);
if(ds instanceof Function){
c.strokeStyle = s.attachStrokeColor; //修改处
ds.apply(c,[lbl.substr(i,1),j,m*s.wordHeight,c.measureText(lbl).width]);
}
}
s.height = m*s.wordHeight;
}else{
d.apply(c,[lbl,0,0,c.measureText(lbl).width]);
if(ds instanceof Function){
c.strokeStyle = s.attachStrokeColor; //修改处
ds.apply(c,[lbl,0,0,c.measureText(lbl).width]);
}
}
if(s.wind_flag){
s.windRun();
}
c.restore();
}, |
|