figments: surface: handle swapped start/end positions
This commit is contained in:
parent
e5d4eea02b
commit
c91757308d
@ -54,17 +54,20 @@ void
|
|||||||
Surface::paintShader(Surface::Shader shader)
|
Surface::paintShader(Surface::Shader shader)
|
||||||
{
|
{
|
||||||
PerfCounter _("paintShader");
|
PerfCounter _("paintShader");
|
||||||
const uint16_t width = end.x - start.x + 1;
|
uint8_t startX = min(start.x, end.x);
|
||||||
const uint16_t height = end.y - start.y + 1;
|
uint8_t startY = min(start.y, end.y);
|
||||||
|
uint8_t endX = max(start.x, end.x);
|
||||||
|
uint8_t endY = max(start.y, end.y);
|
||||||
|
const uint16_t width = endX - startX + 1;
|
||||||
|
const uint16_t height = endY - startY + 1;
|
||||||
const uint8_t xMod = 255 / width;
|
const uint8_t xMod = 255 / width;
|
||||||
const uint8_t yMod = 255 / height;
|
const uint8_t yMod = 255 / height;
|
||||||
for(auto x = 0; x < width; x++) {
|
for(auto x = 0; x < width; x++) {
|
||||||
for(auto y = 0; y < height; y++) {
|
for(auto y = 0; y < height; y++) {
|
||||||
PhysicalCoordinates coords{x + start.x, y + start.y};
|
PhysicalCoordinates coords{x + startX, y + startY};
|
||||||
VirtualCoordinates virtCoords{m_display->coordinateMapping()->physicalToVirtualCoords(coords)};
|
VirtualCoordinates virtCoords{m_display->coordinateMapping()->physicalToVirtualCoords(coords)};
|
||||||
VirtualCoordinates surfaceCoords{xMod * x, yMod * y};
|
VirtualCoordinates surfaceCoords{xMod * x, yMod * y};
|
||||||
//Log.notice("width=%d height=%d vx=%d vy=%d sx=%d sy=%d x=%d y=%d px=%d py=%d", width, height, start.x, start.y, x, y, coords.x, coords.y);
|
//Log.notice("width=%d height=%d vx=%d vy=%d sx=%d sy=%d x=%d y=%d px=%d py=%d", width, height, startX, startY, x, y, coords.x, coords.y); // 256 = 1.0
|
||||||
// 256 = 1.0
|
|
||||||
// 128 = 0.0
|
// 128 = 0.0
|
||||||
// 0 = 1.0
|
// 0 = 1.0
|
||||||
shader(m_display->pixelAt(coords), virtCoords, coords, surfaceCoords);
|
shader(m_display->pixelAt(coords), virtCoords, coords, surfaceCoords);
|
||||||
|
Loading…
Reference in New Issue
Block a user