简体   繁体   中英

Fill t-shirt with color and change text color accordingly on HTML canvas

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?

Snippet of the code so far:

<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>

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

You should use ctx.fillStyle = color and ctx.fill() methods to fill that shirt. but somehow the shirt is not being filled with color completely.

Here is the partially completed fiddle .

I hope you can solve this from here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM