Compare commits

...
5 Commits
Author SHA1 Message Date
Hannes ede364bdbe updates 2026-07-21 20:25:17 +02:00
chigoma333 c050194be4 a 2026-07-21 16:27:29 +02:00
Hannes 4503f99135 updates 2026-07-20 20:51:09 +02:00
Hannes fe9072221b rainbow 2026-06-25 23:25:49 +02:00
Hannes b78b24d679 added stuff 2026-06-25 01:55:44 +02:00
11 changed files with 1567 additions and 135 deletions
+2
View File
@@ -1,6 +1,8 @@
output/ output/
*.gif *.gif
*.mp4 *.mp4
*.png
*.jpg
# ---> Python # ---> Python
+66
View File
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="169.33333mm"
height="127mm"
viewBox="0 0 169.33333 127"
version="1.1"
id="svg1"
sodipodi:docname="480p.svg"
inkscape:version="1.4.4 (dcaf3e7d9e, 2026-05-05)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showguides="false"
inkscape:zoom="2.7665553"
inkscape:cx="225.73198"
inkscape:cy="268.56503"
inkscape:window-width="3433"
inkscape:window-height="2076"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:page
x="0"
y="0"
width="169.33333"
height="127"
id="page2"
margin="0"
bleed="0" />
</sodipodi:namedview>
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:#808080;stroke-width:0.264583"
id="rect1"
width="63.5"
height="127"
x="17.991667"
y="0" />
<rect
style="fill:#808080;stroke-width:0.264583"
id="rect1-3"
width="63.5"
height="127"
x="87.841667"
y="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

