Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
add BOF_RGBA, bof_point_2D,3D,4D, BOF_SIZE template
  • Loading branch information
onbings committed Dec 21, 2023
1 parent 04006d0 commit 92fadad
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 100 deletions.
15 changes: 0 additions & 15 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ AlignConsecutiveMacros:
PadOperators: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
Expand Down Expand Up @@ -70,13 +67,10 @@ BraceWrapping:
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAfterAttributes: Never
BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Custom
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
Expand Down Expand Up @@ -125,17 +119,11 @@ IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
Decimal: 0
Hex: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
Expand All @@ -162,14 +150,11 @@ QualifierAlignment: Leave
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
# Revision: 5.0
#
# History: 05 June 2004: BHA: Initial version
#compile with emscripten: https://thatonegamedev.com/cpp/programming-a-c-game-for-the-web-emscripten/
#emcmake cmake -S C:/pro/github/bofstd -D__EMSCRIPTEN__=1 -B C:/bld/bofstd-web -DCMAKE_TOOLCHAIN_FILE=C:/pro/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=wasm32-emscripten

#cmake -DCMAKE_TOOLCHAIN_FILE=C:/pro/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static-md -DVCPKG_HOST_TRIPLET=x64-windows-static-md -DBUILD_SHARED_LIBS=OFF -DVCPKG_OVERLAY_PORTS=C:/pro/github/onbings-vcpkg-registry/ports -DCMAKE_INSTALL_PREFIX=C:\tmp\bofstd -B C:/bld/bofstd -S C:/pro/github/bofstd
#cmake -DCMAKE_TOOLCHAIN_FILE=C:/pro/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DVCPKG_HOST_TRIPLET=x64-windows-static -DBUILD_SHARED_LIBS=OFF -DVCPKG_OVERLAY_PORTS=C:/pro/github/onbings-vcpkg-registry/ports -DCMAKE_INSTALL_PREFIX=C:\tmp\bofstd -B C:/bld/bofstd -S C:/pro/github/bofstd
#cmake --build . --config Release -- -j 16
#cmake --install . --config Debug
cmake_minimum_required(VERSION 3.25)
Expand Down
2 changes: 0 additions & 2 deletions Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ endif()
# ===========================
# == REQUIRED DEPENDENCIES ==
# ===========================

if(NOT TARGET jsoncpp_object)
find_package_dependency(jsoncpp REQUIRED)

Expand All @@ -46,4 +45,3 @@ find_package_dependency(spdlog REQUIRED)
find_package_dependency(fmt REQUIRED)
find_package_dependency(date REQUIRED)


26 changes: 1 addition & 25 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

include(GNUInstallDirs)
# get_cmake_property(_variableNames VARIABLES)
# list (SORT _variableNames)
Expand Down Expand Up @@ -340,35 +339,14 @@ target_link_libraries(bofstd
PRIVATE
jsoncpp::jsoncpp
spdlog::spdlog
# Qt5::Widgets
# mediainfo
# yuv
# asio::asio
# czmq
# libzmq
# libzmq-static
# czmq-static
# ZLIB::ZLIB
# zen
# OpenSSL::SSL
# OpenSSL::Crypto
# ${Boost_LIBRARIES}
# ${FFMPEG_LIBRARIES}
)
#message("=Boost_INCLUDE_DIRS==============>"${Boost_INCLUDE_DIRS})
#message("=Boost_LIBRARIES==============>"${Boost_LIBRARIES})
#message("=FFMPEG_INCLUDE_DIRS==============>"${FFMPEG_INCLUDE_DIRS})
#message("=FFMPEG_LIBRARIES==============>"${FFMPEG_LIBRARIES})
)
if(WIN32)
target_link_libraries(bofstd
PUBLIC
Ws2_32
Iphlpapi
Winmm
Rpcrt4

PRIVATE
# Qt5::Widgets
)
else()
if( ANDROID )
Expand Down Expand Up @@ -403,8 +381,6 @@ target_compile_features(bofstd
cxx_std_14
)



# ================
# == VERSIONING ==
# ================
Expand Down
4 changes: 2 additions & 2 deletions lib/include/bofstd/bofconio.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ class BOFSTD_EXPORT BofConio final
BOFERR SetTextAttribute(uint32_t _TextAttributeFlag_U32); // Use CONIO_TEXT_ATTRIBUTE_FLAG enum ored value
BOFERR SetForegroundTextColor(CONIO_TEXT_COLOR _ForegroundColor_E);
BOFERR SetBackgroundTextColor(CONIO_TEXT_COLOR _BackgroundColor_E);
BOFERR SetForegroundTextColor(BOF_RGBA _ForegroundColor_E);
BOFERR SetBackgroundTextColor(BOF_RGBA _BackgroundColor_X);
BOFERR SetForegroundTextColor(BOF_RGBA<uint8_t> _ForegroundColor_E);
BOFERR SetBackgroundTextColor(BOF_RGBA<uint8_t> _BackgroundColor_X);

BOFERR SetTextCursorState(CONIO_TEXT_CURSOR_STATE _CursorState_E);
BOFERR SetTextCursorPosition(uint32_t _x_U32, uint32_t _y_U32);
Expand Down
221 changes: 192 additions & 29 deletions lib/include/bofstd/bofstd.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,61 +76,224 @@ struct BOFSTDPARAM
Version_S = "";
}
};

