如何在javascript中从canvas中删除文本 [英] how to remove text from canvas in javascript

查看:141
本文介绍了如何在javascript中从canvas中删除文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,当我点击按钮时,调用的callfunction()方法和计数器增加5,当我再次点击计数器增加5并在给定位置显示10我的问题是当计数器增加之前数字未被删除并在前一个数字上显示增加的数字。我想删除以前的数字并显示下一个增加的数字。我有以下代码

my problem is that when i am clicking on button, callfunction() method called and counter is incremented by 5, when i am again click counter incremented by 5 and displayed 10 on given location my problem is that when counter is incremented previous number is not erased and displayed incremented number on previous number.I want to remove previous number and display next incremented number. i have following code

var count=0;
function callfunction()
   {
         context.fillText(count,200,200);
         count = count+5;
         //context.fillText("",200,200);
   }


推荐答案

fillText 带背景颜色,如果它是单色的。或者保留之前的图像数据,然后在要删除文本时粘贴它。

fillText with background colour, if it's monochromatic. Or preserve what was there before as image data, then paste it over later when you want to erase the text.

这篇关于如何在javascript中从canvas中删除文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