Jump to content
Sign in to follow this  
Socket

A bandeira do brasil em Lua

Recommended Posts

Socket    0
Socket

Bom, copa do mundo, todo mundo em clima de rumo ao hexa. Brasil ganhou da Coréia do Norte por 2 x 1, que eu acho que foi um placar horrivel. Eu que estou aprendendo Python lembro de uma biblioteca de Lua chamada Lua-GD. Então, lá vou eu aprender.

 

Após um tempo de estudo, e o aprendizado de algumas funções, lá vou eu fazer a bandeira do brasil em Lua! Éhh, não foi fácil não, principalmente escrever o lema de nosso país: "Ordem e progresso". Só tem uma coisa, a bandeira tem umas 500 estrelas, e elas são randomicas, ou seja, cada vez que você "criar" a bandeira as estrelas vão sair em posições diferentes haha.

 

Script:

require "gd"
local im = gd.createTrueColor(950,700)
local green = im:colorAllocate(1,84,32)
local yellow = im:colorAllocate(216,182,0)
local blue = im:colorAllocate(8,28,79)
local white = im:colorAllocate(250,234,219)
local black = im:colorAllocate(0,0,0)

im:filledRectangle(0,0,im:sizeX(),im:sizeY(),green)
im:filledPolygon({{475,80},{870,350},{475,620},{80,350}},yellow)
im:polygon({{475,80},{870,350},{475,620},{80,350}}, black)
im:filledEllipse(475,350,300,300,blue)
im:arc(475,350,300,300,0,360,black)

function gd.createStar(gdImage, x, y, size)
   local white, black = gdImage:colorAllocate(255,255,255), gdImage:colorAllocate(0,0,0)
   local points = {
                   {x,y-(size)},
                   {x+(size/2),y-(size/4)},
                   {x+size,y-(size/4)},
                   {x+(size/2)-(size/10), y+(size/4)},
                   {x+(size/2), y+size},
                   {x, y+(size/2)},
                   {x-(size/2), y+size},
                   {x-(size/2)+(size/10), y+(size/4)},
                   {x-size, y-(size/4)},
                   {x-(size/2), y-(size/4)}
   }
   gdImage:filledPolygon(points,white)
   gdImage:polygon(points, black)
end

for i = 360, 380 do
   if i < 375 then
       im:arc(475, i, 300, 150, 183, 357, white)
   else
       im:arc(475, i, 300, 150, 189, 351, white)
   end
end
im:arc(475, 360, 300, 150, 183, 357, black)
im:arc(475, 380, 300, 150, 189, 351, black)
im:stringFT(black, "./Vera.ttf", 15, math.rad(15) , 380, 320, "O")
im:stringFT(black, "./Vera.ttf", 15, math.rad(15) , 396, 314, "r")
im:stringFT(black, "./Vera.ttf", 15, math.rad(13) , 405, 312, "d")
im:stringFT(black, "./Vera.ttf", 15, math.rad(11) , 417, 310, "e")
im:stringFT(black, "./Vera.ttf", 15, math.rad(9)  , 428, 308, "m")
im:stringFT(black, "./Vera.ttf", 15, math.rad(3)  , 458, 304, "e")
im:stringFT(black, "./Vera.ttf", 15, math.rad(5)  , 478, 304, "P")
im:stringFT(black, "./Vera.ttf", 15, math.rad(357), 488, 304, "r")
im:stringFT(black, "./Vera.ttf", 15, math.rad(355), 495, 304, "o")
im:stringFT(black, "./Vera.ttf", 15, math.rad(353), 506, 305, "g")
im:stringFT(black, "./Vera.ttf", 15, math.rad(352), 517, 306, "r")
im:stringFT(black, "./Vera.ttf", 15, math.rad(351), 525, 308, "e")
im:stringFT(black, "./Vera.ttf", 15, math.rad(350), 537, 311, "s")
im:stringFT(black, "./Vera.ttf", 15, math.rad(349), 546, 313, "s")
im:stringFT(black, "./Vera.ttf", 15, math.rad(348), 556, 316, "o")

for i = 340, 460 do
   gd.createStar(im, math.random(400, 570), i, math.random(4,5))
