-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
free brush drawer & cleanup of the brush code
- Loading branch information
Showing
20 changed files
with
643 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <Geode/Geode.hpp> | ||
|
||
namespace allium { | ||
class EditorUtilities { | ||
protected: | ||
std::vector<GameObject*> m_objects; | ||
int m_colorID = 0; | ||
public: | ||
static EditorUtilities* get(); | ||
|
||
void setColor(int colorID); | ||
|
||
void addRectangle( | ||
cocos2d::CCPoint const& p1, cocos2d::CCPoint const& p2, cocos2d::CCPoint const& p3, cocos2d::CCPoint const& p4 | ||
); | ||
|
||
void addCircle( | ||
cocos2d::CCPoint const& center, float radius | ||
); | ||
|
||
void finish(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include <Geode/Geode.hpp> | ||
#include "BrushDrawer.hpp" | ||
|
||
namespace allium { | ||
class FreeBrushDrawer : public BrushDrawer { | ||
protected: | ||
std::vector<cocos2d::CCPoint> m_points; | ||
private: | ||
|
||
std::vector<cocos2d::CCPoint> simplify(std::vector<cocos2d::CCPoint> const& points); | ||
public: | ||
static FreeBrushDrawer* create(); | ||
bool init() override; | ||
|
||
bool handleTouchStart(cocos2d::CCPoint const& point) override; | ||
void handleTouchMove(cocos2d::CCPoint const& point) override; | ||
void handleTouchEnd(cocos2d::CCPoint const& point) override; | ||
|
||
void updateOverlay() override; | ||
|
||
void updateLine() override; | ||
|
||
PolylineConverter initializeConverter() override; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include <vector> | ||
#include <cmath> | ||
#include <numbers> | ||
#include <Geode/Geode.hpp> | ||
|
||
namespace allium { | ||
class PolylineConverter { | ||
public: | ||
struct Point { | ||
double x; | ||
double y; | ||
|
||
Point operator+(Point const& other) const { | ||
return Point{x + other.x, y + other.y}; | ||
} | ||
|
||
Point operator-(Point const& other) const { | ||
return Point{x - other.x, y - other.y}; | ||
} | ||
|
||
Point operator*(double const& scalar) const { | ||
return Point{x * scalar, y * scalar}; | ||
} | ||
|
||
Point operator/(double const& scalar) const { | ||
return Point{x / scalar, y / scalar}; | ||
} | ||
}; | ||
|
||
struct Rect { | ||
Point p1; | ||
Point p2; | ||
Point p3; | ||
Point p4; | ||
}; | ||
|
||
struct Circle { | ||
Point center; | ||
float radius; | ||
}; | ||
|
||
private: | ||
float m_lineWidth; | ||
std::vector<Point> m_points; | ||
|
||
// Returns the a coefficient of the line equation of the line passing through p1 and p2 | ||
double a(Point p1, Point p2); | ||
|
||
// Returns the b coefficient of the line equation of the line passing through p1 and p2 | ||
double b(Point p1, Point p2); | ||
|
||
// Returns the c coefficient of the line equation of the line passing through p1 and p2 | ||
double c(Point p1, Point p2); | ||
|
||
// Returns the intersection point of the lines passing through p1 and p2 and r1 and r2 | ||
Point intersect(Point p1, Point p2, Point r1, Point r2); | ||
|
||
// Returns the angle between the lines passing through p1, p2, and p2, p3 | ||
double angle(Point p1, Point p2, Point p3); | ||
|
||
// Returns the distance between two points | ||
double distance(Point p1, Point p2); | ||
|
||
// Checks if the angle between the lines passing through p1, p2, and p2, p3 is valid | ||
bool hasAngle(Point p1, Point p2, Point p3); | ||
|
||
// Returns the offset point of p2 based on the angle between the lines passing through p1, p2, and p2, p3 | ||
// This is the corner of the rectangle that is wanted to be extended to intersection point | ||
Point offset(Point p1, Point p2, Point p3); | ||
|
||
// Extends the corner based on the angle between the lines passing through p1, p2, and p2, p3 | ||
auto extend(Point p1, Point p2, Point p3); | ||
|
||
// Checks if the points are colinear | ||
bool checkColinear(Point p1, Point p2, Point p3); | ||
|
||
public: | ||
|
||
PolylineConverter(float lineWidth, std::vector<Point>&& points); | ||
|
||
void handleExtension(std::vector<PolylineConverter::Rect>& rects, std::vector<PolylineConverter::Circle>& circles); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"geode": "3.1.1", | ||
"geode": "3.2.0", | ||
"gd": { | ||
"win": "2.206", | ||
"android": "2.206" | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.