Skip to content

Commit

Permalink
Reformat literally everything
Browse files Browse the repository at this point in the history
  • Loading branch information
robotman2412 committed Dec 9, 2023
1 parent f28212f commit 713cb62
Show file tree
Hide file tree
Showing 34 changed files with 8,280 additions and 7,543 deletions.
193 changes: 193 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
---
Language: Cpp
BasedOnStyle: ''

# Basic indentation and spacing rules:
IndentWidth: 4
ContinuationIndentWidth: 4
TabWidth: 4
UseCRLF: false
UseTab: Never
ColumnLimit: 120
MaxEmptyLinesToKeep: 3

IndentCaseLabels: true
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentWrappedFunctionNames: true

AlignConsecutiveAssignments:
# The column at which the = starts is constant among a block of definitions.
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignCompound: true
PadOperators: true
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignConsecutiveDeclarations:
# The column at which the name starts is constant among a block of declarations / definitions.
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true

# configure braces and parens:
BraceWrapping:
AfterEnum: false # The { is on the same line as the struct, union or enum keyword.
AfterStruct: false # The { is on the same line as the struct, union or enum keyword.
AfterUnion: false # The { is on the same line as the struct, union or enum keyword.
AfterFunction: false # The { is on the same line as the ).

AfterCaseLabel: false
AfterControlStatement: Never

AfterExternBlock: false
BeforeElse: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true

AllowShortFunctionsOnASingleLine: None # never collapse empty functions
AllowShortBlocksOnASingleLine: Never # never make single-line blocks
AllowShortIfStatementsOnASingleLine: Never # never make single-line ifs
AllowShortLoopsOnASingleLine: true # allow single-line loops
AllowShortEnumsOnASingleLine: true # allow enum { FOO = 10 };

# configure general code:

# The = has at least one space to the left and one space to the right.
SpaceBeforeAssignmentOperators: true

# configure pointers:

PointerAlignment: Right # The * is at the function name and has at least one space from the type before it.
QualifierAlignment: Right # The const is to the left of the type (unless the pointer is also a constant).
SpaceAroundPointerQualifiers: After

# include sorting:

SortIncludes: CaseInsensitive
IncludeBlocks: Regroup
IncludeCategories:
# External headers
- Regex: '^\<('
Priority: 3
SortPriority: 0
CaseSensitive: false

# System headers
- Regex: '^\<(std.*|inttypes)'
Priority: 2
SortPriority: 0
CaseSensitive: false

# Assume project header
- Regex: '^\".*'
Priority: 1
SortPriority: 0
CaseSensitive: false

# all other options

# all arguments on one or on a separate line, use closing parens on separate line
BinPackArguments: false
BinPackParameters: false
AlignAfterOpenBracket: BlockIndent
AllowAllArgumentsOnNextLine: false

BitFieldColonSpacing: Both # int bf : 2;

AlignEscapedNewlines: Right

AllowShortCaseLabelsOnASingleLine: true # don't split up "case x: return value;"

BreakBeforeTernaryOperators: true

# default values:

# AlignArrayOfStructures: None
# AlignOperands: Align
# AlignTrailingComments: true
# AllowAllParametersOfDeclarationOnNextLine: true

# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
# AlwaysBreakBeforeMultilineStrings: false
# BreakBeforeBinaryOperators: None
# BreakBeforeBraces: Attach
# BreakStringLiterals: true
# CommentPragmas: '^ IWYU pragma:'

# ExperimentalAutoDetectBinPacking: false
# IncludeIsMainRegex: '(Test)?$'
# IncludeIsMainSourceRegex: ''
# InsertBraces: false
# InsertTrailingCommas: None
# KeepEmptyLinesAtTheStartOfBlocks: true
# ReflowComments: true
# RequiresClausePosition: OwnLine
# SeparateDefinitionBlocks: Leave

# SpaceAfterCStyleCast: false
# SpaceAfterLogicalNot: false
# SpaceBeforeCaseColon: false
# SpaceBeforeParens: ControlStatements
# SpaceBeforeParensOptions:
# AfterControlStatements: true
# AfterForeachMacros: true
# AfterFunctionDefinitionName: false
# AfterFunctionDeclarationName: false
# AfterIfMacros: true
# AfterOverloadedOperator: false
# AfterRequiresInClause: false
# AfterRequiresInExpression: false
# BeforeNonEmptyParentheses: false
# SpaceBeforeRangeBasedForLoopColon: true
# SpaceInEmptyBlock: false
# SpaceInEmptyParentheses: false
# SpacesBeforeTrailingComments: 1
# SpacesInAngles: Never
# SpacesInConditionalStatement: false
# SpacesInContainerLiterals: true
# SpacesInCStyleCastParentheses: false
# SpacesInLineCommentPrefix:
# Minimum: 1
# Maximum: -1
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
# SpaceBeforeSquareBrackets: false

# Configure some special macros:
AttributeMacros:
- NORETURN
- PURE
- COLD
- HOT
- FORCEINLINE
- SECTION
WhitespaceSensitiveMacros:
- comptime_stringify
# ForEachMacros:
# - foreach
# - Q_FOREACH
# - BOOST_FOREACH
# IfMacros:
# - KJ_IF_MAYBE
# StatementMacros:
# - Q_UNUSED
# - QT_REQUIRE_VERSION
# StatementAttributeLikeMacros:
# - FALLTHROUGH
# MacroBlockBegin: ''
# MacroBlockEnd: ''
---

1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ elseif(DEFINED PICO_SDK_PATH)
project(pax_graphics C CXX)

