from hooman import Hooman import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: hapi.is_running = False hapi.handle_events = handle_events clock = pygame.time.Clock() hapi.set_background(hapi.color["white"]) while hapi.is_running: hapi.fill(hapi.colour["green"]) hapi.regular_polygon(100, 200, 50, 50, hapi.mouseX() // 50) hapi.rotate(hapi.mouseY() // 2) hapi.event_loop() hapi.flip_display()
""" Author: Abdur-Rahmaan Janhangeer Github: https://github.com/Abdur-rahmaanJ """ from hooman import Hooman import pygame hapi = Hooman(500, 500) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False hapi.handle_events = handle_events size = 50 while hapi.is_running: hapi.background((255, 255, 255)) hapi.no_stroke() hapi.fill((0, 255, 0)) hapi.rect(10, 10, size, size) hapi.fill((255, 255, 0)) hapi.rect(100, 100, size, size) hapi.fill((255, 0, 0)) hapi.rect(100, 10, size, size) hapi.fill((0, 0, 255))
from hooman import Hooman from collections import OrderedDict import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) while hapi.is_running: hapi.background(bg_col) hapi.piechart( hapi.center_x - 100, hapi.center_y, 100, [['a', 20, hapi.color['red']], ['b', 30, hapi.color['blue']], ['c', 40, hapi.color['yellow']], ['d', 60, hapi.color['green']], ['e', 30, hapi.color['black']]]) hapi.piechart( hapi.center_x + 100, hapi.center_y, 100, [['a', 20, hapi.color['red']], ['b', 30, hapi.color['blue']], ['c', 40, hapi.color['yellow']], ['d', 60, hapi.color['green']], ['e', 30, hapi.color['black']]], start_rad=30) hapi.event_loop() hapi.flip_display() pygame.quit()
from hooman import Hooman import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: hapi.is_running = False hapi.handle_events = handle_events clock = pygame.time.Clock() while hapi.is_running: hapi.background(bg_col) hapi.rotate(hapi.mouseX()) hapi.fill(hapi.color["red"]) hapi.heart(10, 200, hapi.mouseX() // 4, hapi.mouseY() // 4) hapi.arrow(300, 200, hapi.mouseX(), hapi.mouseY() // 2)
""" Original Author: https://github.com/jimmy-print Edit: https://github.com/Abdur-rahmaanJ """ from hooman import Hooman import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) rect_x, rect_y = 100, 100 rect_w, rect_h = 100, 100 dy = 0 gravity_acceleration = 1 jump_strength = 20 def handle_events(event): global dy if event.type == pygame.QUIT: hapi.is_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: hapi.is_running = False if event.key == pygame.K_SPACE: dy = -jump_strength hapi.handle_events = handle_events
from hooman import Hooman import numpy from math import pow from math import sqrt import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: hapi.is_running = False hapi.handle_events = handle_events clock = pygame.time.Clock() while hapi.is_running: hapi.background(bg_col) hapi.fill(hapi.color["red"]) n1 = (hapi.mouseX() / hapi.WIDTH) * 1 smooth_star = { "n1": n1,
from hooman import Hooman window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) while hapi.is_running: bg_col = (255, 255, 255) hapi.background(bg_col) hapi.barchart(30, 30, 200, 200, { "data": { "a": 10, "b": 20, "c": 90 }, "mouse_line": True }) # hapi.text(hapi.mouseX(), 200, 200) hapi.flip_display() hapi.event_loop()
from hooman import Hooman import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) while hapi.is_running: hapi.background(bg_col) hapi.fill(hapi.color["red"]) hapi.fill_arc(hapi.center_x, hapi.center_y, 100, 0, 90, start_rad=30) hapi.fill(hapi.color["blue"]) hapi.fill_arc(hapi.center_x, hapi.center_y, 100, 90, 180, start_rad=30) hapi.fill(hapi.color["green"]) hapi.fill_arc(hapi.center_x, hapi.center_y, 100, 180, 270, start_rad=30) hapi.fill(hapi.color["black"]) hapi.fill_arc(hapi.center_x, hapi.center_y, 100, 270, 0, start_rad=30) hapi.event_loop() hapi.flip_display() pygame.quit()
from hooman import Hooman import numpy from math import pow from math import sqrt import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: hapi.is_running = False hapi.handle_events = handle_events clock = pygame.time.Clock() while hapi.is_running: hapi.background(bg_col) hapi.fill(hapi.color["red"]) # hapi.text(n1, 10+hapi.mouseX(), 10+hapi.mouseY())
from hooman import Hooman window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) while hapi.is_running: bg_col = (255, 255, 255) hapi.background(bg_col) hapi.linechart( 40, 30, 300, 200, { "data": [[0, 0], [10, 10], [20, 20], [30, 30], [90, 20]], "mouse_line": True, "range_y": [0, 200], "range_x": [0, 300], }, ) hapi.fill(hapi.color["blue"]) hapi.flip_display() hapi.event_loop()
from hooman import Hooman import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) red_blue = hapi.gradient(300, 30, hapi.color["blue"], hapi.color["red"]).convert() green_blue = hapi.gradient(300, 30, hapi.color["green"], hapi.color["blue"]).convert() yellow_black = hapi.gradient(300, 30, hapi.color["yellow"], hapi.color["black"]).convert() black_white = hapi.gradient(300, 30, hapi.color["black"], hapi.color["white"]).convert() slider = hapi.slider(100, 300, 300, 30, { "image": red_blue, "slider_height": 60, "value_range": [0, 255] }) color_slider = hapi.slider( 150, 400, 200, 20, {
from hooman import Hooman import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: hapi.is_running = False hapi.handle_events = handle_events clock = pygame.time.Clock() while hapi.is_running: hapi.background(bg_col) hapi.fill(hapi.color["red"]) hapi.star(100, 100, 30, 70, hapi.mouseX() // 10) hapi.event_loop() hapi.flip_display()
"""Author: Bhargava N Reddy Github: https://github.com/reddybhargava """ from hooman import Hooman import pygame from random import sample window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: hapi.is_running = False hapi.handle_events = handle_events clock = pygame.time.Clock() background_color = (0, 255, 255) while hapi.is_running: hapi.background(background_color) hapi.event_loop() num_of_stars = window_width // 100 random_colors = sample(list(hapi.color.values()), num_of_stars)
from hooman import Hooman import numpy from math import pow from math import sqrt import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) slider_options = {"value_range": [0, 255]} r_slider = hapi.slider(50, 300, 400, 10, slider_options) g_slider = hapi.slider(50, 330, 400, 10, slider_options) b_slider = hapi.slider(50, 360, 400, 10, slider_options) while hapi.is_running: bg_col = (r_slider.value(), g_slider.value(), b_slider.value()) hapi.background(bg_col) hapi.fill(hapi.color["blue"]) color_text = "r:{} g:{} b:{}".format(r_slider.value(), g_slider.value(), b_slider.value()) hapi.text(color_text, 20, 20) r_slider.update() g_slider.update() b_slider.update() hapi.flip_display() hapi.event_loop() pygame.quit()
from hooman import Hooman import numpy from math import pow from math import sqrt import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: hapi.is_running = False hapi.handle_events = handle_events def fake_slider(pos, x, y, width): size = 10 hapi.fill(hapi.color["grey"]) hapi.rect(x, y, width, size) hapi.fill((200, 200, 200)) hapi.rect(pos, y, size, size)
from hooman import Hooman import numpy from math import pow from math import sqrt import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) r_slider = hapi.slider(50, 330, 400, 10, {"value_range": [0, 100]}) offsetx = 200 offsety = 200 while hapi.is_running: bg_col = (255, 255, 255) hapi.background(bg_col) hapi.fill(hapi.color["red"]) hapi.stroke(hapi.color["black"]) hapi.text("r value: {}".format(r_slider.value()), 50, 330 - 15) for i in range(13): x = ( offsetx + hapi.cos(hapi.constrain(i, 0, 12, 0, hapi.PI * 2) - hapi.PI * 0.5) * r_slider.value()) y = ( offsety + hapi.sin(hapi.constrain(i, 0, 12, 0, hapi.PI * 2) - hapi.PI * 0.5)
from hooman import Hooman import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) import hooman while hapi.is_running: hapi.background(bg_col) hapi.fill(hapi.color["red"]) d = int( hapi.dist((hapi.mouseX(), hapi.mouseY()), (hapi.center_x, hapi.center_y))) hapi.fill_arc(hapi.center_x, hapi.center_y, d, 90, 0) hapi.event_loop() hapi.flip_display() pygame.quit()
from hooman import Hooman import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) text_box_options = {"background_color": hapi.color["light_grey"], "lines": 3} text_box = hapi.text_box(100, 100, 300, 40, text_box_options) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False if event.type == pygame.KEYDOWN: text_box.key_down(event) if event.key == pygame.K_ESCAPE: hapi.is_running = False hapi.handle_events = handle_events while hapi.is_running: hapi.background(bg_col) text_box.update() hapi.flip_display()
from hooman import Hooman from math import pow from math import sqrt window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: hapi.is_running = False hapi.handle_events = handle_events while hapi.is_running: hapi.background(bg_col) hapi.stroke(hapi.color["red"]) hapi.stroke_size(2) mouse_coord = (hapi.mouseX(), hapi.mouseY()) hapi.cross_hair(mouse_coord) hapi.flip_display() hapi.event_loop()
from hooman import Hooman import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) slider_options = { "background_color": hapi.color["grey"], "slider_color": (200, 200, 200), } real_slider = hapi.slider(50, 300, 400, 30, slider_options) slider_2 = hapi.slider(50, 250, 100, 30, slider_options) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: hapi.is_running = False hapi.handle_events = handle_events while hapi.is_running:
""" Author: https://github.com/TheBigKahuna353 Edit: https://github.com/Abdur-rahmaanJ """ from hooman import Hooman import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) # the function that gets called when the button is clicked on def button_clicked(this): if this.y == 250: this.y = 300 else: this.y = 250 grey_style = { "background_color": (200, 200, 200), "hover_background_color": (220, 220, 220), "curve": 0.1, "padding_x": 5, "padding_y": 5, "font_size": 15, }
from hooman import Hooman import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) start_options = { "background_color": hapi.color["grey"], "slider_color": (200, 200, 200), "value_range": [0, 360], "starting_value": 0, } end_options = { "background_color": hapi.color["grey"], "slider_color": (200, 200, 200), "value_range": [0, 360], "starting_value": 90, } start_angle = hapi.slider(50, 400, 400, 20, start_options) end_angle = hapi.slider(50, 430, 400, 20, end_options) while hapi.is_running: hapi.background(bg_col) hapi.fill(hapi.color["red"]) hapi.fill_arc(hapi.center_x, hapi.center_y,
from hooman import Hooman import pygame window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (100, 100, 255) while hapi.is_running: hapi.background(bg_col) hapi.gradient_rect(10, 10, 210, 100, hapi.color["black"], hapi.color["white"]) hapi.gradient_rect(230, 10, 210, 100, hapi.color["green"], hapi.color["blue"]) hapi.gradient_rect(10, 120, 100, 200, hapi.color["black"], hapi.color["yellow"], 1) hapi.gradient_rect(120, 120, 100, 200, hapi.color["red"], hapi.color["white"], 1) hapi.gradient_rect(340, 120, 100, 200, hapi.color["red"], hapi.color["blue"]) hapi.gradient_rect(230, 120, 100, 200, hapi.color["yellow"], hapi.color["green"]) hapi.flip_display() hapi.event_loop() pygame.quit()
import pygame from hooman import Hooman pygame.init() hapi = Hooman(800, 600) while hapi.is_running: hapi.background(hapi.color["white"]) hapi.set_alpha(100) hapi.fill(hapi.color["red"]) hapi.alpha_ellipse(100, 100, hapi.mouseX() // 2, hapi.mouseX() // 2) hapi.fill(hapi.color["yellow"]) hapi.alpha_ellipse(100, 100, 100, 100) hapi.fill(hapi.color["green"]) hapi.alpha_ellipse(150, 100, 100, 100) pygame.display.flip() hapi.event_loop() pygame.quit()
from hooman import Hooman from collections import OrderedDict import pygame import random window_width, window_height = 500, 500 hapi = Hooman(window_width, window_height) bg_col = (255, 255, 255) scroll = hapi.scroll({'range_y': 400}) slider = hapi.slider(100, 850, 300, 30, {'curve': 80}) while hapi.is_running: hapi.background(bg_col) hapi.fill(hapi.color['red']) dy = scroll[1] hapi.rect(100, 600 + dy, 100, 100) hapi.rect(200, 400 + dy, 100, 200) scroll.update() slider.update() slider.Move(y=850 + dy) hapi.event_loop() hapi.flip_display() pygame.quit()
""" Author: Abdur-Rahmaan Janhangeer Github: https://github.com/Abdur-rahmaanJ """ from hooman import Hooman import pygame hapi = Hooman(500, 500) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False hapi.handle_events = handle_events while hapi.is_running: hapi.background((255, 255, 255)) hapi.stroke_size(5) hapi.stroke((0, 255, 0)) for i in range(0, hapi.WIDTH, 20): hapi.line(i, 0, hapi.mouseX(), hapi.mouseY()) hapi.flip_display() hapi.event_loop()
""" Author: Abdur-Rahmaan Janhangeer Github: https://github.com/Abdur-rahmaanJ """ from hooman import Hooman import pygame hapi = Hooman(500, 500) def handle_events(event): if event.type == pygame.QUIT: hapi.is_running = False hapi.handle_events = handle_events while hapi.is_running: hapi.background((255, 255, 255)) hapi.no_stroke() mx = (hapi.mouseX() / hapi.WIDTH) * 255 hapi.fill((0, mx, 0)) for i in range(50, 200, 60): hapi.rect(i, 50, 30, 30) hapi.fill((255, 0, 0)) hapi.ellipse(hapi.mouseX(), hapi.mouseY(), 10, 10)