-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
3,204 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <stdint.h> | ||
#include <limits.h> | ||
#include <string.h> | ||
#include "core/rect.h" | ||
|
||
/* | ||
// 3x3 transform matrix | ||
class PathFillTransform | ||
{ | ||
public: | ||
PathFillTransform() { for (int i = 0; i < 9; i++) matrix[i] = 0.0f; matrix[0] = matrix[4] = matrix[8] = 1.0; } | ||
PathFillTransform(const float* mat3x3) { for (int i = 0; i < 9; i++) matrix[i] = (double)mat3x3[i]; } | ||
PathFillTransform(const double* mat3x3) { for (int i = 0; i < 9; i++) matrix[i] = mat3x3[i]; } | ||
double matrix[9]; | ||
}; | ||
*/ | ||
|
||
enum class PathFillMode | ||
{ | ||
alternate, | ||
winding | ||
}; | ||
|
||
enum class PathFillCommand | ||
{ | ||
line, | ||
quadradic, | ||
cubic | ||
}; | ||
|
||
class PathFillSubpath | ||
{ | ||
public: | ||
PathFillSubpath() : points(1) { } | ||
|
||
std::vector<Point> points; | ||
std::vector<PathFillCommand> commands; | ||
bool closed = false; | ||
}; | ||
|
||
class PathFillDesc | ||
{ | ||
public: | ||
PathFillDesc() : subpaths(1) { } | ||
|
||
PathFillMode fill_mode = PathFillMode::alternate; | ||
std::vector<PathFillSubpath> subpaths; | ||
|
||
void MoveTo(const Point& point) | ||
{ | ||
if (!subpaths.back().commands.empty()) | ||
{ | ||
subpaths.push_back(PathFillSubpath()); | ||
} | ||
subpaths.back().points.front() = point; | ||
} | ||
|
||
void LineTo(const Point& point) | ||
{ | ||
auto& subpath = subpaths.back(); | ||
subpath.points.push_back(point); | ||
subpath.commands.push_back(PathFillCommand::line); | ||
} | ||
|
||
void BezierTo(const Point& control, const Point& point) | ||
{ | ||
auto& subpath = subpaths.back(); | ||
subpath.points.push_back(control); | ||
subpath.points.push_back(point); | ||
subpath.commands.push_back(PathFillCommand::quadradic); | ||
} | ||
|
||
void BezierTo(const Point& control1, const Point& control2, const Point& point) | ||
{ | ||
auto& subpath = subpaths.back(); | ||
subpath.points.push_back(control1); | ||
subpath.points.push_back(control2); | ||
subpath.points.push_back(point); | ||
subpath.commands.push_back(PathFillCommand::cubic); | ||
} | ||
|
||
void Close() | ||
{ | ||
if (!subpaths.back().commands.empty()) | ||
{ | ||
subpaths.back().closed = true; | ||
subpaths.push_back(PathFillSubpath()); | ||
} | ||
} | ||
|
||
void Rasterize(uint8_t* dest, int width, int height, bool blend = false); | ||
}; |
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
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.