Skip to content

Commit

Permalink
bump: 0.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdur-rahmaanJ committed Oct 14, 2022
1 parent 1a28c52 commit d3ccf94
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 55 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
### 0.9.3

- Feat: candy_colors

### 0.9.2

- Concentric circle demo
Expand Down
2 changes: 1 addition & 1 deletion hooman/__init__.py
@@ -1,7 +1,7 @@
from .hooman import Hooman
from .formula import *

__version__ = "0.9.2"
__version__ = "0.9.3"



17 changes: 17 additions & 0 deletions hooman/colors.py
@@ -0,0 +1,17 @@
import itertools


candy_red = (255, 110, 135)
candy_orange = (255, 185, 105)
candy_blue = (0, 240, 225)
candy_purple = (125, 25, 250)


candy_colors = {
'candy_orange':candy_orange,
'candy_blue': candy_blue,
'candy_purple': candy_purple,
'candy_red': candy_red
}

candy_colors_list = itertools.cycle([v for k, v in candy_colors.items()])
108 changes: 54 additions & 54 deletions hooman/demos/dataviz_widget.py
@@ -1,111 +1,111 @@
"""
Author: Kherin Bundhoo
Github: https://github.com/kherin
Author: Abdur-Rahmaan Janhangeer
Github: https://github.com/Abdur-RahmaanJ
hooman: 0.9.3
"""

from hooman import Hooman
import itertools
import pygame

hapi = Hooman(500, 500)
size = 50

import random
import math

candy_red = (255, 110, 135)
candy_orange = (255, 185, 105)
candy_blue = (0, 240, 225)
candy_purple = (125, 25, 250)
candy_gray = (240, 240, 255)

candy_colors = itertools.cycle([candy_red, candy_orange,
candy_blue, candy_purple])



class ConcentricCircleGraph:
def __init__(self, x, y, size, data: list, val_range: list):
self.x = x
self.y = y
self.size = size
def __init__(self, hapi, x, y, size, data: dict, val_range: list):
self.x = x
self.y = y
self.size = size
self.data = data
self.val_range = val_range
self.cols = []

# --- have fixed colors for circles ---
for i in self.data:
col = next(candy_colors)
col = next(hapi.candy_colors_list)
self.cols.append(col)

def draw(self):
hapi.stroke_size(10)
arc_wid_s = self.size
arc_wid_x = self.x
arc_wid_y = self.y

i = -1
for key in self.data:
for key in self.data: # {'x':1}
i += 1
d = self.data[key]

hapi.stroke_size(5)

end_rad = (d/self.val_range) * (hapi.PI * 2)
end_rad = (d / self.val_range) * (hapi.PI * 2)

a_size = arc_wid_s - (i*30)
pad = (arc_wid_s-a_size)//2
a_size = arc_wid_s - (i * 30)
pad = (arc_wid_s - a_size) // 2

hapi.stroke(candy_gray)
hapi.arc(arc_wid_x+pad, arc_wid_y+pad, a_size, a_size, 0+(1.5*hapi.PI), hapi.PI *2+(1.5*hapi.PI))
# --- background arc ---
hapi.stroke(hapi.colors['candy_gray'])
hapi.arc(
arc_wid_x + pad,
arc_wid_y + pad,
a_size,
a_size,
0 + (1.5 * hapi.PI),
hapi.PI * 2 + (1.5 * hapi.PI),
)


# --- colored arc ---
hapi.stroke(self.cols[i])
hapi.arc(arc_wid_x+pad, arc_wid_y+pad, a_size, a_size, 0+(1.5*hapi.PI), end_rad+(1.5*hapi.PI))



data = {'x':10, 'y':20, 'z': 30, 'a': 40, 'b':50, 'c':60, 'd':70, 'e':80}
cs = ConcentricCircleGraph(80, 10, 300, data, 100)
hapi.arc(
arc_wid_x + pad,
arc_wid_y + pad,
a_size,
a_size,
0 + (1.5 * hapi.PI),
end_rad + (1.5 * hapi.PI),
)


data = {"x": 10, "y": 20, "z": 30, "a": 40, "b": 50, "c": 60, "d": 70, "e": 80}
cs = ConcentricCircleGraph(hapi, 80, 10, 300, data, 100)
sliders = []

# --- initialise sliders corresponding to graph values ---
for i, d in enumerate(cs.data):
s = hapi.slider(10, 300+(i*25), 100, 5,
{'curve':1,
'background_color': cs.cols[i],
'range': [0, cs.val_range]
})
s = hapi.slider(
10,
300 + (i * 25),
100,
5,
{"curve": 1, "background_color": cs.cols[i], "range": [0, cs.val_range]},
)
s.set_value(cs.data[d])
sliders.append([s, d])


def sketch_pad():
# add your code below
global cs, sliders
hapi.background((255, 255, 255))

hapi.fill(hapi.color['black'])
hapi.fill(hapi.color["black"])
hapi.font_size(40)



cs.draw()

for i, s in enumerate(sliders):
slider = s[0]
data_key = s[1]

s[0].update()
cs.data[s[1]] = s[0].value()
slider.update()
cs.data[data_key] = slider.value() # modify value

t = s[1] + ' ' + str(s[0].value()) + '/'+str(round(cs.val_range, 2))
text = f"{data_key} {slider.value()}/ {round(cs.val_range, 2)}"
hapi.font_size(15)

hapi.text(t, s[0].x+s[0].w, s[0].y+10)


hapi.text(text, slider.x + slider.w, slider.y + 10)

hapi.flip_display()
hapi.event_loop()


# entry point
if __name__ == "__main__":
while hapi.is_running:
sketch_pad()
Expand Down
6 changes: 6 additions & 0 deletions hooman/hooman.py
Expand Up @@ -52,6 +52,9 @@
from .check import check_value
from .check import verify_func_param

from .colors import candy_colors
from .colors import candy_colors_list


class Hooman:
def __init__(self, WIDTH=None, HEIGHT=None, svg=False, integrate=False, screen=None):
Expand Down Expand Up @@ -90,10 +93,13 @@ def __init__(self, WIDTH=None, HEIGHT=None, svg=False, integrate=False, screen=N
"yellow": (255, 255, 0),
"grey": (100, 100, 100),
"light_grey": (200, 200, 200),
"candy_gray": (240, 240, 255),
}
self.colours = self.colors
self.color = self.colors
self.colour = self.colors
self.candy_colors = candy_colors
self.candy_colors_list = candy_colors_list

self.set_caption = pygame.display.set_caption

Expand Down

0 comments on commit d3ccf94

Please sign in to comment.