import entire random library in extension

This commit is contained in:
Frank DeMarco 2020-01-27 22:48:28 -05:00
parent 10ee6533f0
commit 7a4f318ac2
1 changed files with 5 additions and 6 deletions

View File

@ -1,5 +1,4 @@
import itertools
from random import randint, random
import itertools, random
from math import sin, cos, atan2, radians, sqrt, pi
from pygame import Surface, PixelArray, Color, Rect, draw
@ -101,7 +100,7 @@ def get_distance(p0, p1):
def place_in_rect(rect, incoming, contain=True, *args):
while True:
incoming.center = randint(0, rect.w), randint(0, rect.h)
incoming.center = random.randint(0, rect.w), random.randint(0, rect.h)
if not contain or rect.contains(incoming):
collides = False
for inner in args:
@ -153,7 +152,7 @@ def collide_line_with_rect(rect, p0, p1):
return True
def get_random_number_in_range(start, end):
return random() * (end - start) + start
return random.random() * (end - start) + start
def get_value_in_range(start, end, position, reverse=False):
if reverse:
@ -324,8 +323,8 @@ def get_hsla_color(hue, saturation=100, lightness=50, alpha=100):
def get_random_hsla_color(hue_range=(0, 359), saturation_range=(0, 100),
lightness_range=(0, 100), alpha_range=(100, 100)):
return get_hsla_color(
randint(*hue_range), randint(*saturation_range), randint(*lightness_range),
randint(*alpha_range))
random.randint(*hue_range), random.randint(*saturation_range), random.randint(*lightness_range),
random.randint(*alpha_range))
def get_hsva_color(hue, saturation=100, value=100, alpha=100):
color = Color(0, 0, 0, 0)