html5 canvas 绘制上下浮动的字体
来源:互联网 发布:菜鸟商城服务器源码 编辑:程序博客网 时间:2024/06/09 19:56
绘制上下浮动的字体主要思想为先绘制好需要的字体,每隔一定的时间将画布清空,然后再将字体位置改变再绘制上去 如此循环即可。
(function(window) {
var flowLogo = function(logo, x, font) {
this.logo = logo;
this.x = x;
this.font = font || "25px Verdana";
}
flowLogo.prototype.flow = function(start, min, max, increment, time, container) {
var logo = this.logo;
container.font = this.font;
var x = this.x;
var logoWidth = container.measureText(logo).width;
container.strokeStyle = "white";
var forward = true;
var changeInterval = setInterval(function() {
container.clearRect(x, 0, logoWidth, max + 10);
container.strokeText(logo, x, start, logoWidth, 20);
if (forward) {
start += increment;
} else {
start -= increment;
}
if (start < min || start > max) {
forward = !forward;
}
}, time);
storage.changeInterval = changeInterval;
}
window.flowLogo = flowLogo;
})(window);
使用方式:
var logo = new flowLogo(text, left);
logo.flow(40, 40, 60, 2, 150, t);
- html5 canvas 绘制上下浮动的字体
- html5 canvas 绘制上下浮动的字体
- html5 canvas元素字体绘制
- 使用 HTML5 canvas 绘制精美的图形
- html5 canvas绘制图片模糊的问题
- 使用 HTML5 canvas 绘制精美的图形
- html5-canvas的绘制文本自动换行
- HTML5 canvas 绘制的文字如何换行?
- html5 canvas元素各种矩形的绘制
- html5 canvas元素扇形的绘制
- html5 canvas绘制图片模糊的问题
- html5的canvas绘制迷宫地图
- 【Html5】canvas绘制圆形
- html5 canvas 绘制钟表
- HTML5 Canvas: 绘制矩形
- HTML5 canvas 绘制圆形
- html5 canvas绘制路径
- HTML5 Canvas 绘制图像
- 程序员的美:极致与疯狂
- maven常见问题问答
- 【综合】设计师为什么要学编程,开发者为什么要学设计?
- apache 整合 tomcat
- Java枚举的七种常见用法
- html5 canvas 绘制上下浮动的字体
- 将博客搬至CSDN
- ARM的系统模式(system mode)
- string基本字符系列容器(二)
- android中ExpandableListView增加自定义组件
- c语言问题求解答
- 无人驾驶不是梦?CES上海大会探讨未来
- CSI-VII:存储器层次结构-神秘“金字塔”
- RabbitMQ C++客户端 RabbitMQ Client for Windows/Linux 超简单接收发送接口