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
|
||||
setState(() {
|
||||
// 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,34 +87,48 @@ class _WolfAsciiRendererState extends State<WolfAsciiRenderer>
|
||||
autofocus: true,
|
||||
onKeyEvent: (_) {},
|
||||
// Added the missing argument here
|
||||
child: _asciiFrame.isEmpty
|
||||
? const SizedBox.shrink()
|
||||
: _buildAsciiFrame(_asciiFrame),
|
||||
child: Center(
|
||||
child: _asciiFrame.isEmpty
|
||||
? const SizedBox.shrink()
|
||||
: AsciiFrameWidget(frameData: _asciiFrame),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildAsciiFrame(List<List<ColoredChar>> frameData) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: frameData.map((row) {
|
||||
return RichText(
|
||||
text: TextSpan(
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Courier',
|
||||
fontSize: 8, // Bumped slightly for better visibility
|
||||
height: 1.0,
|
||||
letterSpacing: 2.0,
|
||||
),
|
||||
children: row.map((cell) {
|
||||
return TextSpan(
|
||||
text: cell.char,
|
||||
style: TextStyle(color: cell.color),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
class AsciiFrameWidget extends StatelessWidget {
|
||||
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,
|
||||
children: frameData.map((row) {
|
||||
return RichText(
|
||||
text: TextSpan(
|
||||
style: const TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
height: 1.0,
|
||||
letterSpacing: 2.0,
|
||||
),
|
||||
children: row.map((cell) {
|
||||
return TextSpan(
|
||||
text: cell.char,
|
||||
style: TextStyle(color: cell.color),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user