Polygon

Type    

class (base classes : 

[gd]

Inheritance

Polygon ⟶ ShapeDisplay ⟶ Object

[bg]

Overview

Creates a regular polygon shape.


See also 

Display



Overview


  Creates a regular polygon shape.


  Polygon class inherits Display class, therefore all the methods defined in Display class can also be used in the Polygon object.



Syntax



local p = Polygon(radius, points  [, option] )


    • radius - (required) the radius of the outer tangent circle

    • points - (required) number of vertexts (>= 3)

    • option - (optional) table containing parameters


        option = {

                strokeWidth = n, -- (default = 0) width of stroke

                strokeColor = color, -- (default = Color.WHITE) stroke color

                fill = color, -- (default = Color(Color.WHITE,1)) color and alpha for fill

        }


  Note that the initial anchor point is the center of the right polygon.


Methods



method

description

return

obj:setStrokeWidth(n)

set width of outline

self

obj:setStrokeColor(color)

set color of outline with Color object

self

obj:fill(color)

fill inner area with Color object

self

obj:empty()

display stroke only (fill inner area by transparent color)

self

obj:setRadius(n)

set radius of the polygon as n

self

obj:setPoints(n)

set number of vertexts as n

self


Examples



Polygon(100, 3) -- equilateral triangle


local p = Polygon(100, 4, {fill=Color.RED}) -- square


local p = Polygon(100, 5, {strokeWidth=10,strokeColor=Color.BLUE} )

Timer(5000, function() p:setStrokeColor(Color.RED) end) -- change stroke color after 5 seconds


local p = Circle(100, 8, {

    fill = Color.RED,

    strokeColor = Color.YELLOW,

    strokeWidth = 10,

} )


댓글 없음:

댓글 쓰기