Skip to content

Commit

Permalink
Tweak format settings and reformat files.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregersn committed Nov 20, 2024
1 parent 5fd7d1c commit 7241be3
Show file tree
Hide file tree
Showing 35 changed files with 2,894 additions and 2,884 deletions.
11 changes: 10 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@ Language: Cpp
# Force pointers to the type for C++.
# DerivePointerAlignment: false
# PointerAlignment: Right
ColumnLimit: 80
ColumnLimit: 0
SortIncludes: Never
NamespaceIndentation: All
AllowShortFunctionsOnASingleLine: All
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: true
BreakBeforeBraces: Custom
BraceWrapping:
BeforeLambdaBody: true
8 changes: 4 additions & 4 deletions include/pyro/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Pyro
{
class Color
{
private:
private:
float _hue{0.0f};
float _saturation{0.0f};
float _lightness{0.0f};
Expand All @@ -26,7 +26,7 @@ namespace Pyro
void update_hsl();
void update_rgb();

public:
public:
float r();
float g();
float b();
Expand Down Expand Up @@ -155,7 +155,7 @@ namespace Pyro
{
std::vector<Pyro::Color> colors;

public:
public:
Palette();
unsigned int add(Color col);
Color get(unsigned int index);
Expand All @@ -182,6 +182,6 @@ namespace Pyro
*/

}
} // namespace Pyro

#endif
2 changes: 1 addition & 1 deletion include/pyro/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ namespace Pyro
const int SOFT_LIGHT{1 << 11};
const int DODGE{1 << 12};
const int BURN{1 << 13};
}
} // namespace Pyro

#endif
6 changes: 3 additions & 3 deletions include/pyro/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ namespace Pyro

class Font
{
private:
private:
std::filesystem::path filename{""};

public:
public:
explicit Font(std::filesystem::path filename);
static Font *load(std::filesystem::path filename);
FontImpl *impl;
};

Font *create_font(std::filesystem::path filename, int size);
}
} // namespace Pyro
#endif
6 changes: 3 additions & 3 deletions include/pyro/font_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ namespace Pyro
{
class FontImpl
{
private:
private:
std::filesystem::path filename{""};
FT_Face face{nullptr};

public:
public:
explicit FontImpl(std::filesystem::path filename);
FT_Face get_ft_face() { return this->face; };
};
}
} // namespace Pyro
#endif
18 changes: 9 additions & 9 deletions include/pyro/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Pyro

class Graphics : public Image
{
protected:
protected:
GraphicsMode mode;
std::filesystem::path filename{""};

Expand All @@ -33,7 +33,7 @@ namespace Pyro
Transformer2D transformer;
StyleStack style;

public:
public:
Graphics(unsigned int width, unsigned int height, std::filesystem::path filename = "");
virtual ~Graphics() override;

Expand All @@ -44,14 +44,14 @@ namespace Pyro
this->style.imagemode(mode);
};
void image(Image *img, float x, float y);
virtual void image_impl(Image * /*img*/, float /*x*/, float /*y*/) {};
virtual void image_impl(Image * /*img*/, float /*x*/, float /*y*/){};
Image *loadimage(std::filesystem::path const &filename) { return Image::load(filename); };

// Color functions
void nostroke();
void nofill();

virtual void blendmode(int /*mode*/) {};
virtual void blendmode(int /*mode*/){};
void colormode(int mode)
{
this->style.colormode(mode);
Expand Down Expand Up @@ -124,7 +124,7 @@ namespace Pyro
};
virtual void background(float r, float g, float b, float a = 1.0);

virtual void shape(Shape /*s*/, float /*x*/, float /*y*/) {};
virtual void shape(Shape /*s*/, float /*x*/, float /*y*/){};

