Line

Type     

class (base class : Display)

[gd]

Inheritance

Line ⟶ Display ⟶ Object

[bg]

Overview

Draw line.


See also 

Display




Overview


Creates and displays a line on the screen. 

The local origin (anchor point) is at the center of the line.


Line class inherits Display class, therefore all the methods defined in Display class can be used.



Syntax


Line(x1, y1, x2, y2 [, option])


x1, y1, x2, y2 (required) : number


    x-y coordinates of starting point (x1, y1) and end point (x2,y2)


option (optional) : Lua table that contains line width and/or line color


        option = {

                width = n,

                color = ColorObject

        }



Mehtods



method 

description

return

obj:setWidth(num)

set line width as num

self

obj:setColor(color)

set line color as Color object color

self

obj:getWidth()

return width of the line

num

obj:getColor()

return color object of the line

color object



Examples



local s = Line(100,200,300,400)



-- set initial line width as 10

local s = Line(100,200,300,400,{width=10})



-- set initial rotational speed as 2

local s = Line(100,200,300,400):setDrot(2)



-- red line with width as 10

local s = Line(10,20,30,40,{width=10,color=Color.RED})


-- remove line after 5 seconds

s:removeAfter(5000)


-- Change width after 5 seconds

s:addTimer(5000, function(self) self:setWidth(5) end)


댓글 없음:

댓글 쓰기