Wie man Leinwandelemente mit CSS stymt
Posted: 11 Aug 2025, 08:11
Ich habe viele Figuren und Elemente in der A -HTML -Leinwand. Alle von ihnen haben unterschiedliche Farben, Striche usw. Ich mag es wirklich nicht, dass all diese Werte in meinem JS -Code wandern, da einige Stile im CSS und einige im Code sind. tun: < /p>
Http://jsfiddle.net/nedyalkov/ysglqqh3/1/
Code: Select all
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'green'; // I'd like to set with CSS
context.fill();
context.lineWidth = 5; // I'd like to set with CSS
context.strokeStyle = '#003300'; // I'd like to set with CSS
context.stroke();