Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion arcade/drawing_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
from __future__ import annotations

import math
from typing import Tuple

__all__ = ["get_points_for_thick_line"]


def get_points_for_thick_line(start_x: float, start_y: float,
end_x: float, end_y: float,
line_width: float):
line_width: float) -> Tuple[Tuple[float, float], Tuple[float, float],
Tuple[float, float], Tuple[float, float]]:
"""
Function used internally for Arcade. OpenGL draws triangles only, so a thick
line must be two triangles that make up a rectangle. This calculates and returns
Expand Down
10 changes: 5 additions & 5 deletions arcade/earclip.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def earclip(polygon: PointList) -> List[Tuple[Tuple[float, float], Tuple[float,
return triangles


def _is_clockwise(polygon: List[Point]):
def _is_clockwise(polygon: List[Point]) -> bool:
s = 0.0
polygon_count = len(polygon)
for i in range(polygon_count):
Expand All @@ -78,17 +78,17 @@ def _is_clockwise(polygon: List[Point]):
return s > 0


def _is_convex(prev: Point, point: Point, next_point: Point):
def _is_convex(prev: Point, point: Point, next_point: Point) -> bool:
return _triangle_sum(prev[0], prev[1], point[0], point[1], next_point[0], next_point[1]) < 0


def _is_ear(p1: Point, p2: Point, p3: Point, polygon: List[Point]):
def _is_ear(p1: Point, p2: Point, p3: Point, polygon: List[Point]) -> bool:
return _contains_no_points(p1, p2, p3, polygon) and \
_is_convex(p1, p2, p3) and \
_triangle_area(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]) > 0


def _contains_no_points(p1: Point, p2: Point, p3: Point, polygon: List[Point]):
def _contains_no_points(p1: Point, p2: Point, p3: Point, polygon: List[Point]) -> bool:
for pn in polygon:
if pn in (p1, p2, p3):
continue
Expand All @@ -97,7 +97,7 @@ def _contains_no_points(p1: Point, p2: Point, p3: Point, polygon: List[Point]):
return True


def _is_point_inside(p: Point, a: Point, b: Point, c: Point):
def _is_point_inside(p: Point, a: Point, b: Point, c: Point) -> bool:
area = _triangle_area(a[0], a[1], b[0], b[1], c[0], c[1])
area1 = _triangle_area(p[0], p[1], b[0], b[1], c[0], c[1])
area2 = _triangle_area(p[0], p[1], a[0], a[1], c[0], c[1])
Expand Down
5 changes: 3 additions & 2 deletions arcade/easing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from math import pi, sin, cos
from dataclasses import dataclass
from typing import Callable, Tuple
from typing import Callable, Optional, Tuple
from .math import get_distance


Expand Down Expand Up @@ -147,7 +147,8 @@ def easing(percent: float, easing_data: EasingData) -> float:
easing_data.ease_function(percent)


def ease_angle(start_angle: float, end_angle: float, *, time=None, rate=None, ease_function: Callable = linear):
def ease_angle(start_angle: float, end_angle: float, *, time=None, rate=None,
ease_function: Callable = linear) -> Optional[EasingData]:
"""
Set up easing for angles.
"""
Expand Down
2 changes: 1 addition & 1 deletion arcade/particles/emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _emit(self):
p.change_y = vel.y
self._particles.append(p)

def get_count(self):
def get_count(self) -> int:
return len(self._particles)

def get_pos(self) -> Point:
Expand Down
4 changes: 2 additions & 2 deletions arcade/particles/emitter_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def make_burst_emitter(
particle_lifetime_min: float,
particle_lifetime_max: float,
particle_scale: float = 1.0,
fade_particles: bool = True):
fade_particles: bool = True) -> Emitter:
"""Returns an emitter that emits all of its particles at once"""
particle_factory: Type[LifetimeParticle] = LifetimeParticle
if fade_particles:
Expand All @@ -48,7 +48,7 @@ def make_interval_emitter(
particle_lifetime_min: float,
particle_lifetime_max: float,
particle_scale: float = 1.0,
fade_particles: bool = True):
fade_particles: bool = True) -> Emitter:
"""Returns an emitter that emits its particles at a constant rate for a given amount of time"""
particle_factory: Type[LifetimeParticle] = LifetimeParticle
if fade_particles:
Expand Down
5 changes: 3 additions & 2 deletions arcade/particles/particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Particle - Object produced by an Emitter. Often used in large quantity to produce visual effects effects
"""
from __future__ import annotations
from typing import Literal

from arcade.sprite import Sprite
from arcade.math import lerp, clamp
Expand Down Expand Up @@ -64,7 +65,7 @@ def __init__(
super().__init__(filename_or_texture, change_xy, center_xy, angle, change_angle, scale, alpha,
mutation_callback)

def can_reap(self):
def can_reap(self) -> Literal[False]:
"""Determine if Particle can be deleted"""
return False

Expand Down Expand Up @@ -94,7 +95,7 @@ def update(self):
super().update()
self.lifetime_elapsed += 1 / 60

def can_reap(self):
def can_reap(self) -> bool:
"""Determine if Particle can be deleted"""
return self.lifetime_elapsed >= self.lifetime_original

Expand Down