Creating a shadow around a canvas drawn shape?

前端 未结 3 833
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-01 17:44

What steps are required to create a shape e.g. rectangle with a shadow from scratch using a Canvas?

Adding a shadow layer to the paint used to draw the rectangle yielded

3条回答
  •  醉酒成梦
    2021-02-01 18:31

    1. create. a Path, add some elements to it

    2. set BlurMaskFilter to a Paint

    3. draw a path with dx, dy shadow offset

    4. unset mask filter

    5. draw a path again with no. offset

提交回复
热议问题