Changeset View
Changeset View
Standalone View
Standalone View
stand/lua/logo/logo-air.lua
- This file was added.
| -- | |||||
| -- SPDX-License-Identifier: BSD-2-Clause-FreeBSD | |||||
| -- | |||||
| -- Copyright (c) 2023 The SmartixOS Project <ip@smartix.llc> | |||||
| -- All rights reserved. | |||||
| -- | |||||
| -- Redistribution and use in source and binary forms, with or without | |||||
| -- modification, are permitted provided that the following conditions | |||||
| -- are met: | |||||
| -- 1. Redistributions of source code must retain the above copyright | |||||
| -- notice, this list of conditions and the following disclaimer. | |||||
| -- 2. Redistributions in binary form must reproduce the above copyright | |||||
| -- notice, this list of conditions and the following disclaimer in the | |||||
| -- documentation and/or other materials provided with the distribution. | |||||
| -- | |||||
| -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |||||
| -- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||||
| -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||||
| -- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |||||
| -- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||||
| -- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||||
| -- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||||
| -- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||||
| -- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||||
| -- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| -- SUCH DAMAGE. | |||||
| -- | |||||
| -- $FreeBSD$ | |||||
| -- | |||||
| -- loading library of functions. | |||||
| local color = require("color") | |||||
| local config = require("config") | |||||
| local core = require("core") | |||||
| local screen = require("screen") | |||||
| local drawer = require("drawer") | |||||
| -- end of library functions | |||||
| -- The local function responsible for drawing the logo using regular ASCII strings combined with | |||||
| -- Terminal Escape Sequences. The logo or brand is separately drawn using regular ASCII strings and this procedure is | |||||
| -- (vendor/domain/industry/company/corporate/team/project) dependent. | |||||
| -- Assuming this procedure has been done to obtain an array of string such as the one below | |||||
| --[[ | |||||
| " .::' .." , | |||||
| " .::: ..... '::." , | |||||
| " :::::::::::::. :::." , | |||||
| " :::'::''::::::::::::" , | |||||
| " .:..:' :::::::::::" , | |||||
| " ::::::: :::::::::'" , | |||||
| " . :::::::'.::::::::" , | |||||
| " ..::.::::::::::::::::" , | |||||
| "..'::.: ':::::::::::::'" , | |||||
| "':::::::::.'::::::::'" , | |||||
| " :::::.::::::::." , | |||||
| " '::::::::::::::" , | |||||
| " ':::::::::::" , | |||||
| " :::::::::::" , | |||||
| " :::::::::::." , | |||||
| " :::::::::::.." , | |||||
| " .......:::::::::::::::...." , | |||||
| " :'....'''''::::::::. '''''::::.." , | |||||
| " '''':::::::::::.'' .: .:::" , | |||||
| " ..::::::::'" , | |||||
| ]]-- | |||||
| -- The coloring/theming can be controlled using the color.getTheme() function call with one of the three magic values | |||||
| -- (color.LOGO, color.BRAND, color.MENU) passed in as argument. | |||||
| -- The magic values are used under the hood to complete the Terminal Escape Sequence necessary to display colors. This Sequence is | |||||
| -- made of specific control characters recognized by the Terminal. These specific control characters are defined by | |||||
| -- termcap (or your specific terminal capabilities). The default are safe enough for a wide range of terminal since the Sequences | |||||
| -- implemented in this library include the most basic terminal capabilities such as displaying the most basic colors like red | |||||
| -- green, black, white, blue, yellow etc.. | |||||
| -- The theming system leverages the immutability ability of the Lua scripting language. | |||||
| -- The idea is to return the same array of strings drawn differently on demand. By leveraging this ability, | |||||
| -- the rendition time is near instantaneous and the memory usage efficiently and automatically managed by the Lua | |||||
| -- garbage collector which, based on the current reference discards un-referenced strings as fast as memory allows. | |||||
| -- The end result when sitting on the terminal is near instantaneous change for testing and color manipulation before booting. | |||||
| -- The garbage collection aspect is not necessary ideal because this file (the logo/brand) is executed and the result returned. | |||||
| -- The small catch is that the table is later stored in global table used as cache. | |||||
| -- Manual theming such as the array of string below can still be achieved | |||||
| --[[ | |||||
| " \027[31m``` \027[31;1m`\027[31m", | |||||
| " s` `.....---...\027[31;1m....--.``` -/\027[31m", | |||||
| " +o .--` \027[31;1m/y:` +.\027[31m", | |||||
| " yo`:. \027[31;1m:o `+-\027[31m", | |||||
| " y/ \027[31;1m-/` -o/\027[31m", | |||||
| " .- \027[31;1m::/sy+:.\027[31m", | |||||
| " / \027[31;1m`-- /\027[31m", | |||||
| " `: \027[31;1m:`\027[31m", | |||||
| " `: \027[31;1m:`\027[31m", | |||||
| " / \027[31;1m/\027[31m", | |||||
| " .- \027[31;1m-.\027[31m", | |||||
| " -- \027[31;1m-.\027[31m", | |||||
| " `:` \027[31;1m`:`", | |||||
| " \027[31;1m.-- `--.", | |||||
| " .---.....----.\027[m", | |||||
| ]] | |||||
| -- In fact this is how the old system works; the new system is fully compatible with the manual method. To be more specific | |||||
| -- the new system is a super-set of the old or the old system is a sub-set of the new system; which ever makes more sense. | |||||
| -- The new system allows automation but is limited when it comes to intricate designs; the effort level goes up quickly. In contrast, | |||||
| -- the new system makes it easy to access several terminal capabilities with few predefined library functions. | |||||
| -- On the other end, the old system makes it easy to draw very detailed designs since full control is given to the designer | |||||
| -- as long as he/she is familiar with Terminal Escape Sequences and their characteristics; the new system can still | |||||
| -- be used for detailed design, but the effort and discomfort levels go up considerably. | |||||
| local air_graphic_func = function() | |||||
| return { | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " .::' .." .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " .::: ..... '::." .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " :::::::::::::. :::." .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " :::'::''::::::::::::" .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " .:..:' :::::::::::" .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " ::::::: :::::::::'" .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " . :::::::'.::::::::" .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " ..::.::::::::::::::::" .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. "..'::.: ':::::::::::::'" .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. "':::::::::.'::::::::'" .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " :::::.::::::::." .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " '::::::::::::::" .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " ':::::::::::" .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " :::::::::::" .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " :::::::::::." .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " :::::::::::.." .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " .......:::::::::::::::...." .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " :'....'''''::::::::. '''''::::.." .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " '''':::::::::::.'' .: .:::" .. color.resetfg() ), | |||||
| color.highlight(color.escapefg(color.getTheme(color.LOGO)) .. " ..::::::::'" .. color.resetfg() ), | |||||
| } | |||||
| end | |||||
| return { | |||||
| logo = { | |||||
| graphic = air_graphic_func, | |||||
| shift = {x = 0, y = 1 }, | |||||
| } -- end logo | |||||
| } | |||||