Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
TFT_eSPI
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
TFT_eSPI
Commits
52ee45b3
Commit
52ee45b3
authored
Aug 05, 2020
by
Bodmer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct medium warnings #702
parent
cfcb9c66
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
27 deletions
+27
-27
Extensions/Sprite.cpp
Extensions/Sprite.cpp
+20
-20
Extensions/Sprite.h
Extensions/Sprite.h
+7
-7
No files found.
Extensions/Sprite.cpp
View file @
52ee45b3
...
...
@@ -33,8 +33,8 @@ TFT_eSprite::TFT_eSprite(TFT_eSPI *tft)
_xptr
=
0
;
// pushColor coordinate
_yptr
=
0
;
_x
p
ivot
=
0
;
_y
p
ivot
=
0
;
_x
P
ivot
=
0
;
_y
P
ivot
=
0
;
_colorMap
=
nullptr
;
...
...
@@ -69,8 +69,8 @@ void* TFT_eSprite::createSprite(int16_t w, int16_t h, uint8_t frames)
_sh
=
h
;
_scolor
=
TFT_BLACK
;
_x
p
ivot
=
w
/
2
;
_y
p
ivot
=
h
/
2
;
_x
P
ivot
=
w
/
2
;
_y
P
ivot
=
h
/
2
;
_img8
=
(
uint8_t
*
)
callocSprite
(
w
,
h
,
frames
);
_img8_1
=
_img8
;
...
...
@@ -397,8 +397,8 @@ void TFT_eSprite::deleteSprite(void)
***************************************************************************************/
void
TFT_eSprite
::
setPivot
(
int16_t
x
,
int16_t
y
)
{
_x
p
ivot
=
x
;
_y
p
ivot
=
y
;
_x
P
ivot
=
x
;
_y
P
ivot
=
y
;
}
...
...
@@ -408,7 +408,7 @@ void TFT_eSprite::setPivot(int16_t x, int16_t y)
***************************************************************************************/
int16_t
TFT_eSprite
::
getPivotX
(
void
)
{
return
_x
p
ivot
;
return
_x
P
ivot
;
}
...
...
@@ -418,7 +418,7 @@ int16_t TFT_eSprite::getPivotX(void)
***************************************************************************************/
int16_t
TFT_eSprite
::
getPivotY
(
void
)
{
return
_y
p
ivot
;
return
_y
P
ivot
;
}
...
...
@@ -454,8 +454,8 @@ bool TFT_eSprite::pushRotated(int16_t angle, int32_t transp)
// Scan destination bounding box and fetch transformed pixels from source Sprite
for
(
int32_t
y
=
min_y
;
y
<=
max_y
;
y
++
,
yt
++
)
{
int32_t
x
=
min_x
;
uint32_t
xs
=
(
_cosra
*
xt
-
(
_sinra
*
yt
-
(
_x
p
ivot
<<
FP_SCALE
))
+
(
1
<<
(
FP_SCALE
-
1
)));
uint32_t
ys
=
(
_sinra
*
xt
+
(
_cosra
*
yt
+
(
_y
p
ivot
<<
FP_SCALE
))
+
(
1
<<
(
FP_SCALE
-
1
)));
uint32_t
xs
=
(
_cosra
*
xt
-
(
_sinra
*
yt
-
(
_x
P
ivot
<<
FP_SCALE
))
+
(
1
<<
(
FP_SCALE
-
1
)));
uint32_t
ys
=
(
_sinra
*
xt
+
(
_cosra
*
yt
+
(
_y
P
ivot
<<
FP_SCALE
))
+
(
1
<<
(
FP_SCALE
-
1
)));
while
((
xs
>=
xe
||
ys
>=
ye
)
&&
x
<
max_x
)
{
x
++
;
xs
+=
_cosra
;
ys
+=
_sinra
;
}
if
(
x
==
max_x
)
continue
;
...
...
@@ -513,8 +513,8 @@ bool TFT_eSprite::pushRotated(TFT_eSprite *spr, int16_t angle, int32_t transp)
uint16_t
sline_buffer
[
max_x
-
min_x
+
1
];
int32_t
xt
=
min_x
-
spr
->
_x
p
ivot
;
int32_t
yt
=
min_y
-
spr
->
_y
p
ivot
;
int32_t
xt
=
min_x
-
spr
->
_x
P
ivot
;
int32_t
yt
=
min_y
-
spr
->
_y
P
ivot
;
uint32_t
xe
=
_dwidth
<<
FP_SCALE
;
uint32_t
ye
=
_dheight
<<
FP_SCALE
;
uint32_t
tpcolor
=
transp
>>
8
|
transp
<<
8
;
// convert to unsigned swapped bytes
...
...
@@ -525,8 +525,8 @@ bool TFT_eSprite::pushRotated(TFT_eSprite *spr, int16_t angle, int32_t transp)
// Scan destination bounding box and fetch transformed pixels from source Sprite
for
(
int32_t
y
=
min_y
;
y
<=
max_y
;
y
++
,
yt
++
)
{
int32_t
x
=
min_x
;
uint32_t
xs
=
(
_cosra
*
xt
-
(
_sinra
*
yt
-
(
_x
p
ivot
<<
FP_SCALE
))
+
(
1
<<
(
FP_SCALE
-
1
)));
uint32_t
ys
=
(
_sinra
*
xt
+
(
_cosra
*
yt
+
(
_y
p
ivot
<<
FP_SCALE
))
+
(
1
<<
(
FP_SCALE
-
1
)));
uint32_t
xs
=
(
_cosra
*
xt
-
(
_sinra
*
yt
-
(
_x
P
ivot
<<
FP_SCALE
))
+
(
1
<<
(
FP_SCALE
-
1
)));
uint32_t
ys
=
(
_sinra
*
xt
+
(
_cosra
*
yt
+
(
_y
P
ivot
<<
FP_SCALE
))
+
(
1
<<
(
FP_SCALE
-
1
)));
while
((
xs
>=
xe
||
ys
>=
ye
)
&&
x
<
max_x
)
{
x
++
;
xs
+=
_cosra
;
ys
+=
_sinra
;
}
if
(
x
==
max_x
)
continue
;
...
...
@@ -563,7 +563,7 @@ bool TFT_eSprite::getRotatedBounds(int16_t angle, int16_t *min_x, int16_t *min_y
int16_t
*
max_x
,
int16_t
*
max_y
)
{
// Get the bounding box of this rotated source Sprite relative to Sprite pivot
getRotatedBounds
(
angle
,
width
(),
height
(),
_x
pivot
,
_yp
ivot
,
min_x
,
min_y
,
max_x
,
max_y
);
getRotatedBounds
(
angle
,
width
(),
height
(),
_x
Pivot
,
_yP
ivot
,
min_x
,
min_y
,
max_x
,
max_y
);
// Move bounding box so source Sprite pivot coincides with TFT pivot
*
min_x
+=
_tft
->
_xpivot
;
...
...
@@ -595,13 +595,13 @@ bool TFT_eSprite::getRotatedBounds(TFT_eSprite *spr, int16_t angle, int16_t *min
int16_t
*
max_x
,
int16_t
*
max_y
)
{
// Get the bounding box of this rotated source Sprite relative to Sprite pivot
getRotatedBounds
(
angle
,
width
(),
height
(),
_x
pivot
,
_yp
ivot
,
min_x
,
min_y
,
max_x
,
max_y
);
getRotatedBounds
(
angle
,
width
(),
height
(),
_x
Pivot
,
_yP
ivot
,
min_x
,
min_y
,
max_x
,
max_y
);
// Move bounding box so source Sprite pivot coincides with destination Sprite pivot
*
min_x
+=
spr
->
_x
p
ivot
;
*
max_x
+=
spr
->
_x
p
ivot
;
*
min_y
+=
spr
->
_y
p
ivot
;
*
max_y
+=
spr
->
_y
p
ivot
;
*
min_x
+=
spr
->
_x
P
ivot
;
*
max_x
+=
spr
->
_x
P
ivot
;
*
min_y
+=
spr
->
_y
P
ivot
;
*
max_y
+=
spr
->
_y
P
ivot
;
// Test only to show bounding box
// spr->fillSprite(TFT_BLACK);
...
...
Extensions/Sprite.h
View file @
52ee45b3
...
...
@@ -9,7 +9,7 @@ class TFT_eSprite : public TFT_eSPI {
public:
TFT_eSprite
(
TFT_eSPI
*
tft
);
explicit
TFT_eSprite
(
TFT_eSPI
*
tft
);
~
TFT_eSprite
(
void
);
// Create a sprite of width x height pixels, return a pointer to the RAM area
...
...
@@ -167,15 +167,15 @@ class TFT_eSprite : public TFT_eSPI {
uint8_t
_bpp
;
// bits per pixel (1, 8 or 16)
uint16_t
*
_img
;
// pointer to 16 bit sprite
uint8_t
*
_img8
;
// pointer to 8 bit sprite
uint8_t
*
_img8
;
// pointer to 8 bit sprite
frame 1 or frame 2
uint8_t
*
_img4
;
// pointer to 4 bit sprite (uses color map)
uint8_t
*
_img8_1
;
// pointer to frame 1
uint8_t
*
_img8_2
;
// pointer to frame 2
uint16_t
*
_colorMap
;
// color map: 16 entries, used with 4 bit color map.
int16_t
_x
p
ivot
;
// x pivot point coordinate
int16_t
_y
p
ivot
;
// y pivot point coordinate
int16_t
_x
P
ivot
;
// x pivot point coordinate
int16_t
_y
P
ivot
;
// y pivot point coordinate
int32_t
_sinra
;
int32_t
_cosra
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment