Only use exact pixel scales again

This commit is contained in:
Pyrex 2023-09-09 18:58:31 -07:00
parent fa8d09d504
commit e5cd74926f
2 changed files with 28 additions and 4 deletions

View File

@ -8,5 +8,5 @@ void main() async {
.bg(Palette.subtitle)
.fg(Palette.defaultBg)
.big()
.puts("BEWARE OF THE BAT!");
.puts("BEWARE OF THE BAT!\nA cool bat.");
}

View File

@ -1,3 +1,4 @@
import 'dart:developer';
import 'dart:ui' as ui;
import 'dart:ui';
@ -32,9 +33,32 @@ class TerminalCustomPainter extends CustomPainter {
var image = pr
.endRecording()
// Renderer does something bizarre if I don't multiply by something greater than 1
.toImageSync(cellW * Terminal.width * 2, cellH * Terminal.height * 2);
canvas.drawImageRect(image, const Offset(0, 0) & smallSize,
const Offset(0, 0) & size, Paint()..filterQuality = FilterQuality.none);
.toImageSync(cellW * Terminal.width * 1, cellH * Terminal.height * 1);
double x0, y0, xSz, ySz;
(x0, y0) = (0.0, 0.0);
(xSz, ySz) = (size.width, size.height);
for (var multiplierBase = 16.0; multiplierBase >= 1; multiplierBase -= 1) {
final multiplier = multiplierBase / scalingFactor;
final candidateXSz = (multiplier * cellW * Terminal.width).toDouble();
final candidateYSz = (multiplier * cellH * Terminal.height).toDouble();
if (candidateXSz <= size.width && candidateYSz <= size.height) {
xSz = candidateXSz;
ySz = candidateYSz;
x0 = (size.width - xSz) / 2;
y0 = (size.height - ySz) / 2;
x0 = (x0 * scalingFactor).floor() / scalingFactor;
y0 = (y0 * scalingFactor).floor() / scalingFactor;
break;
}
}
log("$x0, $y0, $xSz, $ySz");
canvas.drawImageRect(
image,
const Offset(0, 0) & smallSize,
Offset(x0, y0) & Size(xSz, ySz),
Paint()..filterQuality = FilterQuality.none);
}
void virtualPaint(Canvas canvas, Size size) {