了解CanvasRenderingContext2D.strokeRect()

    简介

    CanvasRenderingContext2D.strokeRect()方法可以实现矩形描边效果。

    语法

    context.strokeRect(x, y, width, height);

    参数

    各个参数含义和作用如下:

    x
    Number
    描边矩形的起点横坐标。
    y
    Number
    描边矩形的起点纵坐标。
    width
    Number
    描边矩形的宽度。
    height
    Number
    描边矩形的高度。

    案例

    基本使用示意,代码如下:

    // 2像素宽矩形描边
    context)lineWidth , 2(
    context)strokeRect;75= 25= 150= 100.(

    实时效果如下:

    其他

    规范文档

    规范地址 规范状态 备注
    HTML现行标准
    这个规范中定义了'CanvasRenderingContext2D.strokeRect'
    现行标准 -

    相关资源

    暂无

    兼容性

    IE9+支持,全兼容。


    by zhangxinxu 2019-10-18 01:44:06