min_dist_tag = TextObject([0, 0], [255, 0, 0], pygame.font.SysFont( 'arial', 20), 'Minimum distance(px): {}'.format(params['min_dist'])) def adj_min_dist_func(): params.update({ 'min_dist': max(20, min(50, adjs['delta_min_dist'] + params['min_dist'])) }) min_dist_tag.set_text('Minimum distance(px): {}'.format( params['min_dist'])) min_dist_tag.__build__() pygame.time.wait(150) adjust_min_dist = Button([0, 0], [255, 0, 0], pygame.font.SysFont('arial', 20), 'Adjust Min Distance', [0, 255, 0], [30, 10], on_hold=adj_min_dist_func) toggle_min_dist_adj_direction = ToggleButton( [0, 0], [[255, 0, 0], [0, 255, 0]], pygame.font.SysFont('arial', 20), ['INCREASE', 'DECREASE'], [30, 10], on_click=lambda: adjs.update( {'delta_min_dist': adjs['delta_min_dist'] * -1})) min_dist_row = RowBorder( [window_size[0] // 4, 240], [0, 255, 255], 950, 10, [min_dist_tag, adjust_min_dist, toggle_min_dist_adj_direction])
from pygameui.clickable.toggle_button import ToggleButton from pygameui.text_object import TextObject from pygameui.row_border import RowBorder import pygame noise_tag = TextObject([0, 0], [255, 0, 0], pygame.font.SysFont('arial', 20), 'Noise Bounds: +-{}'.format(params['noise'])) def adj_noise_func(): params.update( {'noise': max(0, min(30, adjs['delta_noise'] + params['noise']))}) noise_tag.set_text('Noise Bounds: +-{}'.format(params['noise'])) noise_tag.__build__() pygame.time.wait(150) adjust_noise = Button([0, 0], [255, 0, 0], pygame.font.SysFont('arial', 20), 'Adjust Noise', [0, 255, 0], [30, 10], on_hold=adj_noise_func) toggle_noise_adj_direction = ToggleButton( [0, 0], [[255, 0, 0], [0, 255, 0]], pygame.font.SysFont('arial', 20), ['INCREASE', 'DECREASE'], [30, 10], on_click=lambda: adjs.update({'delta_noise': adjs['delta_noise'] * -1})) noise_row = RowBorder([window_size[0] // 4, 730], [0, 255, 255], 950, 10, [noise_tag, adjust_noise, toggle_noise_adj_direction])
}) influence_tag.set_text('Visual perception(px): {}'.format( params['influence'])) influence_tag.__build__() pygame.time.wait(150) adjust_influence = Button([0, 0], [255, 0, 0], pygame.font.SysFont('arial', 20), 'Adjust Influence', [0, 255, 0], [30, 10], on_hold=adj_influence_func) toggle_influence_adj_direction = ToggleButton( [0, 0], [[255, 0, 0], [0, 255, 0]], pygame.font.SysFont('arial', 20), ['INCREASE', 'DECREASE'], [30, 10], on_click=lambda: adjs.update( {'delta_influence': adjs['delta_influence'] * -1})) toggle_delta_influence = ToggleButton( [0, 0], [[255, 0, 0], [255, 0, 0], [255, 0, 0]], pygame.font.SysFont('arial', 20), ['1', '10', '100'], [30, 10], on_click=lambda: adjs.update( {'delta_influence': adjs['delta_influence'] * 10}) if -100 < adjs['delta_influence'] < 100 else adjs.update( {'delta_influence': np.sign(adjs['delta_influence'])})) influence_row = RowBorder([window_size[0] // 4, 170], [0, 255, 255], 950, 10, [ influence_tag, adjust_influence, toggle_influence_adj_direction, toggle_delta_influence ])
pygame.time.wait(150) adjust_jitter = Button([0, 0], [255, 0, 0], pygame.font.SysFont('arial', 20), 'Adjust jitter', [0, 255, 0], [30, 10], on_hold = adj_jitter_func) toggle_jitter_adj_direction = ToggleButton([0, 0], [[255, 0, 0], [0, 255, 0]], pygame.font.SysFont('arial', 20), ['INCREASE', 'DECREASE'], [30, 10], on_click = lambda: adjs.update({'delta_jitter' : adjs['delta_jitter'] * -1})) toggle_delta_jitter = ToggleButton([0, 0], [[255, 0, 0], [255, 0, 0]], pygame.font.SysFont('arial', 20), ['1', '10'], [30, 10], on_click = lambda: adjs.update({'delta_jitter' : adjs['delta_jitter'] * 10}) if -10 < adjs['delta_jitter'] < 10 else adjs.update({'delta_jitter' : np.sign(adjs['delta_jitter'])})) jitter_row = RowBorder([window_size[0]//4, 660], [0, 255, 255], 950, 10, [jitter_tag, adjust_jitter, toggle_jitter_adj_direction, toggle_delta_jitter])
cohesion_factor_tag.set_text('Cohesion Factor: {:.2f}'.format( round(params['cohesion_factor'], 2))) cohesion_factor_tag.__build__() pygame.time.wait(150) adjust_cohesion_factor = Button([0, 0], [255, 0, 0], pygame.font.SysFont('arial', 20), 'Adjust Cohesion Factor', [0, 255, 0], [30, 10], on_hold=adj_cohesion_factor_func) toggle_cohesion_factor_adj_direction = ToggleButton( [0, 0], [[255, 0, 0], [0, 255, 0]], pygame.font.SysFont('arial', 20), ['INCREASE', 'DECREASE'], [30, 10], on_click=lambda: adjs.update( {'delta_cohesion_factor': adjs['delta_cohesion_factor'] * -1})) toggle_delta_cohesion_factor = ToggleButton( [0, 0], [[255, 0, 0], [255, 0, 0], [255, 0, 0]], pygame.font.SysFont('arial', 20), ['0.01', '0.1'], [30, 10], on_click=lambda: adjs.update({ 'delta_cohesion_factor': 0.1 * np.sign(adjs['delta_cohesion_factor']) }) if -0.05 < adjs['delta_cohesion_factor'] < 0.05 else adjs.update({ 'delta_cohesion_factor': 0.01 * np.sign(adjs['delta_cohesion_factor']) })) cohesion_factor_row = RowBorder( [window_size[0] // 4, 380], [0, 255, 255], 950, 10, [ cohesion_factor_tag, adjust_cohesion_factor,
pygame.time.wait(150) adjust_separation_factor = Button([0, 0], [255, 0, 0], pygame.font.SysFont('arial', 20), 'Adjust Separation Factor', [0, 255, 0], [30, 10], on_hold = adj_separation_factor_func) toggle_separation_factor_adj_direction = ToggleButton([0, 0], [[255, 0, 0], [0, 255, 0]], pygame.font.SysFont('arial', 20), ['INCREASE', 'DECREASE'], [30, 10], on_click = lambda: adjs.update({'delta_separation_factor' : adjs['delta_separation_factor'] * -1})) toggle_delta_separation_factor = ToggleButton([0, 0], [[255, 0, 0], [255, 0, 0], [255, 0 ,0]], pygame.font.SysFont('arial', 20), ['0.01', '0.1'], [30, 10], on_click = lambda: adjs.update({'delta_separation_factor' : 0.1 * np.sign(adjs['delta_separation_factor'])}) if -0.05 < adjs['delta_separation_factor'] < 0.05 else adjs.update({'delta_separation_factor' : 0.01 * np.sign(adjs['delta_separation_factor'])})) separation_factor_row = RowBorder([window_size[0]//4, 450], [0,255, 255], 950, 10, [separation_factor_tag, adjust_separation_factor, toggle_separation_factor_adj_direction, toggle_delta_separation_factor])
import pygame max_speed_tag = TextObject([0, 0], [255, 0, 0], pygame.font.SysFont('arial', 20), 'Max Speed(px): {}'.format(params['max_speed'])) def adj_max_speed_func(): params.update({ 'max_speed': max(1, min(30, params['max_speed'] + adjs['delta_max_speed'])) }) max_speed_tag.set_text('Max Speed(px): {}'.format(params['max_speed'])) max_speed_tag.__build__() pygame.time.wait(150) adjust_max_speed = Button([0, 0], [255, 0, 0], pygame.font.SysFont('arial', 20), 'Adjust Speed', [0, 255, 0], [30, 10], on_hold=adj_max_speed_func) toggle_max_speed_adj_direction = ToggleButton( [0, 0], [[255, 0, 0], [0, 255, 0]], pygame.font.SysFont('arial', 20), ['INCREASE', 'DECREASE'], [30, 10], on_click=lambda: adjs.update( {'delta_max_speed': adjs['delta_max_speed'] * -1})) max_speed_row = RowBorder( [window_size[0] // 4, 100], [0, 255, 255], 950, 10, [max_speed_tag, adjust_max_speed, toggle_max_speed_adj_direction])
pygame.time.wait(150) adjust_obj_margin = Button([0, 0], [255, 0, 0], pygame.font.SysFont('arial', 20), 'Adjust Object Margin', [0, 255, 0], [30, 10], on_hold = adj_obj_margin_func) toggle_obj_margin_adj_direction = ToggleButton([0, 0], [[255, 0, 0], [0, 255, 0]], pygame.font.SysFont('arial', 20), ['INCREASE', 'DECREASE'], [30, 10], on_click = lambda: adjs.update({'delta_obj_margin' : adjs['delta_obj_margin'] * -1})) toggle_delta_obj_margin = ToggleButton([0, 0], [[255, 0, 0], [255, 0, 0], [255, 0 ,0]], pygame.font.SysFont('arial', 20), ['1', '10', '100'], [30, 10], on_click = lambda: adjs.update({'delta_obj_margin' : adjs['delta_obj_margin'] * 10}) if -100 < adjs['delta_obj_margin'] < 100 else adjs.update({'delta_obj_margin' : np.sign(adjs['delta_obj_margin'])})) obj_margin_row = RowBorder([window_size[0]//4, 310], [0,255, 255], 950, 10, [obj_margin_tag, adjust_obj_margin, toggle_obj_margin_adj_direction, toggle_delta_obj_margin])