Fix scales being drawn outside of image

closes #54
This commit is contained in:
sfan5 2018-03-24 13:57:27 +01:00
parent cca7072eab
commit 7288e60cd2

View File

@ -618,10 +618,12 @@ void TileGenerator::renderScale()
buf << i * 16;
int xPos = (m_xMin * -16 + i * 16)*m_zoom + m_xBorder;
if (xPos >= 0) {
m_image->drawText(xPos + 2, 0, buf.str(), m_scaleColor);
m_image->drawLine(xPos, 0, xPos, m_yBorder - 1, m_scaleColor);
}
}
}
if (m_scales & SCALE_LEFT) {
m_image->drawText(2, 24, "Z", m_scaleColor);
@ -630,10 +632,12 @@ void TileGenerator::renderScale()
buf << i * 16;
int yPos = (m_mapHeight - 1 - (i * 16 - m_zMin * 16))*m_zoom + m_yBorder;
if (yPos >= 0) {
m_image->drawText(2, yPos, buf.str(), m_scaleColor);
m_image->drawLine(0, yPos, m_xBorder - 1, yPos, m_scaleColor);
}
}
}
if (m_scales & SCALE_BOTTOM) {
for (int i = (m_xMin / 4) * 4; i <= m_xMax; i += 4) {
@ -642,10 +646,12 @@ void TileGenerator::renderScale()
int xPos = (m_xMin * -16 + i * 16)*m_zoom + m_xBorder;
int yPos = m_yBorder + m_mapHeight*m_zoom;
if (xPos >= 0) {
m_image->drawText(xPos + 2, yPos, buf.str(), m_scaleColor);
m_image->drawLine(xPos, yPos, xPos, yPos + 39, m_scaleColor);
}
}
}
if (m_scales & SCALE_RIGHT) {
for (int i = (m_zMax / 4) * 4; i >= m_zMin; i -= 4) {
@ -654,10 +660,12 @@ void TileGenerator::renderScale()
int xPos = m_xBorder + m_mapWidth*m_zoom;
int yPos = (m_mapHeight - 1 - (i * 16 - m_zMin * 16))*m_zoom + m_yBorder;
if (yPos >= 0) {
m_image->drawText(xPos + 2, yPos, buf.str(), m_scaleColor);
m_image->drawLine(xPos, yPos, xPos + 39, yPos, m_scaleColor);
}
}
}
}
void TileGenerator::renderOrigin()