Dramatically improve ASCII renderer
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -63,7 +63,7 @@ class _WolfAsciiRendererState extends State<WolfAsciiRenderer>
|
|||||||
// Calculate frame synchronously and trigger UI rebuild
|
// Calculate frame synchronously and trigger UI rebuild
|
||||||
setState(() {
|
setState(() {
|
||||||
// 120x40 is a great sweet spot for text density vs aspect ratio
|
// 120x40 is a great sweet spot for text density vs aspect ratio
|
||||||
_asciiFrame = _asciiRasterizer.render(engine, FrameBuffer(120, 40));
|
_asciiFrame = _asciiRasterizer.render(engine, FrameBuffer(160, 100));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,22 +87,34 @@ class _WolfAsciiRendererState extends State<WolfAsciiRenderer>
|
|||||||
autofocus: true,
|
autofocus: true,
|
||||||
onKeyEvent: (_) {},
|
onKeyEvent: (_) {},
|
||||||
// Added the missing argument here
|
// Added the missing argument here
|
||||||
|
child: Center(
|
||||||
child: _asciiFrame.isEmpty
|
child: _asciiFrame.isEmpty
|
||||||
? const SizedBox.shrink()
|
? const SizedBox.shrink()
|
||||||
: _buildAsciiFrame(_asciiFrame),
|
: AsciiFrameWidget(frameData: _asciiFrame),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildAsciiFrame(List<List<ColoredChar>> frameData) {
|
class AsciiFrameWidget extends StatelessWidget {
|
||||||
return Column(
|
final List<List<ColoredChar>> frameData;
|
||||||
|
|
||||||
|
const AsciiFrameWidget({super.key, required this.frameData});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return FittedBox(
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: frameData.map((row) {
|
children: frameData.map((row) {
|
||||||
return RichText(
|
return RichText(
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontFamily: 'Courier',
|
fontFamily: 'monospace',
|
||||||
fontSize: 8, // Bumped slightly for better visibility
|
|
||||||
height: 1.0,
|
height: 1.0,
|
||||||
letterSpacing: 2.0,
|
letterSpacing: 2.0,
|
||||||
),
|
),
|
||||||
@@ -115,6 +127,8 @@ class _WolfAsciiRendererState extends State<WolfAsciiRenderer>
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user