How to draw a star by using canvas HTML5?

前端 未结 5 2171
伪装坚强ぢ
伪装坚强ぢ 2021-01-05 09:04

Am trying to draw a star using canvas, but the code is not running. I want to understand: what are the steps to measure the Y and X coordinate? How to find them? to draw any

5条回答
  •  耶瑟儿~
    2021-01-05 09:07

    A star is basically a regular polygon with alternating points on an inner and an outer radius.

    Here's an example of a flexible function to draw a star shape.

    You can set the position, #spikes and the inner & outer radius of the spikes:

    enter image description here

    Example code and a Demo: http://jsfiddle.net/m1erickson/8j6kdf4o/

    
    
    
     
    
    
    
    
    
        
    
    
    

提交回复
热议问题