Skip to content

Commit

Permalink
Implement clipping in DrawingContextImpl
Browse files Browse the repository at this point in the history
The implementation of clipping was added in the DrawingContextImpl.cs. This ensures the pixel buffer coordinates stay within the defined bounds when rendering text, specifically with tabs, thereby improving the rendering process and accuracy.
  • Loading branch information
jinek committed Jan 5, 2024
1 parent edd2f41 commit ed022e6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Consolonia.Core/Drawing/DrawingContextImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,14 @@ void DrawPixelAndMoveHead(int count)
const int tabSize = 8;
var consolePixel = new Pixel(' ', foregroundColor);
for (int j = 0; j < tabSize; j++)
_pixelBuffer.Set((PixelBufferCoordinate)characterPoint.WithX(characterPoint.X + j),
(oldPixel, cp) => oldPixel.Blend(cp), consolePixel);
{
Point newCharacterPoint = characterPoint.WithX(characterPoint.X + j);
CurrentClip.ExecuteWithClipping(newCharacterPoint, () =>
{
_pixelBuffer.Set((PixelBufferCoordinate)characterPoint.WithX(characterPoint.X + j),
(oldPixel, cp) => oldPixel.Blend(cp), consolePixel);
});
}


currentXPosition += tabSize - 1;
Expand Down

0 comments on commit ed022e6

Please sign in to comment.