Files

94 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
/// The original APP.svg gradient, expressed in its view-box coordinates.
const tpBrandGradient = LinearGradient(
begin: Alignment(2 * 324.09 / 2008.27 - 1, 2 * 1572.05 / 2009.62 - 1),
end: Alignment(2 * 1871.99 / 2008.27 - 1, 2 * 280.93 / 2009.62 - 1),
colors: [Color(0xFF3FD1FF), Color(0xFF38B3FF), Color(0xFF2A6CFF)],
stops: [0, 0.28, 1],
);
/// Vector rendering of assets/branding/APP.svg; no raster scaling or redesign.
class TpLogo extends StatelessWidget {
const TpLogo({super.key, this.size = 128, this.background = true});
final double size;
final bool background;
@override
Widget build(BuildContext context) => Semantics(
label: 'TPSchedule 标志',
image: true,
child: SizedBox.square(
dimension: size,
child: CustomPaint(painter: _TpLogoPainter(background: background)),
),
);
}
class _TpLogoPainter extends CustomPainter {
const _TpLogoPainter({required this.background});
final bool background;
@override
void paint(Canvas canvas, Size size) {
canvas.save();
canvas.scale(size.width / 2008.27, size.height / 2009.62);
if (background) {
const bounds = Rect.fromLTWH(0.5, 0.5, 2007.27, 2008.62);
canvas.drawRect(
bounds,
Paint()
..shader = tpBrandGradient.createShader(
const Rect.fromLTWH(0, 0, 2008.27, 2009.62),
),
);
canvas.drawRect(
bounds,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = Colors.black,
);
}
final stroke = Paint()
..style = PaintingStyle.stroke
..strokeJoin = StrokeJoin.miter
..strokeMiterLimit = 10
..strokeCap = StrokeCap.butt;
canvas.drawRRect(
RRect.fromRectAndRadius(
const Rect.fromLTWH(405.1, 514.64, 1198.08, 1071.89),
const Radius.circular(20),
),
stroke
..color = const Color(0xFFFFD22A)
..strokeWidth = 217,
);
stroke
..color = Colors.white
..strokeWidth = 150;
for (final x in [704.07, 1249.91]) {
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(x, 339.92, 64.51, 349.44),
const Radius.circular(27.65),
),
stroke,
);
}
canvas.drawPath(
Path()
..moveTo(729.01, 1004.81)
..relativeCubicTo(70.21, 112.08, 200.6, 174.7, 327.98, 152.69)
..relativeCubicTo(122.48, -18.51, 206.2, -123.19, 222.28, -152.69),
stroke..strokeWidth = 185,
);
canvas.restore();
}
@override
bool shouldRepaint(_TpLogoPainter oldDelegate) =>
background != oldDelegate.background;
}