微信H5斗地主平台制作在Canvas画布上画文本的

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了微信H5斗地主平台制作在Canvas画布上画文本的相关的知识,希望对你有一定的参考价值。

微信H5斗地主平台制作Q:2172243813

必不可少的条件(h5.ttkmwl.com)在Canvas画布上画文本的

var Labels = Class.create();
$.extend(Labels.prototype, {
    initialize: function (cxt) {
        this.cxt = cxt;
    },
    setText: function (text, postion) {
        this.cxt.font = ‘bold 20px serif‘;
        this.cxt.fillStyle = ‘#000000‘;
        this.cxt.textAlign = ‘center‘;
        this.cxt.fillText(text, postion.x, postion.y);
    }
});

这个类的方法setText主要是根据设置的字体,字体大小,字体颜色,在Canvas上画文本的,this.cxt这个是canvas上下文(每个教程的叫法不一样),首先this.cxt.font = ‘bold 20px serif‘;这个是设置字体大小,样式等,this.cxt.fillStyle = ‘#000000‘;这个

是设置字体颜色,this.cxt.textAlign = ‘center‘;这个是设置字体对齐方式,this.cxt.fillText(text, postion.x, postion.y);这个是开始在canvas上画文本,postion.x, postion.y分别是x坐标和y坐标。

以上是关于微信H5斗地主平台制作在Canvas画布上画文本的的主要内容,如果未能解决你的问题,请参考以下文章