void beginshape(int kind = DEFAULT)
{
Expand Down Expand Up @@ -172,7 +172,7 @@ namespace Pyro
void point(float x, float y);
void point(Vector p);
virtual void line(Vector /*p0*/, Vector /*p1*/){};
virtual void line(float /*x0*/, float /*y0*/, float /*x1*/, float /*y1*/) {};
virtual void line(float /*x0*/, float /*y0*/, float /*x1*/, float /*y1*/){};
void curve(Vector p0, Vector p1, Vector p2, Vector p3);
void curve(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3);
void bezier(Vector p0, Vector p1, Vector p2, Vector p3);
Expand Down Expand Up @@ -215,8 +215,8 @@ namespace Pyro
void text(std::string const &text, float x, float y);
void textfont(Font *font);

virtual void textfont_impl(Font * /*font*/) {};
virtual void text_impl(std::string /*text*/, float /*x*/, float /*y*/) {};
virtual void textfont_impl(Font * /*font*/){};
virtual void text_impl(std::string /*text*/, float /*x*/, float /*y*/){};
};
/**
* Create a graphics object
Expand All @@ -230,6 +230,6 @@ namespace Pyro
std::filesystem::path filename = "");

Graphics *creategraphics(unsigned int width, unsigned int height, int dpi, Unit unit, GraphicsMode mode = GraphicsMode::CAIRO, std::filesystem::path filename = "");
};
}; // namespace Pyro

#endif
6 changes: 3 additions & 3 deletions include/pyro/graphics_cairo.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ namespace Pyro
{
class GraphicsCairo : public Graphics
{
private:
private:
cairo_surface_t *surface{nullptr};
cairo_t *cr{nullptr};

cairo_font_face_t *font{nullptr};

public:
public:
GraphicsCairo(unsigned int width, unsigned int height,
GraphicsMode mode = GraphicsMode::CAIRO,
std::filesystem::path filename = "");
Expand Down Expand Up @@ -47,6 +47,6 @@ namespace Pyro
void text_impl(std::string text, float x, float y) override;
void textfont_impl(Font *font) override;
};
}
} // namespace Pyro

#endif
8 changes: 4 additions & 4 deletions include/pyro/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Pyro

class Image
{
private:
private:
bool pixels_locked{false};
void *cache{nullptr};
uint32_t *data{nullptr};
Expand All @@ -38,7 +38,7 @@ namespace Pyro
int destX1, int destY1, int destX2, int destY2,
unsigned int mode);

protected:
protected:
unsigned int _width{0};
unsigned int _height{0};
unsigned int _pixelwidth{0};
Expand All @@ -50,7 +50,7 @@ namespace Pyro
int mx1{0}, my1{0}, mx2{0}, my2{0};
bool initialized{false};

public:
public:
unsigned int format{ARGB};
unsigned int width() { return this->_pixelwidth; };
unsigned int height() { return this->_pixelheight; };
Expand Down Expand Up @@ -114,5 +114,5 @@ namespace Pyro
};

Image *createimage(unsigned int width, unsigned int height, int format = RGB);
}
} // namespace Pyro
#endif
2 changes: 1 addition & 1 deletion include/pyro/noise.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ namespace Pyro
double noise(double x, double y);
double noise(double x, double y, double z);
double noise(double x, double y, double z, double w);
}
} // namespace Pyro

#endif
8 changes: 4 additions & 4 deletions include/pyro/pyro.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ namespace Pyro
inline void beziervertex(float x2, float y2, float x3, float y3, float x4, float y4) { pg->beziervertex(x2, y2, x3, y3, x4, y4); };
inline void beziervertex(Vector p2, Vector p3, Vector p4) { pg->beziervertex(p2, p3, p4); };

inline void curve(Vector p0, Vector p1, Vector p2, Vector p3) { pg->curve( p0, p1, p2, p3); };
inline void curve(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) { pg->curve( x0, y0, x1, y1, x2, y2, x3, y3); };
inline void bezier(Vector p0, Vector p1, Vector p2, Vector p3) { pg->bezier( p0, p1, p2, p3); };
inline void bezier(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) { pg->bezier( x0, y0, x1, y1, x2, y2, x3, y3); };
inline void curve(Vector p0, Vector p1, Vector p2, Vector p3) { pg->curve(p0, p1, p2, p3); };
inline void curve(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) { pg->curve(x0, y0, x1, y1, x2, y2, x3, y3); };
inline void bezier(Vector p0, Vector p1, Vector p2, Vector p3) { pg->bezier(p0, p1, p2, p3); };
inline void bezier(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) { pg->bezier(x0, y0, x1, y1, x2, y2, x3, y3); };

inline void point(float x, float y) { pg->point(x, y); };
inline void point(Vector p) { pg->point(p); };
Expand Down
10 changes: 5 additions & 5 deletions include/pyro/runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ namespace Pyro
{
class Runner
{
public:
public:
std::function<void()> keypressed_cb{nullptr};
std::function<void()> mousepressed_cb{nullptr};
Runner() : running(true) {};
Runner(const Runner & /*in*/) {};
Runner() : running(true){};
Runner(const Runner & /*in*/){};
Runner &operator=(const Runner & /*in*/) { return *this; };
virtual ~Runner() {};
virtual ~Runner(){};