end

im:png('./brasil.png')
os.execute("brasil.png")

Como eu to sem tempo, não vai da pra postar nenhuma SS, bom, é isso, até mais.

 

-- Edit

Sobrou um tempinho e eu vim postar a foto.

brasilw.png

 

Num está lá aquelas coisas mas está do mesmo formato ;D

As estrelas então nem se fala haha'

 

-- Edit

Mudei uns treko no script, agora ele passa uma linha preta em volta do losango, círculo e da faixa, e mudei a cor da frase "Ordem e progresso" pra preto. Não vo muda a foto, preguiça.

Edited by Socket

Share this post


Link to post
Share on other sites
Seein    0
Seein

Hahaha, fico dahora.

Se eu fosse da staff eu diria :

Aprovado.

hahaha

Share this post


Link to post
Share on other sites
Elwyn    106
Elwyn

o mini-genio como sempre fazendo suas genisses! '-'

quando que vai me dar uma aula explicando algo em vez de falar; "Pera, to fazendo isso python." '-'

Share this post


Link to post
Share on other sites
Iago Felipe    5
Iago Felipe

KOSPAKSAPOKSAPO

as estrelas parece um monte daqueles diamantes do kingdom age.

Mais valeu pelo esforço, e ficou legal a bandeira, só as estrelas néa.. que ta zuada.

Share this post


Link to post
Share on other sites
Mock    32
Mock

aehaeea curti o pog q c fez

im:stringFT(green, "./Vera.ttf", 15, math.rad(15) , 380, 320, "O")

im:stringFT(green, "./Vera.ttf", 15, math.rad(15) , 396, 314, "r")

im:stringFT(green, "./Vera.ttf", 15, math.rad(13) , 405, 312, "d")

im:stringFT(green, "./Vera.ttf", 15, math.rad(11) , 417, 310, "e")

im:stringFT(green, "./Vera.ttf", 15, math.rad(9) , 428, 308, "m")

im:stringFT(green, "./Vera.ttf", 15, math.rad(3) , 458, 304, "e")

im:stringFT(green, "./Vera.ttf", 15, math.rad(5) , 478, 304, "P")

im:stringFT(green, "./Vera.ttf", 15, math.rad(357), 488, 304, "r")

im:stringFT(green, "./Vera.ttf", 15, math.rad(355), 495, 304, "o")

im:stringFT(green, "./Vera.ttf", 15, math.rad(353), 506, 305, "g")

im:stringFT(green, "./Vera.ttf", 15, math.rad(352), 517, 306, "r")

im:stringFT(green, "./Vera.ttf", 15, math.rad(351), 525, 308, "e")

im:stringFT(green, "./Vera.ttf", 15, math.rad(350), 537, 311, "s")

im:stringFT(green, "./Vera.ttf", 15, math.rad(349), 546, 313, "s")

im:stringFT(green, "./Vera.ttf", 15, math.rad(348), 556, 316, "o")

usando umas formulas matematicas tipo a da circunferencia dava p fazer isso ae

mais em fim pog que é bom \o

 

gostei do script

Share this post


Link to post
Share on other sites
Mickfern    32
Mickfern

Caraca nem dá para acreditar nisso '-'

Eu sofrendo para criar um simples scripts de teleport randomico, tu faz isso ¬¬

Parabéns, ficou loko !!!

Share this post


Link to post
Share on other sites
Socket    0
Socket
aehaeea curti o pog q c fez

 

usando umas formulas matematicas tipo a da circunferencia dava p fazer isso ae

mais em fim pog que é bom \o

 

gostei do script

 

kk', eu procurei no manual enteiro de gd, nos exemplos e tal, e num achei uma função que fazia isso, ai eu falei: "que se foda vo no pog :@"

Ai fiz isso kk'

 

A função de criar estrela lá fico zuado, usa ela só que com size 100 pra tu ver .

Share this post


Link to post
Share on other sites
Juan Barcena    0
Juan Barcena

ordem e progresso é verde mano

preto qisop

achei bem legal isso, pog powered mas nem saberia fazer isso mesmo .-.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×