Skip to content

Commit

Permalink
ancient map and fixing colors
Browse files Browse the repository at this point in the history
  • Loading branch information
undertherain committed Sep 9, 2018
1 parent 4bff809 commit 76a95ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions contextfree/contextfree.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,10 @@ def __enter__(self):
self.source_old = _ctx.get_source()
r, g, b, a = self.source_old.get_rgba()
hue, lightness, saturation = colorsys.rgb_to_hls(r / 255, g / 255, b / 255)
#print("rgb:", r, g, b)
#print (hue, lightness, saturation)
hue = math.modf(hue + self.hue)[0]
lightness = lightness * self.lightness
lightness = lightness + self.lightness
if lightness > 1:
lightness = 1
if lightness < 0:
Expand All @@ -276,9 +278,13 @@ def __enter__(self):
saturation = 1
if saturation < 0:
saturation = 0
#print (hue, lightness, saturation)
r, g, b = colorsys.hls_to_rgb(hue, lightness, saturation)
#print("rgb:", r, g, b)
a = min((a * self.alpha), 255)
rgba = [r * 255, g * 255, b * 255, a]
# rgba = [int(r * 255), int(g * 255), int(b * 255), a]
rgba = [r, g, b, a]
#print(rgba)
_ctx.set_source_rgba(* rgba)

def __exit__(self, type, value, traceback):
Expand Down
Binary file modified examples/Ancient Map/map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion examples/Ancient Map/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ def ancient_map():
call_rule("wall")


init(canvas_size=(600, 600), background_color="#e5d5ac", max_depth=100)
init(canvas_size=(600, 600), background_color="#e5d5ac", max_depth=120)

ancient_map()
with rotate(math.pi / 2):
ancient_map()


write_to_png("/tmp/map.png")

0 comments on commit 76a95ce

Please sign in to comment.