Add rainbow surface generator
This commit is contained in:
parent
0e567b36fd
commit
1a725e50a2
1 changed files with 18 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
from dataclasses import dataclass
|
||||
import math
|
||||
import random
|
||||
from typing import Generator, Tuple
|
||||
from typing import Generator, Literal, Tuple
|
||||
import pygame as pg
|
||||
|
||||
|
||||
|
@ -42,6 +42,23 @@ def color_randomize() -> Generator[pg.Color, None, None]:
|
|||
color.hsla = random.randint(0, 359), s, l, a
|
||||
|
||||
|
||||
def rainbow_surface(
|
||||
image: pg.Surface,
|
||||
orientation: Literal["h", "v"] = "h",
|
||||
hue: int = 0,
|
||||
increase: int = 1,
|
||||
):
|
||||
wheel = color_wheel(hue, increase)
|
||||
if orientation == "h":
|
||||
h = image.get_height()
|
||||
for x in range(image.get_width()):
|
||||
pg.draw.line(image, next(wheel), (x, 0), (x, h))
|
||||
elif orientation == "v":
|
||||
w = image.get_width()
|
||||
for y in range(image.get_height()):
|
||||
pg.draw.line(image, next(wheel), (0, y), (w, y))
|
||||
|
||||
|
||||
def transform_bounce(
|
||||
bounds: pg.Rect,
|
||||
velocity: Tuple[int, int],
|
||||
|
|
Loading…
Reference in a new issue