21 lines
889 B
MonkeyC
21 lines
889 B
MonkeyC
import Toybox.Graphics;
|
|
import Toybox.Lang;
|
|
import Toybox.Math;
|
|
|
|
function fillSuperellipse(dc as Dc, start as Point2D, direction as Point2D, length as Float, width as Float) {
|
|
var halfWidth = min(start) * width / 2.0;
|
|
var perpendicular = [-direction[1], direction[0]] as Point2D;
|
|
var end = [start[0] + direction[0] * length, start[1] + direction[1] * length];
|
|
|
|
// body part
|
|
dc.fillPolygon([
|
|
[start[0] + perpendicular[0] * halfWidth, start[1] + perpendicular[1] * halfWidth],
|
|
[start[0] - perpendicular[0] * halfWidth, start[1] - perpendicular[1] * halfWidth],
|
|
[end[0] - perpendicular[0] * halfWidth, end[1] - perpendicular[1] * halfWidth],
|
|
[end[0] + perpendicular[0] * halfWidth, end[1] + perpendicular[1] * halfWidth],
|
|
]);
|
|
|
|
// ends
|
|
dc.fillCircle(start[0], start[1], halfWidth);
|
|
dc.fillCircle(end[0], end[1], halfWidth);
|
|
} |