Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local RunService = game:GetService("RunService")
  3.  
  4. local common = ReplicatedStorage:WaitForChild("common")
  5. local lib = ReplicatedStorage:WaitForChild("lib")
  6.  
  7. local Roact = require(lib:WaitForChild("Roact"))
  8. local CodeLabLogo = Roact.Component:extend("CodeLabLogo")
  9.  
  10. local CODELAB_LOGO_IMAGE = "rbxassetid://3310888975"
  11.  
  12. local BINARY_STRING_1 = "101100101101101101001"
  13. local BINARY_STRING_2 = "001011010111010101100"
  14.  
  15. local BINARY_FONT = Enum.Font.Code
  16.  
  17. local NUM_BINARY_ROWS = 10
  18. local BINARY_LABEL_HEIGHT = 22
  19. local BINARY_ROW_PADDING = 2
  20.  
  21. local BINARY_CYCLES_PER_SEC = 1/15
  22.  
  23. local function alphaFromTime(t)
  24. return (t*BINARY_CYCLES_PER_SEC)%1
  25. end
  26.  
  27. local function binaryLabel(string, offset, children)
  28. return Roact.createElement("TextLabel", {
  29. Size = UDim2.new(1,0,0,BINARY_LABEL_HEIGHT),
  30. BackgroundTransparency = 1,
  31. Position = offset,
  32.  
  33. TextColor3 = Color3.fromRGB(255,255,255),
  34. Text = string or BINARY_STRING_1,
  35. TextSize = 24,
  36. Font = BINARY_FONT,
  37. }, children)
  38. end
  39.  
  40. function CodeLabLogo:init(initialProps)
  41. self:updateBinary(tick())
  42. end
  43.  
  44. function CodeLabLogo:render()
  45.  
  46. local alpha = self.state.alpha
  47.  
  48. local binaryFrameChildren = {}
  49.  
  50. binaryFrameChildren.binaryLayout = Roact.createElement("UIListLayout", {
  51. HorizontalAlignment = Enum.HorizontalAlignment.Center,
  52. VerticalAlignment = Enum.VerticalAlignment.Center,
  53. Padding = UDim.new(0,BINARY_ROW_PADDING),
  54. SortOrder = Enum.SortOrder.LayoutOrder,
  55. })
  56.  
  57. for i = 1, NUM_BINARY_ROWS do
  58. local isOdd = (i%2 ~= 0)
  59. local binaryString = (isOdd and BINARY_STRING_1) or BINARY_STRING_2
  60.  
  61. local binaryLabelFrame = Roact.createElement("Frame", {
  62. Size = UDim2.new(1,0,0,BINARY_LABEL_HEIGHT),
  63. BackgroundTransparency = 1,
  64. LayoutOrder = i,
  65. }, {
  66. binaryLabel(
  67. binaryString,
  68. UDim2.new((isOdd and 1-alpha) or (alpha),0,0,0), {
  69. binaryLabel(
  70. binaryString,
  71. UDim2.new((isOdd and -1) or (-1),0,0,0)
  72. )
  73. }
  74. )
  75. }
  76. )
  77. binaryFrameChildren["binaryFrame_"..i] = binaryLabelFrame
  78. end
  79.  
  80. return Roact.createElement("Frame", {
  81. AnchorPoint = Vector2.new(0.5,0.5),
  82. Position = UDim2.new(0.5,0,0.5,0),
  83. Size = UDim2.new(0,256,0,256),
  84.  
  85. BorderSizePixel = 0,
  86. BackgroundColor3 = Color3.fromRGB(32, 34, 37),
  87. ClipsDescendants = true
  88. }, {
  89. logoLabel = Roact.createElement("ImageLabel", {
  90. Size = UDim2.new(1,0,1,0),
  91.  
  92. BackgroundTransparency = 1,
  93.  
  94. Image = CODELAB_LOGO_IMAGE,
  95. }),
  96. binaryFrame = Roact.createElement("Frame", {
  97. Size = UDim2.new(1,0,1,0),
  98.  
  99. BackgroundTransparency = 1,
  100. }, binaryFrameChildren)
  101. })
  102. end
  103.  
  104. function CodeLabLogo:updateBinary()
  105. self:setState({
  106. alpha = alphaFromTime(tick()),
  107. })
  108. end
  109.  
  110. function CodeLabLogo:didMount()
  111. self.animationConnection = RunService.RenderStepped:connect(function()
  112. self:updateBinary(tick())
  113. end)
  114. end
  115.  
  116. function CodeLabLogo:willUnmount()
  117. if self.animationConnection then self.animationConnection:disconnect() end
  118. end
  119.  
  120. return CodeLabLogo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement