Skip to content

Commit

Permalink
Adjusted swerve widget sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Dec 20, 2023
1 parent d548b30 commit 018aa48
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions lib/widgets/nt_widgets/multi-topic/swerve_drive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ class SwerveDriveWidget extends NTWidget {
tryCast(ntConnection.getLastAnnouncedValue(robotAngleTopic)) ?? 0.0;

return LayoutBuilder(builder: (context, constraints) {
double sideLength = min(constraints.maxWidth, constraints.maxHeight);
double sideLength =
min(constraints.maxWidth, constraints.maxHeight) * 0.9;
return Transform.rotate(
angle: (showRobotRotation) ? radians(-robotAngle) : 0.0,
child: SizedBox(
Expand Down Expand Up @@ -271,10 +272,11 @@ class SwerveDrivePainter extends CustomPainter {
}

void drawRobotFrame(Canvas canvas, Size size, Offset offset) {
final double scaleFactor = size.width / 128.95;
final double circleRadius = min(size.width, size.height) / 8;

Paint framePainter = Paint()
..strokeWidth = 2
..strokeWidth = 1.75 * scaleFactor
..color = Colors.grey
..style = PaintingStyle.stroke;

Expand Down Expand Up @@ -328,20 +330,23 @@ class SwerveDrivePainter extends CustomPainter {
final double circleRadius = min(size.width, size.height) / 8;
const double arrowAngle = 40 * pi / 180;

final double pixelsPerMPS = 12.5 / 1.0 * size.width / 240.0;
final double scaleFactor = size.width / 128.95;

const double minArrowBase = 8.5;
const double maxArrowBase = 16.0;
final double pixelsPerMPS = 6.75 / 1.0 * scaleFactor;

final double minArrowBase = 6.5 * scaleFactor;
final double maxArrowBase = 16.0 * scaleFactor;

Paint arrowPaint = Paint()
..strokeWidth = 2
..strokeWidth = 2 * scaleFactor
..color = Colors.red
..style = PaintingStyle.stroke;

Paint anglePaint = Paint()
..strokeWidth = 4
..strokeWidth = 3.75 * scaleFactor
..color = Colors.red
..style = PaintingStyle.stroke;
..style = PaintingStyle.stroke
..strokeCap = StrokeCap.round;

// Front left angle indicator thing
Rect frontLeftWheel = Rect.fromCenter(
Expand Down Expand Up @@ -571,6 +576,8 @@ class SwerveDrivePainter extends CustomPainter {
}

void drawRobotDirectionArrow(Canvas canvas, Size size, Offset offset) {
final double scaleFactor = size.width / 58.0;

const double arrowAngle = 40 * pi / 180;
final double base = size.width * 0.45;
const double arrowRotation = -pi / 2;
Expand All @@ -580,7 +587,7 @@ class SwerveDrivePainter extends CustomPainter {
Offset center = Offset(size.width, size.height) / 2 + offset;

Paint arrowPainter = Paint()
..strokeWidth = 4
..strokeWidth = 4 * scaleFactor
..color = Colors.red
..style = PaintingStyle.stroke;

Expand Down

0 comments on commit 018aa48

Please sign in to comment.