FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
solvespace/src/resource.h at master · solvespace/solvespace · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
solvespace
/
solvespace
Public
Notifications
You must be signed in to change notification settings
Fork
595
Star
4.1k
Code
Issues
244
Pull requests
34
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
solvespace
/
src
/
resource.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
127 lines (101 loc) · 3.89 KB
Breadcrumbs
solvespace
/
src
/
resource.h
Copy path
File metadata and controls
127 lines (101 loc) · 3.89 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//
-----------------------------------------------------------------------------
//
Discovery and loading of our resources (icons, fonts, templates, etc).
//
//
Copyright 2016 whitequark
//
-----------------------------------------------------------------------------
#
ifndef
SOLVESPACE_RESOURCE_H
#
define
SOLVESPACE_RESOURCE_H
#
include
<
functional
>
#
include
<
map
>
#
include
<
memory
>
#
include
<
stdint.h
>
#
include
<
string
>
#
include
<
vector
>
namespace
SolveSpace
{
class
Camera
;
class
Point2d
;
class
Pixmap
;
class
Vector
;
class
RgbaColor
;
namespace
Platform
{
class
Path
;
}
//
namespace Platform
std::string
LoadString
(
const
std::string &name);
std::string
LoadStringFromGzip
(
const
std::string &name);
std::shared_ptr<Pixmap>
LoadPng
(
const
std::string &name);
class
Pixmap
{
public:
enum
class
Format
{
BGRA
,
RGBA
,
BGR
,
RGB
, A };
Format format;
size_t
width;
size_t
height;
size_t
stride;
std::vector<
uint8_t
> data;
int
colorType;
bool
bgr;
static
std::shared_ptr<Pixmap>
Create
(Format format,
size_t
width,
size_t
height);
static
std::shared_ptr<Pixmap>
FromPng
(
const
uint8_t
*data,
size_t
size,
bool
flip =
false
);
static
std::shared_ptr<Pixmap>
ReadPng
(
FILE
*f,
bool
flip =
false
);
static
std::shared_ptr<Pixmap>
ReadPng
(
const
Platform::Path &filename,
bool
flip =
false
);
bool
WritePng
(
FILE
*f,
bool
flip =
false
);
bool
WritePng
(
const
Platform::Path &filename,
bool
flip =
false
);
size_t
GetBytesPerPixel
()
const
;
RgbaColor
GetPixel
(
size_t
x,
size_t
y)
const
;
bool
Equals
(
const
Pixmap &other)
const
;
void
ConvertTo
(Format newFormat);
void
SetPixel
(
size_t
x,
size_t
y, RgbaColor color);
std::shared_ptr<Pixmap>
Copy
();
};
class
BitmapFont
{
public:
struct
Glyph
{
uint8_t
advanceCells;
uint16_t
position;
};
std::string unifontData;
std::map<
char32_t
, Glyph> glyphs;
std::shared_ptr<Pixmap> texture;
bool
textureUpdated;
uint16_t
nextPosition;
static
BitmapFont
From
(std::string &&unifontData);
static
BitmapFont
Create
();
bool
IsEmpty
()
const
{
return
unifontData.
empty
(); }
const
Glyph &
GetGlyph
(
char32_t
codepoint);
void
LocateGlyph
(
char32_t
codepoint,
double
*s0,
double
*t0,
double
*s1,
double
*t1,
size_t
*advanceWidth,
size_t
*boundingHeight);
void
AddGlyph
(
char32_t
codepoint, std::shared_ptr<
const
Pixmap> pixmap);
size_t
GetWidth
(
char32_t
codepoint);
size_t
GetWidth
(
const
std::string &str);
};
class
VectorFont
{
public:
struct
Contour
{
std::vector<Point2d> points;
};
struct
Glyph
{
std::vector<Contour> contours;
double
leftSideBearing;
double
boundingWidth;
double
advanceWidth;
};
std::string lffData;
std::map<
char32_t
, Glyph> glyphs;
double
rightSideBearing;
double
capHeight;
double
ascender;
double
descender;
static
VectorFont
From
(std::string &&lffData);
static
VectorFont *
Builtin
();
bool
IsEmpty
()
const
{
return
lffData.
empty
(); }
const
Glyph &
GetGlyph
(
char32_t
codepoint);
double
GetCapHeight
(
double
forCapHeight)
const
;
double
GetHeight
(
double
forCapHeight)
const
;
double
GetWidth
(
double
forCapHeight,
const
std::string &str);
Vector
GetExtents
(
double
forCapHeight,
const
std::string &str);
void
Trace
(
double
forCapHeight, Vector o, Vector u, Vector v,
const
std::string &str,
const
std::function<
void
(Vector, Vector)> &traceEdge);
void
Trace
(
double
forCapHeight, Vector o, Vector u, Vector v,
const
std::string &str,
const
std::function<
void
(Vector, Vector)> &traceEdge,
const
Camera &camera);
};
}
#
endif
Back
|
FazBrowse Home
|
New Git URL