message(STATUS "Building PAX Graphics for Pi Pico SDK.")
add_definitions(-DPAX_STANDALONE=0)
add_definitions(-DPAX_COMPILE_MCR=0)
add_definitions(-DPAX_PI_PICO=1)
include(${CMAKE_CURRENT_LIST_DIR}/standalone.cmake)
Expand Down
36 changes: 17 additions & 19 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
/*
MIT License
MIT License

Copyright (c) 2021-2023 Julian Scheffers
Copyright (c) 2021-2023 Julian Scheffers

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:
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 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.
*/
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.
80 changes: 43 additions & 37 deletions precalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,48 @@
import math

def precalcCircle(fd_c, fd_h, resolution, id):
delta = math.pi * 2 / resolution
# Precalculate points.
fd_h.write("// Circle: " + str(resolution) + " segments\n")
fd_h.write("extern const pax_vec2f pax_precalc_" + id + "[" + str(resolution + 1) + "];\n")
fd_c.write("// Circle: " + str(resolution) + " segments\n")
fd_c.write("const pax_vec2f pax_precalc_" + id + "[" + str(resolution + 1) + "] = {\n")
for i in range(resolution + 1):
angle = i * delta
fd_c.write("\t{" + str(math.cos(angle)) + ", " + str(math.sin(angle)) + "},\n")
fd_c.write("};\n\n")
# Precalculate UVs.
fd_h.write("// Circle UVs: " + str(resolution) + " segments\n")
fd_h.write("extern const pax_trif pax_precalc_uv_" + id + "[" + str(resolution - 1) + "];\n\n")
fd_c.write("// Circle UVs: " + str(resolution) + " segments\n")
fd_c.write("const pax_trif pax_precalc_uv_" + id + "[" + str(resolution - 1) + "] = {\n")
for i in range(resolution - 1):
a1 = i * delta
a2 = (i + 1) * delta
fd_c.write("\t{1, 0.5, ")
fd_c.write(str(math.cos(a1)/2+0.5) + ", " + str(math.sin(a1)/2+0.5) + ", ")
fd_c.write(str(math.cos(a2)/2+0.5) + ", " + str(math.sin(a2)/2+0.5))
fd_c.write("},\n")
fd_c.write("};\n\n")
delta = math.pi * 2 / resolution
# Precalculate points.
fd_h.write("// Circle: " + str(resolution) + " segments\n")
fd_h.write("extern const pax_vec2f pax_precalc_" + id + "[" + str(resolution + 1) + "];\n")
fd_c.write("// Circle: " + str(resolution) + " segments\n")
fd_c.write("const pax_vec2f pax_precalc_" + id + "[" + str(resolution + 1) + "] = {\n")
for i in range(resolution + 1):
angle = i * delta
fd_c.write("\t{" + str(math.cos(angle)) + ", " + str(math.sin(angle)) + "},\n")
fd_c.write("};\n\n")
# Precalculate UVs.
fd_h.write("// Circle UVs: " + str(resolution) + " segments\n")
fd_h.write("extern const pax_trif pax_precalc_uv_" + id + "[" + str(resolution - 1) + "];\n\n")
fd_c.write("// Circle UVs: " + str(resolution) + " segments\n")
fd_c.write("const pax_trif pax_precalc_uv_" + id + "[" + str(resolution - 1) + "] = {\n")
for i in range(resolution - 1):
a1 = i * delta
a2 = (i + 1) * delta
fd_c.write("\t{1, 0.5, ")
fd_c.write(str(math.cos(a1)/2+0.5) + ", " + str(math.sin(a1)/2+0.5) + ", ")
fd_c.write(str(math.cos(a2)/2+0.5) + ", " + str(math.sin(a2)/2+0.5))
fd_c.write("},\n")
fd_c.write("};\n\n")

if __name__ == "__main__":
out_c = open("src/helpers/pax_precalculated.c", "w")
out_c.write("// WARNING: This is a generated file, do not edit it!\n")
out_c.write("// This file contains precalculated math operations.\n\n")
out_c.write("#include \"pax_internal.h\"\n\n")
out_h = open("src/helpers/pax_precalculated.h", "w")
out_h.write("// WARNING: This is a generated file, do not edit it!\n")
out_h.write("// This file contains precalculated math operations.\n\n")
out_h.write("#include \"pax_types.h\"\n\n")
precalcCircle(out_c, out_h, 4, "circle_4")
precalcCircle(out_c, out_h, 16, "circle_16")
precalcCircle(out_c, out_h, 24, "circle_24")
precalcCircle(out_c, out_h, 32, "circle_32")
out_c = open("src/helpers/pax_precalculated.c", "w")
out_c.write("// WARNING: This is a generated file, do not edit it!\n")
out_c.write("// This file contains precalculated math operations.\n")
out_c.write("// clang-format off\n\n")
out_c.write("#include \"pax_internal.h\"\n\n")
out_h = open("src/helpers/pax_precalculated.h", "w")
out_h.write("// WARNING: This is a generated file, do not edit it!\n")
out_h.write("// This file contains precalculated math operations.\n")
out_c.write("// clang-format off\n\n")
out_h.write("#include \"pax_types.h\"\n\n")
precalcCircle(out_c, out_h, 4, "circle_4")
precalcCircle(out_c, out_h, 16, "circle_16")
precalcCircle(out_c, out_h, 24, "circle_24")
precalcCircle(out_c, out_h, 32, "circle_32")
out_c.flush()
out_c.close()
out_h.flush()
out_h.close()
2 changes: 1 addition & 1 deletion sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ set(PAX_INCLUDE_C
set(PAX_SRCS_CXX
)

# C include directories.
# C++ include directories.
set(PAX_INCLUDE_CXX
)
Loading

0 comments on commit 713cb62

Please sign in to comment.