Skip to content

Commit

Permalink
Fix scales being drawn outside of image
Browse files Browse the repository at this point in the history
closes #54
  • Loading branch information
sfan5 committed Mar 24, 2018
1 parent cca7072 commit 7288e60
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions TileGenerator.cpp
Expand Up @@ -618,8 +618,10 @@ void TileGenerator::renderScale()
buf << i * 16;

int xPos = (m_xMin * -16 + i * 16)*m_zoom + m_xBorder;
m_image->drawText(xPos + 2, 0, buf.str(), m_scaleColor);
m_image->drawLine(xPos, 0, xPos, m_yBorder - 1, m_scaleColor);
if (xPos >= 0) {
m_image->drawText(xPos + 2, 0, buf.str(), m_scaleColor);
m_image->drawLine(xPos, 0, xPos, m_yBorder - 1, m_scaleColor);
}
}
}

Expand All @@ -630,8 +632,10 @@ void TileGenerator::renderScale()
buf << i * 16;

int yPos = (m_mapHeight - 1 - (i * 16 - m_zMin * 16))*m_zoom + m_yBorder;
m_image->drawText(2, yPos, buf.str(), m_scaleColor);
m_image->drawLine(0, yPos, m_xBorder - 1, yPos, m_scaleColor);
if (yPos >= 0) {
m_image->drawText(2, yPos, buf.str(), m_scaleColor);
m_image->drawLine(0, yPos, m_xBorder - 1, yPos, m_scaleColor);
}
}
}

Expand All @@ -642,8 +646,10 @@ void TileGenerator::renderScale()

int xPos = (m_xMin * -16 + i * 16)*m_zoom + m_xBorder;
int yPos = m_yBorder + m_mapHeight*m_zoom;
m_image->drawText(xPos + 2, yPos, buf.str(), m_scaleColor);
m_image->drawLine(xPos, yPos, xPos, yPos + 39, m_scaleColor);
if (xPos >= 0) {
m_image->drawText(xPos + 2, yPos, buf.str(), m_scaleColor);
m_image->drawLine(xPos, yPos, xPos, yPos + 39, m_scaleColor);
}
}
}

Expand All @@ -654,8 +660,10 @@ 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;
m_image->drawText(xPos + 2, yPos, buf.str(), m_scaleColor);
m_image->drawLine(xPos, yPos, xPos + 39, yPos, m_scaleColor);
if (yPos >= 0) {
m_image->drawText(xPos + 2, yPos, buf.str(), m_scaleColor);
m_image->drawLine(xPos, yPos, xPos + 39, yPos, m_scaleColor);
}
}
}
}
Expand Down

0 comments on commit 7288e60

Please sign in to comment.