From eef2514908cdec3ec02888b7467cc877d33c1ceb Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 30 May 2021 23:30:33 -0700 Subject: Run dos2unix all all files --- 3rdparty/imgui-node-editor/crude_json.cpp | 2 +- 3rdparty/imgui-node-editor/crude_json.h | 2 +- 3rdparty/imgui-node-editor/imgui_canvas.cpp | 2 +- 3rdparty/imgui-node-editor/imgui_canvas.h | 2 +- core/fonts/NotoSansSC-LICENSE.txt | 182 ++++++------- core/src/Utils/Color.hpp | 382 ++++++++++++++-------------- core/src/Utils/Size.hpp | 0 7 files changed, 286 insertions(+), 286 deletions(-) mode change 100755 => 100644 core/src/Utils/Size.hpp diff --git a/3rdparty/imgui-node-editor/crude_json.cpp b/3rdparty/imgui-node-editor/crude_json.cpp index f2b3ba5..34f117f 100644 --- a/3rdparty/imgui-node-editor/crude_json.cpp +++ b/3rdparty/imgui-node-editor/crude_json.cpp @@ -1,4 +1,4 @@ -// Crude implementation of JSON value object and parser. +// Crude implementation of JSON value object and parser. // // LICENSE // This software is dual-licensed to the public domain and under the following diff --git a/3rdparty/imgui-node-editor/crude_json.h b/3rdparty/imgui-node-editor/crude_json.h index 06eedd7..a95abb9 100644 --- a/3rdparty/imgui-node-editor/crude_json.h +++ b/3rdparty/imgui-node-editor/crude_json.h @@ -1,4 +1,4 @@ -// Crude implementation of JSON value object and parser. +// Crude implementation of JSON value object and parser. // // LICENSE // This software is dual-licensed to the public domain and under the following diff --git a/3rdparty/imgui-node-editor/imgui_canvas.cpp b/3rdparty/imgui-node-editor/imgui_canvas.cpp index df63a40..9c71051 100644 --- a/3rdparty/imgui-node-editor/imgui_canvas.cpp +++ b/3rdparty/imgui-node-editor/imgui_canvas.cpp @@ -1,4 +1,4 @@ -# define IMGUI_DEFINE_MATH_OPERATORS +# define IMGUI_DEFINE_MATH_OPERATORS # include "imgui_canvas.h" # include diff --git a/3rdparty/imgui-node-editor/imgui_canvas.h b/3rdparty/imgui-node-editor/imgui_canvas.h index 44f4347..acbb8ae 100644 --- a/3rdparty/imgui-node-editor/imgui_canvas.h +++ b/3rdparty/imgui-node-editor/imgui_canvas.h @@ -1,4 +1,4 @@ -// Canvas widget - view over infinite virtual space. +// Canvas widget - view over infinite virtual space. // // Canvas allows you to draw your widgets anywhere over infinite space and provide // view over it with support for panning and scaling. diff --git a/core/fonts/NotoSansSC-LICENSE.txt b/core/fonts/NotoSansSC-LICENSE.txt index 075d1ae..77b1731 100644 --- a/core/fonts/NotoSansSC-LICENSE.txt +++ b/core/fonts/NotoSansSC-LICENSE.txt @@ -1,91 +1,91 @@ -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -http://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/core/src/Utils/Color.hpp b/core/src/Utils/Color.hpp index 5f4691f..8e159ea 100644 --- a/core/src/Utils/Color.hpp +++ b/core/src/Utils/Color.hpp @@ -1,191 +1,191 @@ -#pragma once - -#include "Utils/Vector.hpp" -#include "Utils/fwd.hpp" - -#include -#include -#include -#include - -class RgbaColor -{ -public: - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t a; - -public: - constexpr RgbaColor() noexcept - : r{ 255 } - , g{ 255 } - , b{ 255 } - , a{ 255 } - { - } - - constexpr RgbaColor(float r, float g, float b, float a = 1.0f) noexcept - : r{ static_cast(r * 255.0f) } - , g{ static_cast(g * 255.0f) } - , b{ static_cast(b * 255.0f) } - , a{ static_cast(a * 255.0f) } - { - } - - constexpr RgbaColor(int r, int g, int b, int a = 255) noexcept - : r{ static_cast(r & 0xFF) } - , g{ static_cast(g & 0xFF) } - , b{ static_cast(b & 0xFF) } - , a{ static_cast(a & 0xFF) } - { - } - - constexpr RgbaColor(uint32_t rgba) noexcept - : r{ static_cast((rgba >> 0) & 0xFF) } - , g{ static_cast((rgba >> 8) & 0xFF) } - , b{ static_cast((rgba >> 16) & 0xFF) } - , a{ static_cast((rgba >> 24) & 0xFF) } - { - } - - constexpr uint32_t GetScalar() const noexcept - { - uint32_t res = 0; - res |= r << 24; - res |= g << 16; - res |= b << 8; - res |= a; - return res; - } - - constexpr void SetScalar(uint32_t scalar) noexcept - { - r = (scalar >> 0) & 0xFF; - g = (scalar >> 8) & 0xFF; - b = (scalar >> 16) & 0xFF; - a = (scalar >> 24) & 0xFF; - } - - constexpr float GetNormalizedRed() const noexcept - { - return r / 255.0f; - } - - constexpr float GetNormalizedGreen() const noexcept - { - return g / 255.0f; - } - - constexpr float GetNormalizedBlue() const noexcept - { - return b / 255.0f; - } - - constexpr float GetNormalizedAlpha() const noexcept - { - return a / 255.0f; - } - - constexpr Vec4i AsVec4i() const noexcept - { - return Vec4i{ r, g, b, a }; - } - - constexpr Vec4f AsVec4f() const noexcept - { - return Vec4f{ - GetNormalizedRed(), - GetNormalizedGreen(), - GetNormalizedBlue(), - GetNormalizedAlpha(), - }; - } - - ImVec4 AsImVec() const - { - auto v = AsVec4f(); - return ImVec4{ v.x, v.y, v.z, v.w }; - } - - ImColor AsImColor() const - { - auto v = AsVec4f(); - return ImColor{ v.x, v.y, v.z, v.w }; - } - - constexpr void SetVec(const Vec4f& vec) noexcept - { - r = (uint8_t)(vec.x * 255.0f); - g = (uint8_t)(vec.y * 255.0f); - b = (uint8_t)(vec.z * 255.0f); - a = (uint8_t)(vec.w * 255.0f); - } - - // Forward declaring because cyclic reference between RgbaColor and HsvColor - constexpr HsvColor ToHsv() const noexcept; - - friend constexpr bool operator==(const RgbaColor&, const RgbaColor&) noexcept = default; -}; - -class HsvColor -{ -public: - float h; - float s; - float v; - float a; - -public: - constexpr HsvColor() noexcept - : h{ 0.0f } - , s{ 0.0f } - , v{ 1.0f } - , a{ 1.0f } - { - } - - constexpr HsvColor(float h, float s, float v, float a) noexcept - : h{ h } - , s{ s } - , v{ v } - , a{ a } - { - } - - // Forward declaring because cyclic reference between RgbaColor and HsvColor - constexpr RgbaColor ToRgba() const noexcept; -}; - -constexpr HsvColor RgbaColor::ToHsv() const noexcept -{ - float fr = GetNormalizedRed(); - float fg = GetNormalizedBlue(); - float fb = GetNormalizedGreen(); - float fa = GetNormalizedAlpha(); - - auto p = fg < fb ? Vec4f{ fb, fg, -1, 2.0f / 3.0f } : Vec4f{ fg, fb, 0, -1.0f / 3.0f }; - auto q = fr < p.x ? Vec4f{ p.x, p.y, p.w, fr } : Vec4f{ fr, p.y, p.z, p.x }; - float c = q.x - std::min(q.w, q.y); - float h = std::abs((q.w - q.y) / (6 * c + std::numeric_limits::epsilon()) + q.z); - - Vec3f hcv{ h, c, q.x }; - float s = hcv.y / (hcv.z + std::numeric_limits::epsilon()); - return HsvColor(hcv.x, s, hcv.z, fa); -} - -constexpr RgbaColor HsvColor::ToRgba() const noexcept -{ - float r = std::abs(h * 6 - 3) - 1; - float g = 2 - std::abs(h * 6 - 2); - float b = 2 - std::abs(h * 6 - 4); - - auto rgb = Vec3f{ - std::clamp(r, 0.0f, 1.0f), - std::clamp(g, 0.0f, 1.0f), - std::clamp(b, 0.0f, 1.0f), - }; - auto vc = (rgb - Vec3f{ 0, 0, 0 }) * s + Vec3f{ 1, 1, 1 } * v; - - return RgbaColor(vc.x, vc.y, vc.z, a); -} +#pragma once + +#include "Utils/Vector.hpp" +#include "Utils/fwd.hpp" + +#include +#include +#include +#include + +class RgbaColor +{ +public: + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + +public: + constexpr RgbaColor() noexcept + : r{ 255 } + , g{ 255 } + , b{ 255 } + , a{ 255 } + { + } + + constexpr RgbaColor(float r, float g, float b, float a = 1.0f) noexcept + : r{ static_cast(r * 255.0f) } + , g{ static_cast(g * 255.0f) } + , b{ static_cast(b * 255.0f) } + , a{ static_cast(a * 255.0f) } + { + } + + constexpr RgbaColor(int r, int g, int b, int a = 255) noexcept + : r{ static_cast(r & 0xFF) } + , g{ static_cast(g & 0xFF) } + , b{ static_cast(b & 0xFF) } + , a{ static_cast(a & 0xFF) } + { + } + + constexpr RgbaColor(uint32_t rgba) noexcept + : r{ static_cast((rgba >> 0) & 0xFF) } + , g{ static_cast((rgba >> 8) & 0xFF) } + , b{ static_cast((rgba >> 16) & 0xFF) } + , a{ static_cast((rgba >> 24) & 0xFF) } + { + } + + constexpr uint32_t GetScalar() const noexcept + { + uint32_t res = 0; + res |= r << 24; + res |= g << 16; + res |= b << 8; + res |= a; + return res; + } + + constexpr void SetScalar(uint32_t scalar) noexcept + { + r = (scalar >> 0) & 0xFF; + g = (scalar >> 8) & 0xFF; + b = (scalar >> 16) & 0xFF; + a = (scalar >> 24) & 0xFF; + } + + constexpr float GetNormalizedRed() const noexcept + { + return r / 255.0f; + } + + constexpr float GetNormalizedGreen() const noexcept + { + return g / 255.0f; + } + + constexpr float GetNormalizedBlue() const noexcept + { + return b / 255.0f; + } + + constexpr float GetNormalizedAlpha() const noexcept + { + return a / 255.0f; + } + + constexpr Vec4i AsVec4i() const noexcept + { + return Vec4i{ r, g, b, a }; + } + + constexpr Vec4f AsVec4f() const noexcept + { + return Vec4f{ + GetNormalizedRed(), + GetNormalizedGreen(), + GetNormalizedBlue(), + GetNormalizedAlpha(), + }; + } + + ImVec4 AsImVec() const + { + auto v = AsVec4f(); + return ImVec4{ v.x, v.y, v.z, v.w }; + } + + ImColor AsImColor() const + { + auto v = AsVec4f(); + return ImColor{ v.x, v.y, v.z, v.w }; + } + + constexpr void SetVec(const Vec4f& vec) noexcept + { + r = (uint8_t)(vec.x * 255.0f); + g = (uint8_t)(vec.y * 255.0f); + b = (uint8_t)(vec.z * 255.0f); + a = (uint8_t)(vec.w * 255.0f); + } + + // Forward declaring because cyclic reference between RgbaColor and HsvColor + constexpr HsvColor ToHsv() const noexcept; + + friend constexpr bool operator==(const RgbaColor&, const RgbaColor&) noexcept = default; +}; + +class HsvColor +{ +public: + float h; + float s; + float v; + float a; + +public: + constexpr HsvColor() noexcept + : h{ 0.0f } + , s{ 0.0f } + , v{ 1.0f } + , a{ 1.0f } + { + } + + constexpr HsvColor(float h, float s, float v, float a) noexcept + : h{ h } + , s{ s } + , v{ v } + , a{ a } + { + } + + // Forward declaring because cyclic reference between RgbaColor and HsvColor + constexpr RgbaColor ToRgba() const noexcept; +}; + +constexpr HsvColor RgbaColor::ToHsv() const noexcept +{ + float fr = GetNormalizedRed(); + float fg = GetNormalizedBlue(); + float fb = GetNormalizedGreen(); + float fa = GetNormalizedAlpha(); + + auto p = fg < fb ? Vec4f{ fb, fg, -1, 2.0f / 3.0f } : Vec4f{ fg, fb, 0, -1.0f / 3.0f }; + auto q = fr < p.x ? Vec4f{ p.x, p.y, p.w, fr } : Vec4f{ fr, p.y, p.z, p.x }; + float c = q.x - std::min(q.w, q.y); + float h = std::abs((q.w - q.y) / (6 * c + std::numeric_limits::epsilon()) + q.z); + + Vec3f hcv{ h, c, q.x }; + float s = hcv.y / (hcv.z + std::numeric_limits::epsilon()); + return HsvColor(hcv.x, s, hcv.z, fa); +} + +constexpr RgbaColor HsvColor::ToRgba() const noexcept +{ + float r = std::abs(h * 6 - 3) - 1; + float g = 2 - std::abs(h * 6 - 2); + float b = 2 - std::abs(h * 6 - 4); + + auto rgb = Vec3f{ + std::clamp(r, 0.0f, 1.0f), + std::clamp(g, 0.0f, 1.0f), + std::clamp(b, 0.0f, 1.0f), + }; + auto vc = (rgb - Vec3f{ 0, 0, 0 }) * s + Vec3f{ 1, 1, 1 } * v; + + return RgbaColor(vc.x, vc.y, vc.z, a); +} diff --git a/core/src/Utils/Size.hpp b/core/src/Utils/Size.hpp old mode 100755 new mode 100644 -- cgit v1.2.3-70-g09d2