From 4803250c4fb17bdfa7964d2b88a4f1e6356c2d99 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Sun, 7 Jun 2020 09:18:24 +0200 Subject: [PATCH] git.vdm.dev/octoleo --- .gitignore | 2 ++ CMakeLists.txt | 8 ++++++ README.md | 18 ++++++++++++++ src/donut.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 src/donut.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8b1aab2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +cmake-build-debug \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5431026 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.20) +project(donut) + +set(CMAKE_CXX_STANDARD 17) + +add_executable(donut src/donut.cpp) + +# https://www.dropbox.com/s/79ga2m7p2bnj1ga/donut_deobfuscated.c?dl=0 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..fbb3865 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# 3D Donut + +> Little C++ script to display a 3D Donut rotating in terminal. + +Copyright 2020 `` + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/donut.cpp b/src/donut.cpp new file mode 100644 index 0000000..8d2dc7e --- /dev/null +++ b/src/donut.cpp @@ -0,0 +1,66 @@ +/** + * Copyright 2020 + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + **/ + +#include +#include +#include +#include + +using namespace std; + +int main() { + float A = 0, B = 0; + float i, j; + int k; + float z[1790]; + char b[1990]; + printf("\x1b[2J"); + for (;;) { + memset(b, 32, 1990); + memset(z, 0, 7040); + for (j = 0; j < 6.28; j += 0.07) { + for (i = 0; i < 6.28; i += 0.02) { + float c = sin(i); + float d = cos(j); + float e = sin(A); + float f = sin(j); + float g = cos(A); + float h = d + 2; + float D = 1 / (c * h * e + f * g + 5); + float l = cos(i); + float m = cos(B); + float n = sin(B); + float t = c * h * g - f * e; + int x = 40 + 30 * D * (l * h * m - t * n); + int y = 12 + 15 * D * (l * h * n + t * m); + int o = x + 80 * y; + int N = 8 * ((f * e - c * d * g) * m - c * d * e - f * g - l * d * n); + if (22 > y && y > 0 && x > 0 && 80 > x && D > z[o]) { + z[o] = D; + b[o] = ".,-~:;=!*#$@"[N > 0 ? N : 0]; + } + } + } + printf("\x1b[H"); + for (k = 0; k < 1991; k++) { + putchar(k % 80 ? b[k] : 10); + A += 0.00004; + B += 0.00002; + } + usleep(30000); + } + return 0; +}