+171
View File
@@ -0,0 +1,171 @@
import math
I = 1
O = 2
T = 3
S = 4
Z = 5
J = 6
L = 7
board = [
[I,I,I,I,L,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[S,S,L,L,L,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[T,S,S,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[T,T,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[T,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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0,0,0],
# [0,0,0,0,0,0,0,0,0,0],
# [0,0,0,0,0,0,0,0,0,0],
# [0,0,0,0,0,0,0,0,0,0],
# [0,0,0,0,0,0,0,0,0,0],
# [0,0,I,0,0,0,0,0,0,0],
# [O,O,I,T,0,0,0,J,J,0],
# [O,O,I,T,T,L,L,J,L,0],
# [O,O,I,T,I,I,L,J,L,0],
# [S,S,S,S,0,S,S,S,S,S]
# ]
board_width = len(board[0])
board_height = len(board)
class color:
def __init__(self, color=None, red=None, green=None, blue=None, alpha=255) -> None:
# Allow hex string input like "#ff8800" or "ff8800"
if isinstance(color, str):
hexcode = color.lstrip("#")
if len(hexcode) not in (6, 8):
raise ValueError("Hex color must be 6 or 8 characters long")
self.r = int(hexcode[0:2], 16)
self.g = int(hexcode[2:4], 16)
self.b = int(hexcode[4:6], 16)
if len(hexcode) == 8:
self.a = int(hexcode[6:8], 16)
else:
self.a = alpha
else:
# Regular RGB(A) input
self.r = red
self.g = green
self.b = blue
self.a = alpha
def get(self) -> tuple[int, int, int]:
return (self.r, self.g, self.b)
def sub(self, n) -> tuple[int, int, int]:
if self.r:
r=self.r-n
else:
r=0
if self.g:
g=self.g-n
else:
g=0
if self.b:
b=self.b-n
else:
b=0
return (r,g,b)
def multiply(self, other) -> tuple[int, int, int]:
r = other[0]
g = other[1]
b = other[2]
return (((self.r * r) >> 8), ((self.g * g) >> 8), ((self.b * b)>>8))
def shiftr(self, n):
return ((self.r >> n), (self.g >> n), (self.b >>n))
def mask(self, n):
return ((self.r & n), (self.g & n), (self.b & n))
black = color("#000000")
white = color("#ffffff")
colors = [
color("#000000"),
color("#00ffff"),
color("#fff200"),
color("#9d00ff"),
color("#00ff00"),
color("#ff0000"),
color("#0000ff"),
color("#ff8000")
]
width = board_width*32
height = board_height*32
from PIL import Image
img = Image.new("RGB", (width, height))
pixels = img.load()
for y in range(height):
for x in range(width):
xd = x
yd = y
color_internal = colors[board[yd>>5][xd>>5]]
if board[yd>>5][xd>>5] != 0:
xs = xd&0x1F
ys = yd&0x1F
if (xs > 7 and xs < 24) and (ys > 7 and ys < 24): # middle
pixels[x, y] = color_internal.get()
elif (xs > 5 and xs < 26) and (ys > 5 and ys < 26): # mid boarder
pixels[x, y] = color_internal.mask(0xFFFFFFB0)
elif xs+ys<31: # top left edge
if xs>ys:
pixels[x, y] = color_internal.get()
else:
pixels[x, y] = color_internal.mask(0xFFFFFFEF)
else:
if xs>ys:
pixels[x, y] = color_internal.mask(0xFFFFFFD7)
else:
pixels[x, y] = color_internal.mask(0xFFFFFFC0)
else:
# pixels[x, y] = (0, 0, 0)
if (x+y)&1:
pixels[x, y] = (0, 0, 255)
else:
pixels[x, y] = (int((x + y) * 255 / ((width - 1) + (height - 1))), int((1 - (x + y) / (width + height - 2)) * 255), 0)
img.save("output/folie_16_background.png")
img.show()
+165
View File
@@ -0,0 +1,165 @@
import math
I = 1
O = 2
T = 3
S = 4
Z = 5
J = 6
L = 7
class color:
def __init__(self, color=None, red=None, green=None, blue=None, alpha=255) -> None:
# Allow hex string input like "#ff8800" or "ff8800"
if isinstance(color, str):
hexcode = color.lstrip("#")
if len(hexcode) not in (6, 8):
raise ValueError("Hex color must be 6 or 8 characters long")
self.r = int(hexcode[0:2], 16)
self.g = int(hexcode[2:4], 16)
self.b = int(hexcode[4:6], 16)
if len(hexcode) == 8:
self.a = int(hexcode[6:8], 16)
else:
self.a = alpha
else:
# Regular RGB(A) input
self.r = red
self.g = green
self.b = blue
self.a = alpha
def get(self) -> tuple[int, int, int]:
return (self.r, self.g, self.b)
def sub(self, n) -> tuple[int, int, int]:
if self.r:
r=self.r-n
else:
r=0
if self.g:
g=self.g-n
else:
g=0
if self.b:
b=self.b-n
else:
b=0
return (r,g,b)
def multiply(self, other) -> tuple[int, int, int]:
r = other[0]
g = other[1]
b = other[2]
return (((self.r * r) >> 8), ((self.g * g) >> 8), ((self.b * b)>>8))
def shiftr(self, n):
return ((self.r >> n), (self.g >> n), (self.b >>n))
def mask(self, n):
return ((self.r & n), (self.g & n), (self.b & n))
black = color("#000000")
white = color("#ffffff")
colors = [
color("#000000"),
color("#00ffff"),
color("#fff200"),
color("#9d00ff"),
color("#00ff00"),
color("#ff0000"),
color("#0000ff"),
color("#ff8000")
]
base_board = [
[I,I,I,I,L,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[S,S,L,L,L,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[T,S,S,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[T,T,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[T,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,J,0,T,0,0,Z,Z,0,J,0,0,L,0,0,0,0,0,O,O,0,0,0,0,S,0,0,0,L,0,0,S,0,O,O,0,J,J,T,0,0,0,0,J],
[J,0,T,T,T,J,T,T,T,Z,Z,Z,Z,J,O,O,L,0,O,O,0,0,O,O,0,Z,Z,T,S,S,O,O,L,Z,Z,S,S,O,O,L,J,T,T,T,0,0,0,J],
[J,J,J,T,J,J,I,I,I,I,Z,Z,J,J,O,O,L,L,O,O,I,I,I,I,Z,Z,T,T,T,S,O,O,L,L,Z,Z,S,L,L,L,J,I,I,I,I,0,J,J]
]
next_piece = [
[T,T,T],
[0,T,0]
]
coord = 44
board_width = len(base_board[0])
board_height = len(base_board)
width = board_width*32
height = board_height*32
from PIL import Image
img2 = Image.open("output.jpg")
pixels2 = img2.load()
for t in range(len(base_board)-1):
img = Image.new("RGB", (width, height))
pixels = img.load()
board = [row[:] for row in base_board]
for i in range(len(next_piece)):
i_int = i + t
for j in range(len(next_piece[i])):
j_int = j + coord
if board[i_int][j_int] == 0:
board[i_int][j_int] = next_piece[i][j]
for y in range(height):
for x in range(width):
xd = x
yd = y
color_internal = colors[board[yd>>5][xd>>5]]
if board[yd>>5][xd>>5] != 0:
xs = xd&0x1F
ys = yd&0x1F
if (xs > 7 and xs < 24) and (ys > 7 and ys < 24): # middle
pixels[x, y] = color_internal.get()
elif (xs > 5 and xs < 26) and (ys > 5 and ys < 26): # mid boarder
pixels[x, y] = color_internal.mask(0xFFFFFFB0)
elif xs+ys<31: # top left edge
if xs>ys:
pixels[x, y] = color_internal.get()
else:
pixels[x, y] = color_internal.mask(0xFFFFFFEF)
else:
if xs>ys:
pixels[x, y] = color_internal.mask(0xFFFFFFD7)
else:
pixels[x, y] = color_internal.mask(0xFFFFFFC0)
else:
# if (x+y)&1:
# pixels[x, y] = (0, 0, 255)
# else:
pixels[x, y] = pixels2[math.floor(x/1.5), math.floor(y/1.5)]#((x+y)>>2, (((1280+720)>>2)-((x+y)>>2)), 255)
#
img.save(f"output/folie_{t}_background.png")
if t == 1:
img.show()
+522 -129
View File
@@ -9,79 +9,175 @@ n0 = [
[1,1,1] [1,1,1]
] ]
n1 = [ n_x = [
[0,0,0],
[0,0,0],
[1,0,1],
[0,1,0], [0,1,0],
[1,1,0], [1,0,1]
[0,1,0],
[0,1,0],
[1,1,1]
] ]
n2 = [ hexnumbers = [
[1,1,1], [ # 0
[0,0,1], [1,1,1],
[1,1,1], [1,0,1],
[1,0,0], [1,0,1],
[1,1,1] [1,0,1],
] [1,1,1]
],
n3 = [ [ # 1
[1,1,1], [0,1,0],
[0,0,1], [1,1,0],
[1,1,1], [0,1,0],
[0,0,1], [0,1,0],
[1,1,1] [1,1,1]
] ],
n4 = [ [ # 2
[1,0,1], [1,1,1],
[1,0,1], [0,0,1],
[1,1,1], [1,1,1],
[0,0,1], [1,0,0],
[0,0,1] [1,1,1]
] ],
n5 = [ [ # 3
[1,1,1], [1,1,1],
[1,0,0], [0,0,1],
[1,1,1], [1,1,1],
[0,0,1], [0,0,1],
[1,1,1] [1,1,1]
] ],
n6 = [ [ # 4
[1,1,1], [1,0,1],
[1,0,0], [1,0,1],
[1,1,1], [1,1,1],
[1,0,1], [0,0,1],
[1,1,1] [0,0,1]
] ],
n7 = [ [ # 5
[1,1,1], [1,1,1],
[0,0,1], [1,0,0],
[0,0,1], [1,1,1],
[0,0,1], [0,0,1],
[0,0,1] [1,1,1]
] ],
n8 = [ [ # 6
[1,1,1], [1,1,1],
[1,0,1], [1,0,0],
[1,1,1], [1,1,1],
[1,0,1], [1,0,1],
[1,1,1] [1,1,1]
] ],
n9 = [ [ # 7
[1,1,1], [1,1,1],
[1,0,1], [0,0,1],
[1,1,1], [0,0,1],
[0,0,1], [0,0,1],
[1,1,1] [0,0,1]
],
[ # 8
[1,1,1],
[1,0,1],
[1,1,1],
[1,0,1],
[1,1,1]
],
[ # 9
[1,1,1],
[1,0,1],
[1,1,1],
[0,0,1],
[1,1,1]
],
[ # A (10)
[1,1,1],
[1,0,1],
[1,1,1],
[1,0,1],
[1,0,1]
],
[ # B (11)
[1,1,0],
[1,0,1],
[1,1,0],
[1,0,1],
[1,1,0]
],
[ # C (12)
[1,1,1],
[1,0,0],
[1,0,0],
[1,0,0],
[1,1,1]
],
[ # D (13)
[1,1,0],
[1,0,1],
[1,0,1],
[1,0,1],
[1,1,0]
],
[ # E (14)
[1,1,1],
[1,0,0],
[1,1,1],
[1,0,0],
[1,1,1]
],
[ # F (15)
[1,1,1],
[1,0,0],
[1,1,1],
[1,0,0],
[1,0,0]
]
] ]
### FONT: https://github.com/teryror/pixel-fonts/tree/master ### FONT: https://github.com/teryror/pixel-fonts/tree/master
a_p = [
[1,1,1,1,1,0],
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[1,1,1,1,1,0],
[1,1,0,0,0,0],
[1,1,0,0,0,0],
[1,1,0,0,0,0]
]
a_1 = [
[0,0,0,1,1,0],
[0,0,1,1,1,0],
[0,1,1,1,1,0],
[1,1,0,1,1,0],
[0,0,0,1,1,0],
[0,0,0,1,1,0],
[0,0,0,1,1,0],
[0,0,0,1,1,0]
]
a_2 = [
[0,1,1,1,1,0],
[1,1,0,0,1,1],
[0,0,0,0,1,1],
[0,0,0,1,1,0],
[0,0,1,1,0,0],
[0,1,1,0,0,0],
[1,1,0,0,0,0],
[1,1,1,1,1,1]
]
a_s = [ a_s = [
[0,1,1,1,1,0], [0,1,1,1,1,0],
@@ -94,6 +190,28 @@ a_s = [
[0,1,1,1,1,0] [0,1,1,1,1,0]
] ]
a_h = [
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[1,1,1,1,1,1],
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[1,1,0,0,1,1]
]
a_w = [
[1,1,0,0,1,0,0,1,1],
[1,1,0,0,1,0,0,1,1],
[1,1,0,1,1,1,0,1,1],
[1,1,1,1,1,1,1,1,1],
[0,1,1,1,0,1,1,1,0],
[0,1,1,1,0,1,1,1,0],
[0,1,1,0,0,0,1,1,0],
[0,0,1,0,0,0,1,0,0]
]
a_c = [ a_c = [
[0,1,1,1,1,0], [0,1,1,1,1,0],
[1,1,1,0,1,1], [1,1,1,0,1,1],
@@ -198,10 +316,10 @@ class coord:
def make_next_board(): def make_next_board():
next_board = [ next_board = [
[0, 0, 0, 0],
[1, 1, 1, 1],
[0, 0, 0, 0], [0, 0, 0, 0],
[0, 0, 0, 0], [0, 0, 0, 0],
[0, 1, 0, 0],
[1, 1, 1, 0],
] ]
return next_board return next_board
@@ -229,6 +347,7 @@ def make_board(n: int):
board.append(line) board.append(line)
return board_height, board_width, board return board_height, board_width, board
def make_sprite(): def make_sprite():
@@ -265,43 +384,124 @@ lime = color("#5fdf5f")
colors = [ colors = [
black, black,
cyan, cyan,
blue,
orange,
yellow, yellow,
green,
purple, purple,
red green,
red,
blue,
orange
] ]
colors2 = [ I=1
black, O=2
color("#0086f3"), T=3
color("#3d4fdc"), S=4
color("#fdab01"), Z=5
color("#abcb04"), J=6
color("#02bdcd"), L=7
color("#d20f63"),
color("#fe4b0f"), colors2 = colors
] # colors2 = [
# black,
# color("#0086f3"),
# color("#3d4fdc"),
# color("#fdab01"),
# color("#abcb04"),
# color("#02bdcd"),
# color("#d20f63"),Z
# color("#fe4b0f"),
# ]
text_bg = black text_bg = black
next_board = make_next_board() # next_board = make_next_board()
nb1 = coord(88, 96, 128, 128) next_board = [
nb2 = coord(1064, 96, 128, 128) [0, 0, T, 0],
[0, T, T, T],
[0, 0, 0, 0],
[0, 0, 0, 0],
]
nb1 = coord(88, 104, 128, 128)
# next_board1 = make_next_board()
next_board1 = [
[0, 0, 0, L],
[0, L, L, L],
[0, 0, 0, 0],
[0, 0, 0, 0],
]
nb2 = coord(1064, 104, 128, 128)
board_height, board_width, board = make_board(len(colors)) board_height, board_width, _ = make_board(len(colors))
board = [
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,J,J,0],
[0,0,0,0,0,0,0,J,0,0],
[0,0,0,0,0,0,0,J,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,I,0,0,0,0,0,0,0],
[O,O,I,I,I,0,0,0,0,0],
[O,O,I,I,I,L,L,0,L,0],
[O,O,I,I,I,I,L,0,L,0]
]
b1 = coord(304, 40, 320, 640) b1 = coord(304, 40, 320, 640)
board2_height, board2_width, board2 = make_board(len(colors2)) board2_height, board2_width, _ = make_board(len(colors2))
board2 = [
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,Z,0,0,0,0,0,0],
[0,0,Z,Z,0,0,0,0,0,0],
[0,0,Z,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[O,O,0,0,0,O,O,J,J,J],
[O,O,0,O,O,O,O,Z,Z,J],
[J,0,S,S,Z,Z,I,I,I,I],
[S,Z,Z,T,I,J,J,Z,Z,0],
[S,S,Z,Z,I,J,0,0,Z,Z]
]
b2 = coord(656, 40, 320, 640) b2 = coord(656, 40, 320, 640)
score1 = make_score() # score0 = make_score()
s1 = coord(84, 454, 136, 32) score0 = 299
sn1 = coord(74, 490, 156, 20) score1 = 298
score2 = make_score() s1 = coord(84, 332, 136, 32)
s2 = coord(1060, 454, 136, 32) sn1 = coord(74, 368, 156, 20)
sn2 = coord(1050, 490, 156, 20) # score1 = make_score()
s2 = coord(1060, 332, 136, 32)
sn2 = coord(1050, 368, 156, 20)
mm0 = coord(576, 155, 128, 128)
mm1 = coord(576, 437, 128, 128)
lm0 = coord(120, 476, 58, 32)
lm1 = coord(120, 516, 58, 32)
lm2 = coord(120, 556, 64, 32)
lm3 = coord(120, 596, 64, 32)
rm0 = coord(1096, 476, 58, 32)
rm1 = coord(1096, 516, 58, 32)
rm2 = coord(1096, 556, 64, 32)
rm3 = coord(1096, 596, 64, 32)
width = 1280 width = 1280
height = 720 height = 720
@@ -310,22 +510,99 @@ img = Image.new("RGB", (width, height))
pixels = img.load() pixels = img.load()
menu = 0
menu_active0 = [1,0,0,0]
menu_active1 = [0,1,0,0]
menu_active2 = [1,0]
def menu_get (side, i) -> tuple[int, int, int] | color | None:
if side == "left":
if menu_active0[i] == 0:
return white.get()
else:
return red.get()
elif side == "right":
if menu_active1[i] == 0:
return white.get()
else:
return red.get()
elif side == "middle":
if menu_active2[i] == 0:
return white
else:
return yellow
for y in range(height): for y in range(height):
for x in range(width): for x in range(width):
####################### player 1 ### BG
if (x+y)&1:
pixels[x, y] = (0, 0, 255)
else:
pixels[x, y] = ((x+y)>>3, (((1280+720)>>3)-((x+y)>>3)), 0)
####################### MENU
if menu and x >= mm0.x and x < (mm0.x + mm0.width) and y >= mm0.y and y < (mm0.y + mm0.height):
xd = x-mm0.x
yd = y-mm0.y
xs = xd >> 3
ys = yd >> 3
if x > mm0.x+3 and y>mm0.y+3 and xd<mm0.width-4 and yd<mm0.height-4:
if xs <ys*2 and xs<((mm0.width-8 >> 3)-ys)<<1 and xs >2:
pixels[x, y] = menu_get ("middle", 0).get()
elif (xs == ys*2 or xs==((mm0.width-8 >> 3)-ys)<<1) and xs >2 and xs <14:
pixels[x, y] = menu_get("middle", 0).shiftr(3)
else:
pixels[x, y] = black.get()
else:
pixels[x, y] = (128,128,128)
elif menu and x >= mm1.x and x < (mm1.x + mm1.width) and y >= mm1.y and y < (mm1.y + mm1.height):
xd = x-mm1.x-4
yd = y-mm1.y-4
xs = xd >> 3
ys = yd >> 3
if x > mm1.x+3 and y>mm1.y+3 and xd<mm1.width-8 and yd<mm1.height-8:
# vert/horizontal
if xs == 2 and ys < 10 and ys > 4: # left
pixels[x, y] = menu_get("middle", 1).get()
elif xs == 11 and ys < 8 and ys > 4: # right
pixels[x, y] = menu_get("middle", 1).get()
elif ys == 2 and xs < 10 and xs > 4: # top
pixels[x, y] = menu_get("middle", 1).get()
elif ys == 12 and xs < 10 and xs > 4: # bot
pixels[x, y] = menu_get("middle", 1).get()
# Orthogonal
elif xs+ys == 7 and xs >1 and ys >1: # top left
pixels[x, y] = menu_get("middle", 1).get()
elif xs+ys == 21 and xs >8 and ys >9: # bot right
pixels[x, y] = menu_get("middle", 1).get()
elif ys-xs == 7 and xs < 6 and ys > 8: # bot left
pixels[x, y] = menu_get("middle", 1).get()
elif xs-ys == 7 and xs > 8 and ys < 5: # top right
pixels[x, y] = menu_get("middle", 1).get()
# Arrow Head
elif xs-ys == 4 and xs > 8 and xs < 12: # left
pixels[x, y] = menu_get("middle", 1).get()
elif xs+ys == 18 and xs > 10 and xs <14: # right
pixels[x, y] = menu_get("middle", 1).get()
# Aliasing
elif (xs==ys==11) or (xs==ys==3) or (xs==11 and ys==3) or (xs==3 and ys==11):
pixels[x, y] = menu_get("middle", 1).shiftr(3)
else:
pixels[x, y] = black.get()
else:
pixels[x, y] = (128,128,128)
####################### Left Side
### Board ### Board
if x>=b1.x and x<b1.x+b1.width and y>=b1.y and y<b1.y+b1.height: elif x>=b1.x and x<b1.x+b1.width and y>=b1.y and y<b1.y+b1.height:
xd = x-b1.x xd = x-b1.x
yd = y-b1.y yd = y-b1.y
# pixels[x, y] = colors[board[yd>>5][xd>>5]].multiply(sprite_pixels[yd&0b0000000000011111, xd&0b0000000000011111])
xs = xd&0x1F xs = xd&0x1F
ys = yd&0x1F ys = yd&0x1F
if (xs > 7 and xs < 24) and (ys > 7 and ys < 24): # middle if (xs > 7 and xs < 24) and (ys > 7 and ys < 24): # middle
pixels[x, y] = colors[board[yd>>5][xd>>5]].get() pixels[x, y] = colors[board[yd>>5][xd>>5]].get()
elif (xs > 5 and xs < 26) and (ys > 5 and ys < 26): # mid boarder elif (xs > 5 and xs < 26) and (ys > 5 and ys < 26): # mid boarder
pixels[x, y] = colors[board[yd>>5][xd>>5]].mask(0xFFFFFFB0) pixels[x, y] = colors[board[yd>>5][xd>>5]].mask(0xFFFFFFB0)
# elif xs == ys or xs+ys==31:
# pixels[x, y] = colors[board[yd>>5][xd>>5]].shiftr(2)
elif xs+ys<31: # top left edge elif xs+ys<31: # top left edge
if xs>ys: if xs>ys:
pixels[x, y] = colors[board[yd>>5][xd>>5]].get() pixels[x, y] = colors[board[yd>>5][xd>>5]].get()
@@ -342,16 +619,21 @@ for y in range(height):
yd = y-nb1.y yd = y-nb1.y
xs = xd&0x1F xs = xd&0x1F
ys = yd&0x1F ys = yd&0x1F
if (xs == 31) or (ys==31): if (xs > 7 and xs < 24) and (ys > 7 and ys < 24): # middle
if (xs == 0) or (ys == 0):
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].shiftr(1)
else:
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].shiftr(2)
elif (not xs) or (not ys):
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].get() pixels[x, y] = colors[next_board[yd>>5][xd>>5]].get()
elif (xs > 5 and xs < 26) and (ys > 5 and ys < 26): # mid next_boarder
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].mask(0xFFFFFFB0)
elif xs+ys<31: # top left edge
if xs>ys:
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].get()
else:
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].mask(0xFFFFFFEF)
else: else:
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].mask(0xFFFFFFC0) if xs>ys:
### Score pixels[x, y] = colors[next_board[yd>>5][xd>>5]].mask(0xFFFFFFD7)
else:
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].mask(0xFFFFFFC0)
### Score text
elif x>=s1.x and x<s1.x+s1.width and y>=s1.y and y<s1.y+s1.height: elif x>=s1.x and x<s1.x+s1.width and y>=s1.y and y<s1.y+s1.height:
yd = y-s1.y yd = y-s1.y
if x < (24+s1.x) and a_s[yd>>2][(x-s1.x)>>2]: if x < (24+s1.x) and a_s[yd>>2][(x-s1.x)>>2]:
@@ -364,45 +646,107 @@ for y in range(height):
pixels[x, y] = white.get() pixels[x, y] = white.get()
elif x > (112+s1.x) and a_e[yd>>2][(x-(112+s1.x))>>2]: elif x > (112+s1.x) and a_e[yd>>2][(x-(112+s1.x))>>2]:
pixels[x, y] = white.get() pixels[x, y] = white.get()
else: ### Score num
pixels[x, y] = text_bg.get()
elif x>=sn1.x and x<sn1.x+sn1.width and y>=sn1.y and y<sn1.y+sn1.height: elif x>=sn1.x and x<sn1.x+sn1.width and y>=sn1.y and y<sn1.y+sn1.height:
pixels[x, y] = text_bg.get() yd = y-sn1.y
####################### player 2 if ((x >= 74 and x < 86) and n0[yd>>2][(x -74)>>2]):
pixels[x, y] = white.get()
elif ((x >= 90 and x < 102) and n_x[yd>>2][(x -90)>>2]):
pixels[x, y] = white.get()
elif ((x >= 106 and x < 118) and hexnumbers[score0>>28&0b1111][yd>>2][(x -106)>>2]):
pixels[x, y] = white.get()
elif ((x >= 122 and x < 134) and hexnumbers[score0>>24&0b1111][yd>>2][(x -122)>>2]):
pixels[x, y] = white.get()
elif ((x >= 138 and x < 150) and hexnumbers[score0>>20&0b1111][yd>>2][(x -138)>>2]):
pixels[x, y] = white.get()
elif ((x >= 154 and x < 166) and hexnumbers[score0>>16&0b1111][yd>>2][(x -154)>>2]):
pixels[x, y] = white.get()
elif ((x >= 170 and x < 182) and hexnumbers[score0>>12&0b1111][yd>>2][(x -170)>>2]):
pixels[x, y] = white.get()
elif ((x >= 186 and x < 198) and hexnumbers[score0>>8&0b1111][yd>>2][(x -186)>>2]):
pixels[x, y] = white.get()
elif ((x >= 202 and x < 214) and hexnumbers[score0>>4&0b1111][yd>>2][(x -202)>>2]):
pixels[x, y] = white.get()
elif ((x >= 218 and x < 230) and hexnumbers[score0&0b1111][yd>>2][(x -218)>>2]):
pixels[x, y] = white.get()
else:
pixels[x, y] = black.get()
# pixels[x, y] = text_bg.get()
### Menu
elif x >= lm0.x and x < (lm0.x + lm0.width) and y >= lm0.y and y < (lm0.y + lm0.height):
xd = x-lm0.x
yd = y-lm0.y
xs = xd-34
if xd < (24) and a_p[yd>>2][xd>>2]:
pixels[x, y] = menu_get("left", 0)
elif xd > (33) and a_1[yd>>2][xs>>2]:
pixels[x, y] = menu_get("left", 0)
elif x >= lm1.x and x < (lm1.x + lm1.width) and y >= lm1.y and y < (lm1.y + lm1.height):
xd = x-lm1.x
yd = y-lm1.y
xs = xd-34
if xd < (24) and a_p[yd>>2][xd>>2]:
pixels[x, y] = menu_get("left", 1)
elif xd > (33) and a_2[yd>>2][xs>>2]:
pixels[x, y] = menu_get("left", 1)
elif x >= lm2.x and x < (lm2.x + lm2.width) and y >= lm2.y and y < (lm2.y + lm2.height):
xd = x-lm2.x
yd = y-lm2.y
xs = xd-28
if xd < (24) and a_s[yd>>2][xd>>2]:
pixels[x, y] = menu_get("left", 2)
elif xd > (27) and a_w[yd>>2][xs>>2]:
pixels[x, y] = menu_get("left", 2)
elif x >= lm3.x and x < (lm3.x + lm3.width) and y >= lm3.y and y < (lm3.y + lm3.height):
xd = x-lm3.x
yd = y-lm3.y
xs = xd-28
if xd < (24) and a_h[yd>>2][xd>>2]:
pixels[x, y] = menu_get("left", 3)
elif xd > (27) and a_w[yd>>2][xs>>2]:
pixels[x, y] = menu_get("left", 3)
####################### Right Board
### Board ### Board
elif x>=b2.x and x<b2.x+b2.width and y>=b2.y and y<b2.y+b2.height: elif x>=b2.x and x<b2.x+b2.width and y>=b2.y and y<b2.y+b2.height:
# xd = x-b2.x
# yd = y-b2.y
# pixels[x, y] = colors2[board2[yd>>5][xd>>5]].multiply(sprite_pixels[yd&0b0000000000011111, xd&0b0000000000011111])
xd = x-b2.x xd = x-b2.x
yd = y-b2.y yd = y-b2.y
xs = xd&0x1F xs = xd&0x1F
ys = yd&0x1F ys = yd&0x1F
if (xs == 31) or (ys == 31): if (xs > 7 and xs < 24) and (ys > 7 and ys < 24): # middle
if (xs == 0) or (ys == 0): pixels[x, y] = colors[board2[yd>>5][xd>>5]].get()
pixels[x, y] = colors2[board2[yd>>5][xd>>5]].shiftr(1) elif (xs > 5 and xs < 26) and (ys > 5 and ys < 26): # mid boarder
pixels[x, y] = colors[board2[yd>>5][xd>>5]].mask(0xFFFFFFB0)
elif xs+ys<31: # top left edge
if xs>ys:
pixels[x, y] = colors[board2[yd>>5][xd>>5]].get()
else: else:
pixels[x, y] = colors2[board2[yd>>5][xd>>5]].shiftr(2) pixels[x, y] = colors[board2[yd>>5][xd>>5]].mask(0xFFFFFFEF)
elif (not xs) or (not ys):
pixels[x, y] = colors2[board2[yd>>5][xd>>5]].get()
else: else:
pixels[x, y] = colors2[board2[yd>>5][xd>>5]].mask(0xFFFFFFC0) if xs>ys:
pixels[x, y] = colors[board2[yd>>5][xd>>5]].mask(0xFFFFFFD7)
else:
pixels[x, y] = colors[board2[yd>>5][xd>>5]].mask(0xFFFFFFC0)
### Next Piece ### Next Piece
elif x>=nb2.x and x<nb2.x+nb2.width and y>=nb2.y and y<nb2.y+nb2.height: elif x>=nb2.x and x<nb2.x+nb2.width and y>=nb2.y and y<nb2.y+nb2.height:
xd = x-nb2.x xd = x-nb2.x
yd = y-nb2.y yd = y-nb2.y
xs = xd&0x1F xs = xd&0x1F
ys = yd&0x1F ys = yd&0x1F
if (xs == 31) or (ys==31): if (xs > 7 and xs < 24) and (ys > 7 and ys < 24): # middle
if (xs == 0) or (ys == 0): pixels[x, y] = colors[next_board1[yd>>5][xd>>5]].get()
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].shiftr(1) elif (xs > 5 and xs < 26) and (ys > 5 and ys < 26): # mid next_boarder
pixels[x, y] = colors[next_board1[yd>>5][xd>>5]].mask(0xFFFFFFB0)
elif xs+ys<31: # top left edge
if xs>ys:
pixels[x, y] = colors[next_board1[yd>>5][xd>>5]].get()
else: else:
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].shiftr(2) pixels[x, y] = colors[next_board1[yd>>5][xd>>5]].mask(0xFFFFFFEF)
elif (not xs) or (not ys):
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].get()
else: else:
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].mask(0xFFFFFFC0) if xs>ys:
### Score pixels[x, y] = colors[next_board1[yd>>5][xd>>5]].mask(0xFFFFFFD7)
else:
pixels[x, y] = colors[next_board1[yd>>5][xd>>5]].mask(0xFFFFFFC0)
### Score Text
elif x>=s2.x and x<s2.x+s2.width and y>=s2.y and y<s2.y+s2.height: elif x>=s2.x and x<s2.x+s2.width and y>=s2.y and y<s2.y+s2.height:
yd = y-s2.y yd = y-s2.y
if x < (24+s2.x) and a_s[yd>>2][(x-s2.x)>>2]: if x < (24+s2.x) and a_s[yd>>2][(x-s2.x)>>2]:
@@ -415,15 +759,64 @@ for y in range(height):
pixels[x, y] = white.get() pixels[x, y] = white.get()
elif x > (112+s2.x) and a_e[yd>>2][(x-(112+s2.x))>>2]: elif x > (112+s2.x) and a_e[yd>>2][(x-(112+s2.x))>>2]:
pixels[x, y] = white.get() pixels[x, y] = white.get()
else: ### Score Num
pixels[x, y] = text_bg.get()
elif x>=sn2.x and x<sn2.x+sn2.width and y>=sn2.y and y<sn2.y+sn2.height: elif x>=sn2.x and x<sn2.x+sn2.width and y>=sn2.y and y<sn2.y+sn2.height:
pixels[x, y] = text_bg.get() yd = y-sn2.y
else: if ((x >= 1050 and x < 1062) and n0[yd>>2][(x -1050)>>2]):
if (x+y)&1: pixels[x, y] = white.get()
pixels[x, y] = (0, 0, 255) elif ((x >= 1066 and x < 1078) and n_x[yd>>2][(x -1066)>>2]):
pixels[x, y] = white.get()
elif ((x >= 1082 and x < 1094) and hexnumbers[score1>>28&0b1111][yd>>2][(x -1082)>>2]):
pixels[x, y] = white.get()
elif ((x >= 1098 and x < 1110) and hexnumbers[score1>>24&0b1111][yd>>2][(x -1098)>>2]):
pixels[x, y] = white.get()
elif ((x >= 1114 and x < 1126) and hexnumbers[score1>>20&0b1111][yd>>2][(x -1114)>>2]):
pixels[x, y] = white.get()
elif ((x >= 1130 and x < 1142) and hexnumbers[score1>>16&0b1111][yd>>2][(x -1130)>>2]):
pixels[x, y] = white.get()
elif ((x >= 1146 and x < 1158) and hexnumbers[score1>>12&0b1111][yd>>2][(x -1146)>>2]):
pixels[x, y] = white.get()
elif ((x >= 1162 and x < 1174) and hexnumbers[score1>>8&0b1111][yd>>2][(x -1162)>>2]):
pixels[x, y] = white.get()
elif ((x >= 1178 and x < 1190) and hexnumbers[score1>>4&0b1111][yd>>2][(x -1178)>>2]):
pixels[x, y] = white.get()
elif ((x >= 1194 and x < 1206) and hexnumbers[score1&0b1111][yd>>2][(x -1194)>>2]):
pixels[x, y] = white.get()
else: else:
pixels[x, y] = ((x+y)>>3, (((1280+720)>>3)-((x+y)>>3)), 0) pixels[x, y] = black.get()
### Menu
elif x >= rm0.x and x < (rm0.x + rm0.width) and y >= rm0.y and y < (rm0.y + rm0.height):
xd = x-rm0.x
yd = y-rm0.y
xs = xd-34
if xd < (24) and a_p[yd>>2][xd>>2]:
pixels[x, y] = menu_get("right", 0)
elif xd > (33) and a_1[yd>>2][xs>>2]:
pixels[x, y] = menu_get("right", 0)
elif x >= rm1.x and x < (rm1.x + rm1.width) and y >= rm1.y and y < (rm1.y + rm1.height):
xd = x-rm1.x
yd = y-rm1.y
xs = xd-34
if xd < (24) and a_p[yd>>2][xd>>2]:
pixels[x, y] = menu_get("right", 1)
elif xd > (33) and a_2[yd>>2][xs>>2]:
pixels[x, y] = menu_get("right", 1)
elif x >= rm2.x and x < (rm2.x + rm2.width) and y >= rm2.y and y < (rm2.y + rm2.height):
xd = x-rm2.x
yd = y-rm2.y
xs = xd-28
if xd < (24) and a_s[yd>>2][xd>>2]:
pixels[x, y] = menu_get("right", 2)
elif xd > (27) and a_w[yd>>2][xs>>2]:
pixels[x, y] = menu_get("right", 2)
elif x >= rm3.x and x < (rm3.x + rm3.width) and y >= rm3.y and y < (rm3.y + rm3.height):
xd = x-rm3.x
yd = y-rm3.y
xs = xd-28
if xd < (24) and a_h[yd>>2][xd>>2]:
pixels[x, y] = menu_get("right", 3)
elif xd > (27) and a_w[yd>>2][xs>>2]:
pixels[x, y] = menu_get("right", 3)
img.save("output/alpha.png") img.save("output/alpha.png")
img.show() img.show()
+104
View File
@@ -0,0 +1,104 @@
import matplotlib.pyplot as plt
import matplotlib.patheffects as path_effects
import matplotlib.ticker as ticker
# ==========================================
# 0. HELPER FUNCTION
# ==========================================
def format_val(x, pos=None):
"""Formats numbers to k/M format for axes and labels"""
if x >= 1_000_000:
return f"{x/1_000_000:.1f}".replace('.0', '') + 'M'
elif x >= 1000:
return f"{x/1000:.1f}".replace('.0', '') + 'k'
return str(int(x))
# ==========================================
# 1. EDIT YOUR DATA HERE
# ==========================================
# Define primary labels and subtext descriptions
labels_main = ['Bitboard Tetris', 'TET-CPU']
subtexts = ['AMD R7-7735H', '50Mhz']
# Combine them with newline characters
labels = [f"{main}\n{sub}" for main, sub in zip(labels_main, subtexts)]
values = [41700, 909000] # e.g., Speed, FPS, Transactions per second (Higher is better)
# Define your unit here (add a space at the start so it looks clean)
unit_label = "Moves per Second [Moves/sec]"
brand_color = '#00E5FF'
competitor_color = '#888888'
multiplier = values[1] / values[0]
max_val = max(values)
black_outline = [path_effects.withStroke(linewidth=3, foreground='black')]
# ==========================================
# 2. SETUP FIGURE
# ==========================================
fig, ax = plt.subplots(figsize=(10, 4.5))
fig.patch.set_alpha(0.0)
ax.patch.set_alpha(0.0)
bars = ax.barh(labels, values, color=[competitor_color, brand_color], height=0.45, zorder=3)
# ==========================================
# 3. CONFIGURE AXES
# ==========================================
# X-Axis Tick Formatting
ax.xaxis.set_major_formatter(ticker.FuncFormatter(format_val))
for spine in ax.spines.values():
spine.set_visible(False)
ax.spines['bottom'].set_visible(True)
ax.spines['bottom'].set_color('white')
ax.spines['bottom'].set_path_effects(black_outline)
# Set base size for x-axis ticks
ax.tick_params(axis='x', colors='white', labelsize=12)
# Set larger font size specifically for Y-axis labels (Option 1)
ax.tick_params(axis='y', colors='white', labelsize=18)
for label in ax.get_xticklabels() + ax.get_yticklabels():
label.set_path_effects(black_outline)
ax.xaxis.grid(True, linestyle='--', color='white', alpha=0.3, zorder=0)
xlabel = ax.set_xlabel(unit_label, color='white', fontsize=12, labelpad=12, fontfamily='monospace')
xlabel.set_path_effects(black_outline)
# ==========================================
# 4. ADD BAR LABELS & BRACKET
# ==========================================
for bar, val in zip(bars, values):
width = bar.get_width()
txt = ax.text(width - (max_val * 0.02) if width >= (max_val*0.15) else width + (max_val*0.02),
bar.get_y() + bar.get_height()/2,
format_val(val),
ha='right' if width >= (max_val*0.15) else 'left',
va='center', color='white', fontsize=14, fontweight='bold')
txt.set_path_effects(black_outline)
# Draw Bracket
y0, y1 = [b.get_y() + b.get_height()/2 for b in bars]
x_line, x_tick = max_val * 1.05, max_val * 1.02
for x, y in zip([x_tick, x_tick, x_line], [y1, y0, [y0, y1]]):
l, = ax.plot([x_tick, x_line] if isinstance(y, (float, int)) else [x_line, x_line],
[y, y] if isinstance(y, (float, int)) else y, color=brand_color, lw=2)
l.set_path_effects(black_outline)
multiplier_txt = ax.text(x_line + (max_val * 0.03), (y0+y1)/2, f'{multiplier:.1f}x\nFASTER',
ha='left', va='center', color=brand_color, fontsize=22, fontweight='heavy')
multiplier_txt.set_path_effects(black_outline)
# Set x-axis limit to end around 1.1M
ax.set_xlim(0, 1_100_000)
plt.tight_layout()
plt.subplots_adjust(bottom=0.2)
plt.savefig('final_graph.png', dpi=300, bbox_inches='tight', transparent=True)
plt.show()
+145
View File
@@ -0,0 +1,145 @@
import matplotlib.pyplot as plt
import matplotlib.patheffects as path_effects
import matplotlib.ticker as ticker
# ==========================================
# 0. HELPER FUNCTION
# ==========================================
def format_val(x, pos=None):
"""Formats numbers to k/M format for axes and labels"""
if x >= 1_000_000:
return f"{x/1_000_000:.1f}".replace('.0', '') + 'M'
elif x >= 1000:
return f"{x/1000:.1f}".replace('.0', '') + 'k'
return str(int(x))
# ==========================================
# 1. EDIT YOUR DATA HERE
# ==========================================
labels_main = ['RTX 40 Series¹', 'RTX 40 Series²', 'RTX 40 Series²', '4 TET-FPGA', '4 TET-FPGA'][::-1]
subtexts = ['60FPS', '60FPS', '360FPS', '60FPS (Worst-Case)', '60FPS'][::-1]
note = ['competitor', 'competitor', 'competitor', 'ours', 'ours'][::-1]
invert_faster = False
invert_ours = True
# Combine main titles and subtexts with newline characters
labels = [f"{main}\n{sub}" for main, sub in zip(labels_main, subtexts)]
values = [57, 35, 17, 24.8, 12.8][::-1] # Base values (e.g., Delay Part 1)
values_extra = [0, 0, 0, 25, 17][::-1] # Extra add-on values (e.g., Delay Part 2)
# Define your unit here (add a space at the start so it looks clean)
unit_label = "Delay in [ms]"
# Style choices
brand_color = '#00E5FF'
competitor_color = '#00FF00'
extra_color = '#FF0000' # Color for extra segments (ours)
extra_color_extra = "#0E0E0E" # Color for extra segments (competitor)
black_outline = [path_effects.withStroke(linewidth=3, foreground='black')]
# ==========================================
# 2. SETUP & DYNAMIC PLOTTING
# ==========================================
fig, ax = plt.subplots(figsize=(10, 6))
fig.patch.set_alpha(0.0)
ax.patch.set_alpha(0.0)
# Create color lists dynamically based on the 'note' array
colors = [brand_color if n == 'ours' else competitor_color for n in note]
extra_colors = [extra_color if n == 'ours' else extra_color_extra for n in note]
# Plot base bars and stacked extra bars
bars_base = ax.barh(labels, values, color=colors, height=0.5, zorder=3)
bars_extra = ax.barh(labels, values_extra, left=values, color=extra_colors, height=0.5, zorder=3)
# Calculate total combined values for limits and bracket positioning
total_values = [v + e for v, e in zip(values, values_extra)]
max_val = max(total_values)
# Configure Axis
ax.xaxis.set_major_formatter(ticker.FuncFormatter(format_val))
for spine in ax.spines.values():
spine.set_visible(False)
ax.spines['bottom'].set_visible(True)
ax.spines['bottom'].set_color('white')
ax.spines['bottom'].set_path_effects(black_outline)
ax.tick_params(axis='x', colors='white', labelsize=12)
ax.tick_params(axis='y', colors='white', labelsize=18)
for label in ax.get_xticklabels() + ax.get_yticklabels():
label.set_path_effects(black_outline)
ax.xaxis.grid(True, linestyle='--', color='white', alpha=0.3, zorder=0)
xlabel = ax.set_xlabel(unit_label, color='white', fontsize=12, labelpad=12, fontfamily='monospace')
xlabel.set_path_effects(black_outline)
# Add Labels for each bar and text inside/outside the extra segment
for bar_base, bar_ext, v_base, v_ext in zip(bars_base, bars_extra, values, values_extra):
base_width = bar_base.get_width()
extra_width = bar_ext.get_width()
total_width = base_width + extra_width
if v_ext > 0:
# 1. Label at the very end of the total bar (just base+extra numbers)
end_txt = ax.text(total_width + (max_val * 0.02),
bar_base.get_y() + bar_base.get_height()/2,
f"{format_val(total_width)} ({format_val(v_base)}+{format_val(v_ext)})",
ha='left',
va='center', color='white', fontsize=10, fontweight='bold')
end_txt.set_path_effects(black_outline)
# 2. Text "[Peripherals]" centered horizontally inside the red/extra bar segment
mid_extra_x = base_width + (extra_width / 2.0)
in_txt = ax.text(mid_extra_x,
bar_base.get_y() + bar_base.get_height()/2,
"[Peripherals]",
ha='center',
va='center', color='white', fontsize=9, fontweight='bold')
in_txt.set_path_effects(black_outline)
else:
# Standard label for bars without an extra segment
end_txt = ax.text(total_width + (max_val * 0.02),
bar_base.get_y() + bar_base.get_height()/2,
format_val(total_width),
ha='left',
va='center', color='white', fontsize=10, fontweight='bold')
end_txt.set_path_effects(black_outline)
# ==========================================
# 3. DYNAMIC BRACKET (First vs Last based on totals)
# ==========================================
y_start = bars_base[0].get_y() + bars_base[0].get_height()/2
y_end = bars_base[-1].get_y() + bars_base[-1].get_height()/2
x_line, x_tick = max_val * 1.15, max_val * 1.12
l1, = ax.plot([x_tick, x_line], [y_end, y_end], color=brand_color, lw=2)
l2, = ax.plot([x_tick, x_line], [y_start, y_start], color=brand_color, lw=2)
l3, = ax.plot([x_line, x_line], [y_start, y_end], color=brand_color, lw=2)
for l in [l1, l2, l3]:
l.set_path_effects(black_outline)
start_val, end_val = values[0], values[-1]
multiplier = end_val / start_val
if (invert_faster):
mult_txt = ax.text(x_line + (max_val * 0.03), (y_start+y_end)/2,
f'{(1/multiplier):.1f}x\nFASTER',
ha='left', va='center', color=brand_color, fontsize=18, fontweight='heavy')
else:
mult_txt = ax.text(x_line + (max_val * 0.03), (y_start+y_end)/2,
f'{multiplier:.1f}x\nFASTER³',
ha='left', va='center', color=brand_color, fontsize=18, fontweight='heavy')
mult_txt.set_path_effects(black_outline)
# Set x-axis limit to comfortably fit the stacked bars, labels, and bracket
ax.set_xlim(0, max_val * 1.40)
plt.tight_layout()
plt.subplots_adjust(bottom=0.2)
plt.savefig('dynamic_comparison.png', dpi=300, transparent=True)
plt.show()
+91 -5
View File
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 67 KiB

