From 162eeedf4f607bc55d6aa2b51a15934622074110 Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Sun, 31 Dec 2023 11:51:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D1=83=20=D1=87=D0=B5,=20=D1=82=D1=80?= =?UTF-8?q?=D0=B0=D0=B9=D0=BD=D0=B5=D0=BC=20=D0=B6=D0=B8=D0=B2=D1=8B=D0=B5?= =?UTF-8?q?=20=D0=BE=D0=B1=D0=BE=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Installer/Files.cfg | 3 +- Libraries/System.lua | 4 +- Pictures/Flight.lua | 134 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 Pictures/Flight.lua diff --git a/Installer/Files.cfg b/Installer/Files.cfg index 70d36a4f..d19ecd0f 100644 --- a/Installer/Files.cfg +++ b/Installer/Files.cfg @@ -690,7 +690,8 @@ "Pictures/Nettle.pic", "Pictures/Raspberry.pic", "Pictures/Road.pic", - "Pictures/Space.pic" + "Pictures/Space.pic", + "Pictures/Flight.lua" }, screensavers = { "Screensavers/Space.lua", diff --git a/Libraries/System.lua b/Libraries/System.lua index f3f73a70..68c0876b 100755 --- a/Libraries/System.lua +++ b/Libraries/System.lua @@ -86,12 +86,12 @@ function system.getDefaultUserSettings() interfaceScreenAddress = nil, interfaceScreenUpdateInterval = 1, interfaceWallpaperEnabled = false, - interfaceWallpaperPath = paths.system.pictures .. "Space.pic", + interfaceWallpaperPath = paths.system.pictures .. "Flight.lua", interfaceWallpaperMode = 1, interfaceWallpaperBrightness = 0.9, interfaceScreensaverEnabled = false, - interfaceScreensaverPath = paths.system.screensavers .. "Space.lua", + interfaceScreensaverPath = paths.system.screensavers .. "Matrix.lua", interfaceScreensaverDelay = 20, interfaceTransparencyEnabled = true, diff --git a/Pictures/Flight.lua b/Pictures/Flight.lua new file mode 100644 index 00000000..d6bd5841 --- /dev/null +++ b/Pictures/Flight.lua @@ -0,0 +1,134 @@ + +-- This's a copy-paste of orignal software from https://github.com/Maxu5/ + +------------------------------------------------------------------------------------- + +local screen = require("Screen") + +local starAmount, delay, colors, background, braille1, braille2, braille3, braille4, braille5, braille6, braille7, braille8, braille9, braille10 = + 100, + 0.05, + { + 0x0F0F0F, + 0x1E1E1E, + 0x2D2D2D, + 0x3C3C3C, + 0x4B4B4B, + 0x5A5A5A, + 0x696969, + 0x787878, + 0x878787, + 0x969696, + 0xA5A5A5, + 0xB4B4B4, + 0xC3C3C3, + 0xD2D2D2, + 0xE1E1E1, + 0xF0F0F0, + }, + 0x0F0F0F, + "⠁", "⠈", "⠂", "⠐", "⠄", "⠠", "⡀", "⢀", "⠛", "⣤" + +-- Faster access without tables indexing +local computerUptime, tableRemove, mathSin, mathCos, mathRandom, screenUpdate = + computer.uptime, + table.remove, + math.sin, + math.cos, + math.random, + screen.update + +-- Other variables, nil by default +local stars, deadline, hitsDeadline, i, star, rotationAngle, targetX, targetY, startWay, x, y, xmod, ymod, prevX, prevY, signalType, char, color = {}, 0 + +return function(self) + hitsDeadline = computerUptime() >= deadline + + -- Spawing stars + while #stars < starAmount do + rotationAngle = mathRandom(6265) / 1000 + + targetX, targetY, startWay = + mathCos(rotationAngle) * self.width * 0.75 + self.width / 2, + mathSin(rotationAngle) * self.width * 0.375 + self.height / 2, + mathRandom() + + stars[#stars + 1] = { + targetX = targetX, + targetY = targetY, + startX = (targetX - self.width / 2) * startWay + self.width / 2, + startY = (targetY - self.height / 2) * startWay + self.height / 2, + way = 0.01, + speed = mathRandom(25, 75) / 1000 + 1, + } + end + + screen.drawRectangle(self.x, self.y, self.width, self.height, background, colors[1], " ") + + -- Drawing stars + i = 1 + while i <= #stars do + star = stars[i] + + x, y = + star.startX + (star.targetX - star.startX) * star.way, + star.startY + (star.targetY - star.startY) * star.way + + if x > self.width + 1 or x < 1 or y > self.height + 1 or y < 1 then + tableRemove(stars, i) + else + -- Star type + xmod = x * 2 + xmod = (xmod - xmod % 1) % 2 + + ymod = y * 4 + ymod = (ymod - ymod % 1) % 4 + + -- Star color + color = star.way * 4.0156862745098 * #colors + color = colors[color - color % 1 + 1] or 0xFFFFFF + + if star.way < 0.3 then + if xmod == 0 then + if ymod == 0 then + char = braille1 + elseif ymod == 1 then + char = braille3 + elseif ymod == 2 then + char = braille5 + else + char = braille7 + end + else + if ymod == 0 then + char = braille2 + elseif ymod == 1 then + char = braille4 + elseif ymod == 2 then + char = braille6 + else + char = braille8 + end + end + else + if ymod < 2 then + char = braille9 + else + char = braille10 + end + end + + screen.set(x - x % 1, y - y % 1, background, color, char) + + i = i + 1 + + if hitsDeadline then + star.way = star.way * star.speed + end + end + end + + if hitsDeadline then + deadline = computerUptime() + delay + end +end \ No newline at end of file