Синтаксис: Lua
function circle(x,y,radius,color,border1,colorL,alfa)
local myShape = Shape.new()
myShape:setLineStyle(border1, colorL,alfa )
myShape:setFillStyle ( Shape.SOLID , color,alfa )
x=x+radius
y=y+radius
myShape:beginPath() --малюєм контур із ліній
myShape:moveTo(x+radius,y) --стартова точка
for i=1,360,1 do
myShape:lineTo(x+math.cos(math.rad(i))*radius,y+math.sin(math.rad(i))*radius)
end
myShape:endPath()
stage:addChild(myShape)
end
local myShape = Shape.new()
myShape:setLineStyle(border1, colorL,alfa )
myShape:setFillStyle ( Shape.SOLID , color,alfa )
x=x+radius
y=y+radius
myShape:beginPath() --малюєм контур із ліній
myShape:moveTo(x+radius,y) --стартова точка
for i=1,360,1 do
myShape:lineTo(x+math.cos(math.rad(i))*radius,y+math.sin(math.rad(i))*radius)
end
myShape:endPath()
stage:addChild(myShape)
end
Закруглений квадрат
function boxR(x,y,w,h,radius,color,border1,colorL,alfa)if radius>w/2 then radius=w/2 end
if radius>h/2 then radius=h/2 end
local myShape = Shape.new()
myShape:setLineStyle(border1, colorL,alfa )
myShape:setFillStyle(Shape.SOLID, color,alfa)
myShape:beginPath()
myShape:moveTo(x+radius,y)
for i=-90,0,1 do
myShape:lineTo(x+w-radius+math.cos(math.rad(i))*radius,y+radius+math.sin(math.rad(i))*radius)
end
for i=0,90,1 do
myShape:lineTo(x+w-radius+math.cos(math.rad(i))*radius,y+h-radius+math.sin(math.rad(i))*radius)
end
for i=90,180,1 do
myShape:lineTo(x+radius+math.cos(math.rad(i))*radius,y+h-radius+math.sin(math.rad(i))*radius)
end
for i=180,270,1 do
myShape:lineTo(x+radius+math.cos(math.rad(i))*radius,y+radius+math.sin(math.rad(i))*radius)
end
myShape:endPath()
stage:addChild(myShape)
end
Квадрат
function box(x,y,w,h,color,border1,colorL,alfa)
local myShape = Shape.new()
myShape:setLineStyle(border1, colorL,alfa )
myShape:setFillStyle(Shape.SOLID, color,alfa)
myShape:beginPath()
myShape:moveTo(x,y)
myShape:lineTo(x+w,y)
myShape:lineTo(x+w,y+h)
myShape:lineTo(x,y+h)
myShape:lineTo(x,y)
myShape:endPath()
stage:addChild(myShape)
end
Синтаксис: Lua
-- circle(x,y,радіус,колір,обводка пікс,колір обводки,прозорість)
circle(200,100,50,"0xF5001D",2,"0x006400",0.5)
circle(300,300,50,0x9900ff,2,0x9900ff,1)
--boxR(x,y,ширина,висота,радіус кута,0x9900ff,2,0x006400,1)
boxR(300,100,100,100,30,0x9900ff,2,0x006400,1)
box(200,200,100,100,"0xF5001D",2,"0x006400",0.9)
circle(200,100,50,"0xF5001D",2,"0x006400",0.5)
circle(300,300,50,0x9900ff,2,0x9900ff,1)
--boxR(x,y,ширина,висота,радіус кута,0x9900ff,2,0x006400,1)
boxR(300,100,100,100,30,0x9900ff,2,0x006400,1)
box(200,200,100,100,"0xF5001D",2,"0x006400",0.9)
1
1
Немає коментарів:
Дописати коментар