+247
View File
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 257 KiB

+54
View File
@@ -0,0 +1,54 @@
import os
import cv2
import numpy as np
from PIL import Image
width = 200
height = 400
fps = 30 # Frames per second
total_frames = 240 # Increased to actually see the animation move
# Ensure output directory exists
os.makedirs("output", exist_ok=True)
# Define the VideoWriter
# 'mp4v' is a widely supported MP4 codec
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
video_path = "output/rainbow.mp4"
video = cv2.VideoWriter(video_path, fourcc, fps, (width, height))
colors = (
(0xFF, 0x00, 0x00),
(0xFF, 0x7F, 0x00),
(0xFF, 0xFF, 0x00),
(0x00, 0xFF, 0x00),
(0x00, 0xFF, 0xFF),
(0x00, 0x00, 0xFF),
(0x8B, 0x00, 0xFF),
(0xFF, 0x00, 0xFF),
)
img = Image.new("RGB", (width, height))
pixels = img.load()
frame_num = 0
while frame_num < total_frames:
for y in range(height):
for x in range(width):
# Adjusted the bit-shift so the animation moves visibly frame-by-frame
pixels[x, y] = colors[((x + y + (frame_num >> 1)) >> 4) & 7]
# 1. Convert PIL Image to a NumPy array
frame_np = np.array(img)
# 2. Convert RGB (PIL format) to BGR (OpenCV format)
frame_bgr = cv2.cvtColor(frame_np, cv2.COLOR_RGB2BGR)
# 3. Write the frame to the video file
video.write(frame_bgr)
frame_num += 1
# Crucial: Release the video writer to finalize and save the file
video.release()
print(f"Video saved successfully to {video_path}")
Submodule tet-cpu-plan deleted from 9d3abbb8e2