/*!
* Summary
* Definition of a color in the RGBA color space
*/
template <typename T> // Can be uint8_t or float
struct BOF_RGBA
{
uint8_t r_U8; /*! Color R component(Red)*/
uint8_t g_U8; /*! Color G component(Greeen)*/
uint8_t b_U8; /*! Color B component(Blue)*/
uint8_t a_U8; /*! Color alpha component(Opacity)*/
T r; /*! Color R component(Red)*/
T g; /*! Color G component(Greeen)*/
T b; /*! Color B component(Blue)*/
T a; /*! Color alpha component(Opacity)*/
BOF_RGBA()
{
Reset();
}

BOF_RGBA(uint8_t _r_U8, uint8_t _g_U8, uint8_t _b_U8, uint8_t _a_U8)
BOF_RGBA(T _r, T _g, T _b, T _a)
{
r_U8 = _r_U8;
g_U8 = _g_U8;
b_U8 = _b_U8;
a_U8 = _a_U8;
r = _r;
g = _g;
b = _b;
a = _a;
}

void Reset()
{
r_U8 = 0;
g_U8 = 0;
b_U8 = 0;
a_U8 = 0;
r = 0;
g = 0;
b = 0;
a = 0;
}
};
/*!
* Summary
* Definition of a size entity
*/
template <typename T>
struct BOF_YUVA
{
T y; /*! Color Y component(Luminance)*/
T u; /*! Color U component(Chrominance)*/
T v; /*! Color V component(Chrominance)*/
T a; /*! Color alpha component(Opacity)*/
BOF_YUVA()
{
Reset();
}

BOF_YUVA(T _y, T _u, T _v, T _a)
{
y = _y;
u = _u;
v = _v;
a = _a;
}

void Reset()
{
y = 0;
u = 0;
v = 0;
a = 0;
}
};

template <typename T>
struct BOF_SIZE
{
uint32_t Width_U32; /*! Width value*/
uint32_t Height_U32; /*! Height value*/
T Width; /*! Width value*/
T Height; /*! Height value*/
BOF_SIZE()
{
Reset();
}

BOF_SIZE(uint32_t _Width_U32, uint32_t _Height_U32)
BOF_SIZE(T _Width, T _Height)
{
Width = _Width;
Height = _Height;
}

void Reset()
{
Width = 0;
Height = 0;
}
};
template <typename T>
struct BOF_RECT;

template <typename T>
struct BOF_POINT_2D
{
T x; /*! Point x coordinate*/
T y; /*! Point y coordinate*/
BOF_POINT_2D()
{
Reset();
}

BOF_POINT_2D(T _x, T _y)
{
x = _x;
y = _y;
}

void Reset()
{
x = 0;
y = 0;
}

bool IsInside(const BOF_RECT<T> &_rBox) const
{
return ((x >= _rBox.Left) && (x <= _rBox.Right) && (y >= _rBox.Top) && (y <= _rBox.Bottom));
}
};

template <typename T>
struct BOF_RECT
{
T Left; /*! Rectangle zone left x position*/
T Right; /*! Rectangle zone right x position outside of rect: Width_U32 = (_rRect_X.Right_S32 - _rRect_X.Left_S32)*/
T Top; /*! Rectangle zone top y position*/
T Bottom; /*! Rectangle zone bottom y position outside of rect: Height_U32 = (_rRect_X.Bottom_S32 - _rRect_X.Top_S32);*/
BOF_RECT()
{
Reset();
}

BOF_RECT(BOF_POINT_2D<T> _TopLeft_X, BOF_POINT_2D<T> _BottomRight_X)
{
Top = _TopLeft_X.y;
Left = _TopLeft_X.x;
Bottom = _BottomRight_X.y;
Right = _BottomRight_X.x;
}

BOF_RECT(T _x, T _y, T _Width, T _Height)
{
Left = _x;
Right = _x + _Width;
Top = _y;
Bottom = _y + _Height;
}

void Reset()
{
Left = 0;
Right = 0;
Top = 0;
Bottom = 0;
}

bool IsInside(const BOF_RECT<T> &_rBox) const
{
return ((_rBox.Left <= Left) && (_rBox.Right >= Right) && (_rBox.Top <= Top) && (_rBox.Bottom >= Bottom));
}

T Width() const
{
return Right - Left;
}

T Height() const
{
return Bottom - Top;
}

BOF_SIZE<T> Size() const
{
return BOF_SIZE<T>(Width(), Height());
}
};
template <typename T>
struct BOF_POINT_3D
{
T x; /*! Point x coordinate*/
T y; /*! Point y coordinate*/
T z; /*! Point z coordinate*/
BOF_POINT_3D()
{
Reset();
}

BOF_POINT_3D(T _x, T _y, T _z)
{
x = _x;
y = _y;
z = _z;
}

void Reset()
{
x = 0;
y = 0;
z = 0;
}
};

template <typename T>
struct BOF_POINT_4D
{
T x; /*! Point x coordinate*/
T y; /*! Point y coordinate*/
T z; /*! Point z coordinate*/
T w; /*! Point w coordinate*/
BOF_POINT_4D()
{
Reset();
}

BOF_POINT_4D(T _x, T _y, T _z, T _w)
{
Width_U32 = _Width_U32;
Height_U32 = _Height_U32;
x = _x;
y = _y;
z = _z;
w = _w;
}

void Reset()
{
Width_U32 = 0;
Height_U32 = 0;
x = 0;
y = 0;
z = 0;
w = 0;
}
};

Expand Down
Loading

0 comments on commit 92fadad

Please sign in to comment.