virtual int update()
{
Expand Down Expand Up @@ -79,6 +79,6 @@ namespace Pyro

extern bool running;
extern Runner *pyro;
}
} // namespace Pyro

#endif
6 changes: 3 additions & 3 deletions include/pyro/sdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Pyro
{
class SDLRunner : public Runner
{
protected:
protected:
SDL_Window *sdl_window{nullptr};
SDL_Renderer *sdl_renderer{nullptr};
SDL_Texture *sdl_texture{nullptr};
Expand All @@ -21,7 +21,7 @@ namespace Pyro
unsigned int width;
unsigned int height;

public:
public:
explicit SDLRunner(bool headless = false);
SDLRunner(const SDLRunner &in);
SDLRunner &operator=(const SDLRunner &in);
Expand All @@ -30,6 +30,6 @@ namespace Pyro
int quit() override;
int init(unsigned int width, unsigned int height) override;
};
}
} // namespace Pyro

#endif
7 changes: 3 additions & 4 deletions include/pyro/shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ namespace Pyro
const int QUADS{6};
const int QUAD_STRIP{7};


template <typename T>
T bezierpoint(T a, T b, T c, T d, float t)
{
float t1 = 1.0f - t;
return (a*t1 + 3*b*t)*t1*t1 + (3*c*t1 + d*t)*t*t;
return (a * t1 + 3 * b * t) * t1 * t1 + (3 * c * t1 + d * t) * t * t;
};

template <typename T>
Expand Down Expand Up @@ -55,7 +54,7 @@ namespace Pyro
std::vector<std::vector<Pyro::t_shapepoint>> contours{std::vector<std::vector<Pyro::t_shapepoint>>()};
int kind{DEFAULT};

public:
public:
int close{false};
Shape();
~Shape();
Expand All @@ -74,5 +73,5 @@ namespace Pyro
void beziervertex(float x2, float y2, float x3, float y3, float x4, float y4) { this->beziervertex(Vector(x2, y2), Vector(x3, y3), Vector(x4, y4)); };
std::vector<std::vector<Pyro::Vector>> getpoints() { return this->outpoints; };
};
};
}; // namespace Pyro
#endif
6 changes: 3 additions & 3 deletions include/pyro/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ namespace Pyro

class StyleStack
{
private:
private:
std::vector<t_style> stack;
t_style current;

public:
public:
StyleStack();
void push();
void pop();
Expand Down Expand Up @@ -79,6 +79,6 @@ namespace Pyro
void strokejoin(int join);
int strokejoin();
};
}
} // namespace Pyro

#endif
6 changes: 3 additions & 3 deletions include/pyro/transformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ namespace Pyro
{
class Transformer2D
{
private:
private:
std::vector<Eigen::Affine2d> stack;
Eigen::Affine2d current;

public:
public:
Transformer2D();
void translate(Vector v);
void translate(float x, float y);
Expand All @@ -36,5 +36,5 @@ namespace Pyro
float screen_y(float x, float y, float z = 0.0f) { return this->screen_y(Vector(x, y, z)); };
};

}
} // namespace Pyro
#endif
2 changes: 1 addition & 1 deletion include/pyro/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ namespace Pyro
}
};

}
} // namespace Pyro

#endif
4 changes: 2 additions & 2 deletions include/pyro/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Pyro
{
class Vector
{
public:
public:
float x{};
float y{};
float z{};
Expand Down Expand Up @@ -147,6 +147,6 @@ namespace Pyro

Vector operator*(float const f, Vector const v);

}
} // namespace Pyro

#endif
Loading

0 comments on commit 7241be3

Please sign in to comment.