mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-28 00:53:45 +08:00
a82935f326
Integrate onroad views, configurable widgets, local settings, steering-profile contracts, Bluetooth and Android Auto with their device and runtime services. Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Daniel Koepping <elkoled@gmail.com> Co-authored-by: Danny <dannyirwin31@yahoo.com> Co-authored-by: DimitriChrysafis <Dimitri.chrysafis@gmail.com> Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com> Co-authored-by: Harald Schäfer <harald.the.engineer@gmail.com> Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu> Co-authored-by: Shane Smiskol <shane@smiskol.com> Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com> Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com> Co-authored-by: stef <19478336+stefpi@users.noreply.github.com> Co-authored-by: whoisdomi <dcantu83@gmail.com> Co-authored-by: Intelli <contact@intelli.software> Co-authored-by: pharmacomaniac <blittle65@gmail.com> Co-authored-by: prabhaavp <prabhaav@msu.edu>
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
"""Small crescent built without an opaque cutout over the camera."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import math
|
|
from functools import lru_cache
|
|
|
|
import pyray as rl
|
|
|
|
|
|
_DISTANCE = math.hypot(.45, -.3)
|
|
_DIRECTION = math.atan2(-.3, .45)
|
|
_INTERSECTION = math.acos(_DISTANCE / 2)
|
|
_POINTS = tuple(point for i in range(25) for point in (
|
|
(math.cos(_DIRECTION + _INTERSECTION + (2 * math.pi - 2 * _INTERSECTION) * i / 24),
|
|
math.sin(_DIRECTION + _INTERSECTION + (2 * math.pi - 2 * _INTERSECTION) * i / 24)),
|
|
(.45 + math.cos(_DIRECTION + math.pi - _INTERSECTION + 2 * _INTERSECTION * i / 24),
|
|
-.3 + math.sin(_DIRECTION + math.pi - _INTERSECTION + 2 * _INTERSECTION * i / 24)),
|
|
))
|
|
|
|
|
|
@lru_cache(maxsize=64)
|
|
def _vertices(x: float, y: float, width: float, height: float):
|
|
radius = min(width, height) / 2
|
|
cx, cy = x + width / 2, y + height / 2
|
|
return rl.ffi.new("Vector2[]", [(cx + px * radius, cy + py * radius) for px, py in _POINTS])
|
|
|
|
|
|
def draw_moon(rect: rl.Rectangle, color: rl.Color | None = None) -> None:
|
|
points = _vertices(rect.x, rect.y, rect.width, rect.height)
|
|
rl.draw_triangle_strip(rl.ffi.cast("Vector2 *", points), len(_POINTS), color if color is not None else rl.Color(188, 132, 255, 255))
|