From 6760653d628b9cdabce5f56c53db00eba6aaa90e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 1 Jan 2023 18:54:05 +0100 Subject: [PATCH] Demos: Remove "Fire" application This served no purpose other than looking somewhat neat. --- Base/res/apps/Fire.af | 4 - Base/res/icons/16x16/app-fire.png | Bin 594 -> 0 bytes Base/res/icons/32x32/app-fire.png | Bin 7758 -> 0 bytes Userland/Demos/CMakeLists.txt | 1 - Userland/Demos/Fire/CMakeLists.txt | 11 -- Userland/Demos/Fire/Fire.cpp | 228 ----------------------------- 6 files changed, 244 deletions(-) delete mode 100644 Base/res/apps/Fire.af delete mode 100644 Base/res/icons/16x16/app-fire.png delete mode 100644 Base/res/icons/32x32/app-fire.png delete mode 100644 Userland/Demos/Fire/CMakeLists.txt delete mode 100644 Userland/Demos/Fire/Fire.cpp diff --git a/Base/res/apps/Fire.af b/Base/res/apps/Fire.af deleted file mode 100644 index 37d90edd2ef..00000000000 --- a/Base/res/apps/Fire.af +++ /dev/null @@ -1,4 +0,0 @@ -[App] -Name=Fire -Executable=/bin/Fire -Category=Demos diff --git a/Base/res/icons/16x16/app-fire.png b/Base/res/icons/16x16/app-fire.png deleted file mode 100644 index 20ab485eaa2da390278229bdecbffcff0e180e88..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 594 zcmV-Y002y>e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00Fv5L_t(I%cYVnZyP}nhM%)6 z-OD;~Sq>gN)?+;uvl^PUFwj4v&@iwtEM+k?>p`=c_29yR!?s`>H&IooQdS!6?9Ax> z7;V$GEpIt1-gy2AFp2Wt0R4;MeX98>XkHHXqHOIo=zUM&rfo~xwtT;>_jBB|ZF&4q zYq#%S_g=;-L-R0Frqf@H?B-hQ3=)*%^hZH2%05w6r-`zgX(mxl6Xn_aC91^BhBA8v z^r#ju8_LGukZIOmFL0bFo#6fqhb?%f1R$V4((DuEZh+GQM~6FLw-x>^O7rt$TM&Gi zVKkT>KKF3R(5HHj1I%aWQdME9wnEVS_|z89kPH^D14F7lL!bbnzH@+eLOEChY!vJ0 z4O0*i*eJ{)JU}7@o`j+z2+%nQ0}Y1G&MHhqC&GmHmD+nF1eOCu5GItXie;OK-p~?6 zC)SY+Z32o85<+E625l#7f!m&R8~y5QG_FMjkqpo#+ypcHmVBf=C9b zDsG;h-WRzO()AOiZXz!y-NZVjkzsQH;CLLbAmemjJueRoL+zi> g`)hv~4!FV!Z diff --git a/Base/res/icons/32x32/app-fire.png b/Base/res/icons/32x32/app-fire.png deleted file mode 100644 index 979d1ad5a30c20e619387e9dc4319b3d39758e9d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7758 zcmeHKc|4SD+a44WsVrHFF?Jd=!^|);_MJg9sSp~oFflXCjGYvbrASFAl_DuhMUiMB zWKWAMQL^NbrEF>8y+=Kz?|r`K{hr_Nd;e?ZchB6{bsgt%p4V}m=XKv#f|G-lh>(mB z2m}(bu{Os8|6uMV$PfIo!@{OPAfdxy+jesB#9**Li%F&VQNWx~e+rlqLZgB}Azeio zF3C#QM9dchh2%{>vo=D-U&(&_xYu6&a(*~gQHs zgo5%xzxgC6x(`z@`(9$r{!iVJQ=zZQCG_IhE>oKpdxPcqhTAZ9ccm^( z8A|oZmxPRU$j6O0ne50N9+lbC;WRnCzk>f$K;zK%#;aPwn7WxTd~3&B$HKl7U%LYp z!ZZ<%lOEBEW$Pm*y?I{GXSIdCI@5QK&+L^!Z0%K%30uMXGyUW!m*evZ4Z}@e2Ny)0 zObzEmbgKk(qLQQTOthzb?l>E2`lYdnxR<&Rbhm->ECoCoJmK8j%epg)5NnUf4s#D} zk@6r!nwWwn5#9irpa(gCijm`J%0r zLgvkm7R|920)q%fUP&7N_X1tNmSX9#GI+|^>C4CDsn19;vi=bjM@`Kv>Wb~&4hB__Csm(XC zI;oy}V`Ci(?=)PxT%_f2_Nckd(LC$pDv@TTn}T|1!|p*Z>2socS~l*C`ut_?V)+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j8?&EYQ|*6$x_4qk&< zCiNklr9|Ipf2gZIlRCAVE{zfOj8U)}o|YAt&uby2lyJ66S^KuQ2IU0kp35xF#*FmG zIR=DpmcH%~v{m)&#~@psVCMzlY47PtUX=)C&9Tz`YB_VDA%*7da1|w5?wgFEoV@aw zFHg{8C5|2@9dCUC|5izI2W6$; zwGzKX?RJRZp`Lm{@skf8&8<>ASRgLx7d^p-g!l$tN9K86ZYLWoCxIB4%jjK-q!Yv5Z^0-W6lY!W+!}UAh`=?gF;i<0o z+N$o$$Z>J)&aG|Bn;nfP)FF)+%;Fd3?hRbH-NgwE(<{=^)O{=*A343{E2!)>)?nYb zb)ab7yK7&hrG#g9Y|FHW@+J`X!4v9E*XvsDDIBOQUI@F;t3#R(-jA3b6)Oqrf9Nko wWeCdNf+UmL4Fm@kMy4TbqhS|WiJ1K`v8lI*?}XQYfy4pXSU8wpG2I>gFBUU}$p8QV diff --git a/Userland/Demos/CMakeLists.txt b/Userland/Demos/CMakeLists.txt index 6112a529947..7c0655c1604 100644 --- a/Userland/Demos/CMakeLists.txt +++ b/Userland/Demos/CMakeLists.txt @@ -1,7 +1,6 @@ add_subdirectory(CatDog) add_subdirectory(Cube) add_subdirectory(Eyes) -add_subdirectory(Fire) add_subdirectory(LibGfxDemo) add_subdirectory(LibGfxScaleDemo) add_subdirectory(Mandelbrot) diff --git a/Userland/Demos/Fire/CMakeLists.txt b/Userland/Demos/Fire/CMakeLists.txt deleted file mode 100644 index 8b467398790..00000000000 --- a/Userland/Demos/Fire/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -serenity_component( - Fire - TARGETS Fire -) - -set(SOURCES - Fire.cpp -) - -serenity_app(Fire ICON app-fire) -target_link_libraries(Fire PRIVATE LibGUI LibCore LibGfx LibMain) diff --git a/Userland/Demos/Fire/Fire.cpp b/Userland/Demos/Fire/Fire.cpp deleted file mode 100644 index 9daa47e52f3..00000000000 --- a/Userland/Demos/Fire/Fire.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 2018-2021, Andreas Kling - * Copyright (c) 2022, the SerenityOS developers. - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -/* Fire.cpp - a (classic) graphics demo for Serenity, by pd. - * heavily based on the Fabien Sanglard's article: - * http://fabiensanglard.net/doom_fire_psx/index.html - * - * Future directions: - * [X] This does suggest the need for a palletized graphics surface. Thanks kling! - * [X] alternate column updates, or vertical interlacing. this would certainly alter - * the effect, but the update load would be halved. - * [/] scaled blit - * [ ] dithering? - * [X] inlining rand() - * [/] precalculating and recycling random data - * [ ] rework/expand palette - * [ ] switch to use tsc values for perf check - * [ ] handle mouse events differently for smoother painting (queue) - * [ ] handle fire bitmap edges better - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static constexpr int FIRE_WIDTH = 320; -static constexpr int FIRE_HEIGHT = 200; -static constexpr int FIRE_MAX = 29; - -static constexpr Array s_palette = { - Color(0x07, 0x07, 0x07), Color(0x1F, 0x07, 0x07), Color(0x2F, 0x0F, 0x07), - Color(0x47, 0x0F, 0x07), Color(0x57, 0x17, 0x07), Color(0x67, 0x1F, 0x07), - Color(0x77, 0x1F, 0x07), Color(0x9F, 0x2F, 0x07), Color(0xAF, 0x3F, 0x07), - Color(0xBF, 0x47, 0x07), Color(0xC7, 0x47, 0x07), Color(0xDF, 0x4F, 0x07), - Color(0xDF, 0x57, 0x07), Color(0xD7, 0x5F, 0x07), Color(0xD7, 0x5F, 0x07), - Color(0xD7, 0x67, 0x0F), Color(0xCF, 0x6F, 0x0F), Color(0xCF, 0x7F, 0x0F), - Color(0xCF, 0x87, 0x17), Color(0xC7, 0x87, 0x17), Color(0xC7, 0x8F, 0x17), - Color(0xC7, 0x97, 0x1F), Color(0xBF, 0x9F, 0x1F), Color(0xBF, 0xA7, 0x27), - Color(0xBF, 0xAF, 0x2F), Color(0xB7, 0xAF, 0x2F), Color(0xB7, 0xB7, 0x37), - Color(0xCF, 0xCF, 0x6F), Color(0xEF, 0xEF, 0xC7), Color(0xFF, 0xFF, 0xFF) -}; - -class Fire : public GUI::Frame { - C_OBJECT(Fire); - -public: - virtual ~Fire() override = default; - void set_stat_label(RefPtr l) { stats = l; }; - -private: - Fire(); - RefPtr bitmap; - RefPtr stats; - - virtual void paint_event(GUI::PaintEvent&) override; - virtual void timer_event(Core::TimerEvent&) override; - virtual void mousedown_event(GUI::MouseEvent& event) override; - virtual void mousemove_event(GUI::MouseEvent& event) override; - virtual void mouseup_event(GUI::MouseEvent& event) override; - - bool dragging; - int timeAvg; - int cycles; - int phase; -}; - -Fire::Fire() -{ - bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::Indexed8, { FIRE_WIDTH, FIRE_HEIGHT }).release_value_but_fixme_should_propagate_errors(); - - /* Initialize fire palette */ - for (int i = 0; i < 30; i++) - bitmap->set_palette_color(i, s_palette[i]); - - /* Set remaining entries to white */ - for (int i = 30; i < 256; i++) - bitmap->set_palette_color(i, Color::White); - - dragging = false; - timeAvg = 0; - cycles = 0; - phase = 0; - - srand(time(nullptr)); - stop_timer(); - start_timer(20); - - /* Draw fire "source" on bottom row of pixels */ - for (int i = 0; i < FIRE_WIDTH; i++) - bitmap->scanline_u8(bitmap->height() - 1)[i] = FIRE_MAX; - - /* Set off initital paint event */ - // update(); -} - -void Fire::paint_event(GUI::PaintEvent& event) -{ - GUI::Frame::paint_event(event); - auto timer = Core::ElapsedTimer::start_new(); - - GUI::Painter painter(*this); - painter.add_clip_rect(event.rect()); - painter.draw_scaled_bitmap(frame_inner_rect(), *bitmap, bitmap->rect()); - - timeAvg += timer.elapsed(); - cycles++; -} - -void Fire::timer_event(Core::TimerEvent&) -{ - /* Update only even or odd columns per frame... */ - phase++; - if (phase > 1) - phase = 0; - - /* Paint our palettized buffer to screen */ - for (int px = 0 + phase; px < FIRE_WIDTH; px += 2) { - for (int py = 1; py < FIRE_HEIGHT; py++) { - int rnd = rand() % 3; - - /* Calculate new pixel value, don't go below 0 */ - u8 nv = bitmap->scanline_u8(py)[px]; - if (nv > 0) - nv -= (rnd & 1); - - /* ...sigh... */ - int epx = px + (1 - rnd); - if (epx < 0) - epx = 0; - else if (epx > FIRE_WIDTH) - epx = FIRE_WIDTH; - - bitmap->scanline_u8(py - 1)[epx] = nv; - } - } - - if ((cycles % 50) == 0) { - dbgln("{} total cycles. finished 50 in {} ms, avg {} ms", cycles, timeAvg, timeAvg / 50); - stats->set_text(DeprecatedString::formatted("{} ms", timeAvg / 50)); - timeAvg = 0; - } - - update(); -} - -void Fire::mousedown_event(GUI::MouseEvent& event) -{ - if (event.button() == GUI::MouseButton::Primary) - dragging = true; - - return GUI::Widget::mousedown_event(event); -} - -/* FIXME: needs to account for the size of the window rect */ -void Fire::mousemove_event(GUI::MouseEvent& event) -{ - if (dragging) { - int ypos = event.y() / 2; - int xpos = event.x() / 2; - if (bitmap->rect().shrunken(1, 1, 0, 0).contains(xpos, ypos)) { - bitmap->scanline_u8(ypos - 1)[xpos] = FIRE_MAX + 5; - bitmap->scanline_u8(ypos - 1)[xpos + 1] = FIRE_MAX + 5; - bitmap->scanline_u8(ypos)[xpos] = FIRE_MAX + 5; - bitmap->scanline_u8(ypos)[xpos + 1] = FIRE_MAX + 5; - } - } - - return GUI::Widget::mousemove_event(event); -} - -void Fire::mouseup_event(GUI::MouseEvent& event) -{ - if (event.button() == GUI::MouseButton::Primary) - dragging = false; - - return GUI::Widget::mouseup_event(event); -} - -ErrorOr serenity_main(Main::Arguments arguments) -{ - auto app = TRY(GUI::Application::try_create(arguments)); - - TRY(Core::System::pledge("stdio recvfd sendfd rpath")); - TRY(Core::System::unveil("/res", "r")); - TRY(Core::System::unveil(nullptr, nullptr)); - - auto window = TRY(GUI::Window::try_create()); - window->set_double_buffering_enabled(false); - window->set_title("Fire"); - window->set_resizable(false); - window->resize(FIRE_WIDTH * 2 + 4, FIRE_HEIGHT * 2 + 4); - - auto file_menu = TRY(window->try_add_menu("&File")); - TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }))); - - auto fire = TRY(window->try_set_main_widget()); - - auto time = TRY(fire->try_add()); - time->set_relative_rect({ 0, 4, 40, 10 }); - time->move_by({ window->width() - time->width(), 0 }); - fire->set_stat_label(time); - - window->show(); - - auto app_icon = GUI::Icon::default_icon("app-fire"sv); - window->set_icon(app_icon.bitmap_for_size(16)); - - return app->exec(); -}