HTML canvas fill() methode
Definitie en gebruik
fill()
De methode vult het huidige beeld (pad) in. De standaard kleur is zwart.
Tip:Gebruik a.u.b. fillStyle een andere kleur of verloop in te vullen.
Note:Als het pad niet gesloten is, dan fill()
De methode voegt een lijn toe tussen het einde van het pad en het beginpunt, om het pad te sluiten, en vult vervolgens het pad in.
Example
Draw a 150*100 pixel rectangle and then fill it with green:
JavaScript:
var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.rect(20,20,150,100); ctx.fillStyle="green"; ctx.fill();
Syntax
context.fill();
Browser support
The numbers in the table indicate the first browser version that fully supports this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.