Created
November 1, 2023 23:12
-
-
Save PM2Ring/502594e72f2a167ddff955794c7f678f to your computer and use it in GitHub Desktop.
Hyperbolic color demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Hyperbolic color demo | |
Written by PM 2Ring 2023.11.2 | |
""" | |
txt = ''' <h3>Hyperbolic color demo</h3> | |
Stare at the black dot for ~30 seconds, | |
then click the colored square to change it | |
to the complementary color. | |
''' | |
@interact | |
def _(txt=HtmlBox(txt), hue=60): | |
out = f'''\ | |
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"> | |
<style> | |
.c0{{fill:hwb({hue} 0% 0%)}} | |
.c1{{fill:hwb({(hue+180)%360} 0% 0%)}} | |
</style> | |
<rect id="a" width="100" height="100" class="c0"> | |
<set attributeName="class" to="c1" begin="a.click" dur="5s"/> | |
</rect> | |
<circle cx="50" cy="50" r="1"/></svg> | |
''' | |
with open("hyper.svg", "w") as f: | |
f.write(out) | |
#print(out) | |
show(html(out)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Live demo on SageMathCell.