Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature: Show Ghost piece #33

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 10 additions & 40 deletions BlockParty.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def color_parse(color):
rgba.parse(color)
return rgba


jriyyya marked this conversation as resolved.
Show resolved Hide resolved
class VanishingCursor:

def __init__(self, win, hide_time=3):
Expand Down Expand Up @@ -221,9 +220,10 @@ def draw_glass(self, cairo_ctx):
draw_glass[i][j] != self.view_glass[i][j]:

color = self.colors[draw_glass[i][j]]
cairo_ctx.set_source_rgb(color.red,
color.green,
color.blue)
cairo_ctx.set_source_rgba(color.red,
color.green,
color.blue,
color.alpha)
cairo_ctx.rectangle(
self.xshift + j * self.bwpx,
self.yshift + (self.bh - i - 1) * self.bhpx,
Expand Down Expand Up @@ -391,42 +391,12 @@ def generate_ghost_py(self, figure):
ghost_py -= 1
return ghost_py + 1

def get_ghost_color(self, color, mix_intensity=0.5):
r = color.red
g = color.green
b = color.blue
r_int = int(r * 255)
g_int = int(g * 255)
b_int = int(b * 255)

# Convert RGB values to hexadecimal format
clr_string = "#{:02x}{:02x}{:02x}".format(r_int, g_int, b_int)
bg_color = self.colors[0]

# Convert fractions to 8-bit integer values (0-255)
r_int = int(bg_color.red * 255)
g_int = int(bg_color.green * 255)
b_int = int(bg_color.blue * 255)

# Convert RGB values to hexadecimal format
bg_string = "#{:02x}{:02x}{:02x}".format(r_int, g_int, b_int)

r1 = int(bg_string[1:3], 16)
g1 = int(bg_string[3:5], 16)
b1 = int(bg_string[5:7], 16)
r2 = int(clr_string[1:3], 16)
g2 = int(clr_string[3:5], 16)
b2 = int(clr_string[5:7], 16)

# Perform color interpolation
r = int(r1 + (r2 - r1) * mix_intensity)
g = int(g1 + (g2 - g1) * mix_intensity)
b = int(b1 + (b2 - b1) * mix_intensity)

# Convert RGB values to hexadecimal format
new_string = "#{:02x}{:02x}{:02x}".format(r, g, b)
new_color = color_parse(new_string)
return new_color
def get_ghost_color(self, color):
rgba = Gdk.RGBA()
rgba.parse(color.to_string())
rgba.alpha = 0.5
return rgba

jriyyya marked this conversation as resolved.
Show resolved Hide resolved

def chk_glass(self):
clearlines = []
Expand Down