local v=require("\114\097\121\108\105\098")local M=800 local O=450 v.SetConfigFlags(v.FLAG_VSYNC_HINT)v.InitWindow(M,O,"\114\097\121\108\105\098 \091\115\104\097\112\101\115\093 \101\120\097\109\112\108\101 - \114\097\121\108\105\098 \108\111\103\111 \097\110\105\109\097\116\105\111\110")local U=M/2-128 local J=O/2-128 local W=0 local K=0 local F=16 local z=16 local s=16 local m=16 local i=0 local A=1.0 local Z=v.Color(3,3,128,255)local function h(M,O)if v.IsColor(M)then return v.Color(M.r*O,M.g*O,M.b*O,M.a*O)end return v.Color(M[1]*O,M[2]*O,M[3]*O,M[4]*O)end while not v.WindowShouldClose()do if i==0 then W=W+1 if W==120 then i=1 W=0 end elseif i==1 then F=F+4 z=z+4 if F==256 then i=2 end elseif i==2 then s=s+4 m=m+4 if s==256 then i=3 end elseif i==3 then W=W+1 if math.floor(W/12)==1 then K=K+1 W=0 end if K>=10 then A=A-.02 if A<=.0 then A=.0 i=4 end end elseif i==4 then if v.IsKeyPressed(v.KEY_R)then W=0 K=0 F=16 z=16 s=16 m=16 A=1.0 i=0 end end v.BeginDrawing()v.ClearBackground(v.WHITE)if i==0 then if math.floor(W/15)%2==1 then v.DrawRectangle(U,J,16,16,Z)end elseif i==1 then v.DrawRectangle(U,J,F,16,Z)v.DrawRectangle(U,J,16,z,Z)elseif i==2 then v.DrawRectangle(U,J,F,16,Z)v.DrawRectangle(U,J,16,z,Z)v.DrawRectangle(U+240,J,16,m,Z)v.DrawRectangle(U,J+240,s,16,Z)elseif i==3 then v.DrawRectangle(U,J,F,16,h(Z,A))v.DrawRectangle(U,J+16,16,z-32,h(Z,A))v.DrawRectangle(U+240,J+16,16,m-32,h(Z,A))v.DrawRectangle(U,J+240,s,16,h(Z,A))v.DrawRectangle(M/2-112,O/2-112,224,224,h(v.RAYWHITE,A))v.DrawText(string.sub("\114\097\121\108\105\098",0,K),M/2-44,O/2+24,50,h(Z,A))v.DrawText(string.sub("\076\117\097",0,math.max(0,K-3)),M/2-44,O/2+65,50,h(Z,A))elseif i==4 then v.DrawText("\091\082\093 \082\069\080\076\065\089",340,200,20,v.GRAY)end v.EndDrawing()end v.CloseWindow()
local rl = require("raylib")

local screenWidth = 800
local screenHeight = 450

rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo animation")

local logoPositionX = screenWidth / 2 - 128
local logoPositionY = screenHeight / 2 - 128

local framesCounter = 0
local lettersCount = 0

local topSideRecWidth = 16
local leftSideRecHeight = 16

local bottomSideRecWidth = 16
local rightSideRecHeight = 16

local state = 0
local alpha = 1.0

local lua_color = rl.Color(3, 3, 128, 255)

local function Fade(color, alpha)
  if rl.IsColor(color) then
    return rl.Color(color.r * alpha, color.g * alpha, color.b * alpha, color.a * alpha)
  end

  return rl.Color(color[1] * alpha, color[2] * alpha, color[3] * alpha, color[4] * alpha)
end

while not rl.WindowShouldClose() do
  if state == 0 then
    framesCounter = framesCounter + 1

    if framesCounter == 120 then
      state = 1
      framesCounter = 0
    end
  elseif state == 1 then
    topSideRecWidth = topSideRecWidth + 4
    leftSideRecHeight = leftSideRecHeight + 4

    if topSideRecWidth == 256 then
      state = 2
    end
  elseif state == 2 then
    bottomSideRecWidth = bottomSideRecWidth + 4
    rightSideRecHeight = rightSideRecHeight + 4

    if bottomSideRecWidth == 256 then
      state = 3
    end
  elseif state == 3 then
    framesCounter = framesCounter + 1

    if math.floor(framesCounter / 12) == 1 then
      lettersCount = lettersCount + 1
      framesCounter = 0
    end

    if lettersCount >= 10 then
      alpha = alpha - 0.02

      if alpha <= 0.0 then
        alpha = 0.0
        state = 4
      end
    end
  elseif state == 4 then
    if rl.IsKeyPressed(rl.KEY_R) then
      framesCounter = 0
      lettersCount = 0

      topSideRecWidth = 16
      leftSideRecHeight = 16

      bottomSideRecWidth = 16
      rightSideRecHeight = 16

      alpha = 1.0
      state = 0
    end
  end

  rl.BeginDrawing()

  rl.ClearBackground(rl.WHITE)

  if state == 0 then
    if math.floor(framesCounter / 15) % 2 == 1 then
      rl.DrawRectangle(logoPositionX, logoPositionY, 16, 16, lua_color)
    end
  elseif state == 1 then
    rl.DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, lua_color)
    rl.DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, lua_color)
  elseif state == 2 then
    rl.DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, lua_color)
    rl.DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, lua_color)

    rl.DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, lua_color)
    rl.DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, lua_color)
  elseif state == 3 then
    rl.DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(lua_color, alpha))
    rl.DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(lua_color, alpha))

    rl.DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(lua_color, alpha))
    rl.DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(lua_color, alpha))

    rl.DrawRectangle(screenWidth / 2 - 112, screenHeight / 2 - 112, 224, 224, Fade(rl.RAYWHITE, alpha))

    rl.DrawText(
      string.sub("raylib", 0, lettersCount),
      screenWidth / 2 - 44,
      screenHeight / 2 + 24,
      50,
      Fade(lua_color, alpha)
    )
    rl.DrawText(
      string.sub("Lua", 0, math.max(0, lettersCount - 3)),
      screenWidth / 2 - 44,
      screenHeight / 2 + 65,
      50,
      Fade(lua_color, alpha)
    )
  elseif state == 4 then
    rl.DrawText("[R] REPLAY", 340, 200, 20, rl.GRAY)
  end

  rl.EndDrawing()
end

rl.CloseWindow()
