HTML5 画布文本编辑 [英] HTML5 Canvas Text Edit

查看:22
本文介绍了HTML5 画布文本编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 HTML5 画布中使用 fillText(); 填充了一个文本如何使其可编辑并将值读入变量?文本必须在画布内,因为它会写在一些复杂的多边形内.

解决方案

无法从画布中获取文本.您需要做的是在使用 fillText(); 并渲染画布之前将文本保存在变量中.当你想编辑画布中的文本时,你必须重新绘制画布,当你想用 fillText(); 渲染编辑的文本时,你必须再次从变量中读取文本..p>

I have a text filled in HTML5 canvas using fillText(); How to make it editable and read the value into a variable? The text must be inside canvas, as it will be written inside some complex polygon shape.

解决方案

You can not get the text from the canvas. What you need to do is to keep the text in a variable before you use fillText(); and render the canvas. When you want to edit the text in the canvas, you have to paint the canvas again, and read the text from the variable again when you want to render the edited text with fillText();.

这篇关于HTML5 画布文本编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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