# CanvasRenderingContext2D - [fillRect\(\)](#en-us_topic_0000001058830807_section16678142165920) - [fillStyle](#en-us_topic_0000001058830807_section159395553313) - [clearRect\(\)](#en-us_topic_0000001058830807_section205940367194) - [strokeRect\(\)](#en-us_topic_0000001058830807_section18427819195711) - [fillText\(\)](#en-us_topic_0000001058830807_section114524106587) - [strokeText\(\)](#en-us_topic_0000001058830807_section4144191355810) - [measureText\(\)](#en-us_topic_0000001058830807_section378313153588) - [lineWidth](#en-us_topic_0000001058830807_section652391716583) - [strokeStyle](#en-us_topic_0000001058830807_section1191517562337) - [stroke\(\)](#en-us_topic_0000001058830807_section1071523411019) - [beginPath\(\)](#en-us_topic_0000001058830807_section12670134392) - [moveTo\(\)](#en-us_topic_0000001058830807_section16813157310) - [lineTo\(\)](#en-us_topic_0000001058830807_section4767915838) - [closePath\(\)](#en-us_topic_0000001058830807_section86825473917) - [lineCap](#en-us_topic_0000001058830807_section6852133718410) - [lineJoin](#en-us_topic_0000001058830807_section395812401442) - [miterLimit](#en-us_topic_0000001058830807_section429711421945) - [font](#en-us_topic_0000001058830807_section17597332121110) - [textAlign](#en-us_topic_0000001058830807_section15681153321114) - [textBaseline](#en-us_topic_0000001058830807_section77981136141111) - [createPattern\(\)](#en-us_topic_0000001058830807_section1034582183919) - [bezierCurveTo\(\)](#en-us_topic_0000001058830807_section450521614318) - [quadraticCurveTo\(\)](#en-us_topic_0000001058830807_section12938183173) - [arc\(\)](#en-us_topic_0000001058830807_section102329511716) - [arcTo\(\)](#en-us_topic_0000001058830807_section3172156571) - [rect\(\)](#en-us_topic_0000001058830807_section1351519304107) - [fill\(\)](#en-us_topic_0000001058830807_section14842031151015) - [clip\(\)](#en-us_topic_0000001058830807_section1355171921416) - [rotate\(\)](#en-us_topic_0000001058830807_section7682182091419) - [scale\(\)](#en-us_topic_0000001058830807_section157714218144) - [transform\(\)](#en-us_topic_0000001058830807_section1675964717570) - [setTransform\(\)](#en-us_topic_0000001058830807_section1439382216440) - [translate\(\)](#en-us_topic_0000001058830807_section931011253449) - [globalAlpha](#en-us_topic_0000001058830807_section188252174810) - [drawImage\(\)](#en-us_topic_0000001058830807_section1953117410488) - [restore\(\)](#en-us_topic_0000001058830807_section64027684817) - [save\(\)](#en-us_topic_0000001058830807_section410672635214) - [createLinearGradient\(\)6+](#en-us_topic_0000001058830807_section1696310905) - [createImageData\(\)](#en-us_topic_0000001058830807_section2021142714524) - [getImageData\(\)](#en-us_topic_0000001058830807_section92731528205217) - [putImageData\(\)](#en-us_topic_0000001058830807_section15774154925515) - [setLineDash\(\)](#en-us_topic_0000001058830807_section1934985155516) - [getLineDash\(\)](#en-us_topic_0000001058830807_section522105285519) - [lineDashOffset](#en-us_topic_0000001058830807_section8283548889) - [globalCompositeOperation](#en-us_topic_0000001058830807_section123871750284) - [shadowBlur](#en-us_topic_0000001058830807_section6207051888) - [shadowColor](#en-us_topic_0000001058830807_section42724396120) - [shadowOffsetX](#en-us_topic_0000001058830807_section1616174021219) - [shadowOffsetY](#en-us_topic_0000001058830807_section272013417128) **CanvasRenderingContext2D** allows you to draw rectangles, text, images, and other objects on a canvas. - Example ``` ``` ``` // xxx.js export default { handleClick() { const el = this.$refs.canvas1; const ctx = el.getContext('2d'); ctx.beginPath(); ctx.arc(100, 75, 50, 0, 6.28); ctx.stroke(); }, } ``` - ![](figures/en-us_image_0000001089583647.png) ## fillRect\(\) Fills a rectangle on the canvas. - Parameter
X-coordinate of the upper left corner of the rectangle stroke |
||
Y-coordinate of the upper left corner of the rectangle stroke |
||
Object that contains the text width. You can obtain the width by TextMetrics.width. |
Style of line endpoints. Available values include: |
Text alignment mode. Available values include: |
Source image. For details, see Image. |
||
Repetition mode. The value can be "repeat", "repeat-x", "repeat-y", or "no-repeat". |
Clockwise rotation angle. You can use Math.PI / 180 to convert the angle to a radian. |
Global alpha value to set. The value ranges from 0.0 (completely transparent) to 1.0 (completely opaque). |
Image resource. For details, see Image. |
||
X-coordinate of the upper left corner of the rectangle used to crop the source image. |
||
Y-coordinate of the upper left corner of the rectangle used to crop the source image. |
||
X-coordinate of the upper left corner of the drawing area on the canvas. |
||
Y-coordinate of the upper left corner of the drawing area on the canvas. |
||
ImageData object with the same width and height copied from the original ImageData object |
ImageData object that contains pixels in the specified area on the canvas |
X-axis offset of the upper left corner of the rectangular area relative to that of the source image |
||
Y-axis offset of the upper left corner of the rectangular area relative to that of the source image |
||
An array describing the interval of alternate line segments and length of spacing |
Interval of alternate line segments and the length of spacing |
Dash line offset. The value is a floating point number starting from 0.0. |
Shadow blur degree. A larger value indicates a more blurred shadow. The value is of the float type, and the default value is 0. |