填充t恤与颜色和相应地更改文本颜色在HTML画布上 [英] Fill t-shirt with color and change text color accordingly on HTML canvas

查看:111
本文介绍了填充t恤与颜色和相应地更改文本颜色在HTML画布上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在画布上画出了一件T恤,当用户在上面的菜单上选择一种颜色时,我正在填充它。此外,我想让T恤上的文字相应改变(例如,如果选择了黑色,那么T恤的文字颜色应该是白色的)。这是可能吗?

I've drawn out a t-shirt on canvas and I am currently trying to fill it when the user selects a colour on the menu above. In addition, I'd like the text on the t-shirt to change accordingly (for instance if the color black is selected then the t-shirt text color should be white). Is this possible?

代码片段到目前为止:

<body>T-shirt color
    <br>
    <canvas id="toolsCanvas" width=300 height=53></canvas>
    <br>
    <p>
        <canvas id="drawingCanvas" width="520" height="0"></canvas>
        <canvas id="itemCanvas" width="520" height="429"></canvas>
</body>

这将更容易演示我在说什么,jsFiddle这里: http://jsfiddle.net/rtnq8mjL/

It would be easier to demonstrate what I'm speaking it, jsFiddle here: http://jsfiddle.net/rtnq8mjL/

推荐答案

您应该使用 ctx.fillStyle = color ctx.fill()衬衫。

这里是部分完成的小提琴

我希望你能从这里解决这个问题。

I hope you can solve this from here.

这篇关于填充t恤与颜色和相应地更改文本颜色在HTML画布上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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