Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65115482
arrow.dart
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, May 31, 22:40
Size
2 KB
Mime Type
text/x-c++
Expires
Sun, Jun 2, 22:40 (2 d)
Engine
blob
Format
Raw Data
Handle
18006252
Attached To
R10646 Orchestration
arrow.dart
View Options
import 'package:flutter/material.dart';
import 'package:arrow_path/arrow_path.dart';
import 'package:student/model/Cellulo.dart';
class Arrow extends CustomPainter {
// <-- CustomPainter class
var celluloxPosition;
var celluloyPosition;
var coeffScreenMapWidth;
var coeffScreenMapHeight;
double directionx;
double directiony;
Offset celluloyM;
Offset celluloxM;
Arrow(this.celluloxPosition, this.celluloyPosition, this.coeffScreenMapWidth,
this.coeffScreenMapHeight, this.directionx, this.directiony) {
celluloxM = Offset(celluloxPosition[0] * coeffScreenMapWidth,
celluloxPosition[1] * coeffScreenMapHeight);
celluloyM = Offset(celluloyPosition[0] * coeffScreenMapWidth,
celluloyPosition[1] * coeffScreenMapHeight);
if (directionx < -40)
directionx = -1;
else if (directionx > 40)
directionx = 1;
else {
directionx = 0;
}
if (directiony < -40)
directiony = -1;
else if (directiony > 40)
directiony = 1;
else {
directiony = 0;
}
}
@override
void paint(Canvas canvas, Size size) {
Path path;
Paint paintblue = Paint()
..color = Colors.blue
..style = PaintingStyle.stroke
..strokeCap = StrokeCap.round
..strokeJoin = StrokeJoin.round
..strokeWidth = 3.0;
Paint paintRed = Paint()
..color = Colors.red
..style = PaintingStyle.stroke
..strokeCap = StrokeCap.round
..strokeJoin = StrokeJoin.round
..strokeWidth = 3.0;
path = Path();
path.moveTo(celluloxM.dx - 20, celluloxM.dy - 20);
path.relativeCubicTo(0, 0, 0, 0, directionx.toDouble() * 40, 0);
path = ArrowPath.make(path: path);
canvas.drawPath(path, paintRed);
path.moveTo(celluloyM.dx + 30, celluloyM.dy);
path.relativeCubicTo(0, 0, 0, 0, 0, directiony.toDouble() * 40);
path = ArrowPath.make(path: path);
canvas.drawPath(path, paintblue);
//canvas.drawLine(p1, p2, paint);
}
@override
bool shouldRepaint(CustomPainter old) {
return false;
}
}
Event Timeline
Log In to Comment