parent
da968c2fd4
commit
c067b426a9
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,129 @@
|
|||
#! /usr/local/bin/python3
|
||||
|
||||
def main(args) :
|
||||
print("args", args)
|
||||
for i in args :
|
||||
rotate(i)
|
||||
|
||||
def rotate(x) :
|
||||
print("input: {}", x)
|
||||
rgb = hex_to_rgb(x)
|
||||
print("rgb: {}", rgb)
|
||||
hsl = rgb_to_hsl(rgb)
|
||||
print("hsl: {}", hsl)
|
||||
import os
|
||||
env = os.environ
|
||||
if "DEG" in env :
|
||||
deg = int(env["DEG"])
|
||||
else :
|
||||
deg = 110
|
||||
hsl = rotate_hsl(hsl, deg)
|
||||
print("hsl': {}", hsl)
|
||||
rgb = hsl_to_rgb(hsl)
|
||||
print("rgb': {}", rgb)
|
||||
print(rgb_to_hex(rgb))
|
||||
|
||||
def hex_to_rgb(x) :
|
||||
if x.startswith("#") :
|
||||
x = x[1:]
|
||||
r = x[0:2]
|
||||
g = x[2:4]
|
||||
b = x[4:6]
|
||||
return (
|
||||
hex_to_dec(r),
|
||||
hex_to_dec(g),
|
||||
hex_to_dec(b),
|
||||
)
|
||||
|
||||
def hex_to_dec(x) :
|
||||
s = 0
|
||||
mul = 1
|
||||
for i in range(len(x)):
|
||||
c = x[len(x)-i-1]
|
||||
c = c.upper()
|
||||
digit = ord(c) - ord('0')
|
||||
if not c.isdigit() :
|
||||
digit = ord(c) - ord('A') + 10
|
||||
s += mul * digit
|
||||
mul *= 16
|
||||
return s
|
||||
|
||||
def rgb_to_hsl(rgb) :
|
||||
return (
|
||||
compute_h(rgb),
|
||||
compute_s(rgb),
|
||||
compute_l(rgb),
|
||||
)
|
||||
|
||||
def compute_h(rgb) :
|
||||
r, g, b, cmax, cmin, delta = compute_hsl_const(rgb)
|
||||
if delta == 0 :
|
||||
return 0
|
||||
if r == cmax :
|
||||
return 60 * ( ( (g - b)/delta ) % 6)
|
||||
if g == cmax :
|
||||
return 60 * ( ( (b - r)/delta ) + 2)
|
||||
if b == cmax :
|
||||
return 60 * ( ( (r - g)/delta ) + 4)
|
||||
|
||||
def compute_s(rgb) :
|
||||
r, g, b, cmax, cmin, delta = compute_hsl_const(rgb)
|
||||
if delta == 0 :
|
||||
return 0
|
||||
return delta / ( 1 - (abs(2*compute_l(rgb)-1)) )
|
||||
|
||||
def compute_l(rgb) :
|
||||
r, g, b, cmax, cmin, delta = compute_hsl_const(rgb)
|
||||
return (cmax + cmin) / 2
|
||||
|
||||
def compute_hsl_const(rgb) :
|
||||
rgb = [ i/255.0 for i in rgb ]
|
||||
return rgb[:] + [max(rgb), min(rgb), max(rgb)-min(rgb)]
|
||||
|
||||
def rotate_hsl(hsl, deg) :
|
||||
return (
|
||||
(hsl[0] + deg) % 360,
|
||||
hsl[1],
|
||||
hsl[2],
|
||||
)
|
||||
|
||||
def hsl_to_rgb(hsl) :
|
||||
h = hsl[0]
|
||||
s = hsl[1]
|
||||
l = hsl[2]
|
||||
|
||||
c = s * (1 - abs(2 * l))
|
||||
x = c * (1 - abs((h / 60) % 2 - 1))
|
||||
m = l - (c / 2)
|
||||
|
||||
rgbp = ()
|
||||
if h < 60 :
|
||||
rgbp = (c, x, 0)
|
||||
if h < 120 :
|
||||
rgbp = (x, c, 0)
|
||||
if h < 180 :
|
||||
rgbp = (0, c, x)
|
||||
if h < 240 :
|
||||
rgbp = (0, x, c)
|
||||
if h < 300 :
|
||||
rgbp = (x, 0, c)
|
||||
else:
|
||||
rgbp = (c, 0, x)
|
||||
|
||||
r = rgbp[0]
|
||||
g = rgbp[1]
|
||||
b = rgbp[2]
|
||||
return (
|
||||
(r+m)*255,
|
||||
(g+m)*255,
|
||||
(b+m)*255,
|
||||
)
|
||||
|
||||
def rgb_to_hex(rgb) :
|
||||
r = min(max(int(rgb[0]), 0), 255)
|
||||
g = min(max(int(rgb[1]), 0), 255)
|
||||
b = min(max(int(rgb[2]), 0), 255)
|
||||
return "#{:02x}{:02x}{:02x}".format(r, g, b)
|
||||
|
||||
from sys import argv
|
||||
main(argv[1:])
|
||||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 7e86e4f67c8a90d581df8926e77fbe9534752c9e
|
||||
|
|
@ -22,7 +22,7 @@ func (s *Server) notes(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func notesHead(w http.ResponseWriter, p filetree.Path) {
|
||||
fmt.Fprintln(w, h2(p.MultiLink(), "margin: 0; position: fixed; padding: .25em; background-color: #202b38; width: 100%; top: 0;"))
|
||||
fmt.Fprintln(w, h2(p.MultiLink()))
|
||||
htmlSearch(w)
|
||||
}
|
||||
|
||||
|
|
|
|||
33
wrapper.html
33
wrapper.html
|
|
@ -1,33 +0,0 @@
|
|||
<html>
|
||||
<header>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<!-- https://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/dark.min.css -->
|
||||
<style>
|
||||
@charset "UTF-8";body{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;line-height:1.4;max-width:800px;margin:20px auto;padding:0 10px;color:#dbdbdb;background:#202b38;text-rendering:optimizeLegibility}button,input,textarea{transition:background-color .1s linear,border-color .1s linear,color .1s linear,box-shadow .1s linear,transform .1s ease}h1{font-size:2.2em;margin-top:0}h1,h2,h3,h4,h5,h6{margin-bottom:12px}h1,h2,h3,h4,h5,h6,strong{color:#fff}b,h1,h2,h3,h4,h5,h6,strong,th{font-weight:600}blockquote{border-left:4px solid rgba(0,150,191,.67);margin:1.5em 0;padding:.5em 1em;font-style:italic}blockquote>footer{margin-top:10px;font-style:normal}address,blockquote cite{font-style:normal}a[href^=mailto]:before{content:"📧 "}a[href^=tel]:before{content:"📞 "}a[href^=sms]:before{content:"💬 "}button,input[type=button],input[type=checkbox],input[type=submit]{cursor:pointer}input:not([type=checkbox]):not([type=radio]),select{display:block}button,input,select,textarea{color:#fff;background-color:#161f27;font-family:inherit;font-size:inherit;margin-right:6px;margin-bottom:6px;padding:10px;border:none;border-radius:6px;outline:none}button,input:not([type=checkbox]):not([type=radio]),select,textarea{-webkit-appearance:none}textarea{margin-right:0;width:100%;box-sizing:border-box;resize:vertical}button,input[type=button],input[type=submit]{padding-right:30px;padding-left:30px}button:hover,input[type=button]:hover,input[type=submit]:hover{background:#324759}button:focus,input:focus,select:focus,textarea:focus{box-shadow:0 0 0 2px rgba(0,150,191,.67)}button:active,input[type=button]:active,input[type=checkbox]:active,input[type=radio]:active,input[type=submit]:active{transform:translateY(2px)}button:disabled,input:disabled,select:disabled,textarea:disabled{cursor:not-allowed;opacity:.5}::-webkit-input-placeholder{color:#a9a9a9}:-ms-input-placeholder{color:#a9a9a9}::-ms-input-placeholder{color:#a9a9a9}::placeholder{color:#a9a9a9}a{text-decoration:none;color:#41adff}a:hover{text-decoration:underline}code,kbd{background:#161f27;color:#ffbe85;padding:5px;border-radius:6px}pre>code{padding:10px;display:block;overflow-x:auto}img{max-width:100%}hr{border:none;border-top:1px solid #dbdbdb}table{border-collapse:collapse;margin-bottom:10px;width:100%}td,th{padding:6px;text-align:left}th{border-bottom:1px solid #dbdbdb}tbody tr:nth-child(2n){background-color:#161f27}::-webkit-scrollbar{height:10px;width:10px}::-webkit-scrollbar-track{background:#161f27;border-radius:6px}::-webkit-scrollbar-thumb{background:#324759;border-radius:6px}::-webkit-scrollbar-thumb:hover{background:#415c73}
|
||||
</style>
|
||||
<style>
|
||||
nav {
|
||||
display: block;
|
||||
background: #161f27;
|
||||
padding: .5pt;
|
||||
border-radius: 6px;
|
||||
}
|
||||
nav li li li li {
|
||||
display: none;
|
||||
}
|
||||
img {
|
||||
max-height: 400px;
|
||||
}
|
||||
body {
|
||||
font-size: 125%;
|
||||
filter: hue-rotate(120deg);
|
||||
background: #3b242b;
|
||||
}
|
||||
</style>
|
||||
</header>
|
||||
<body height="100%">
|
||||
{{{}}}
|
||||
</body>
|
||||
<footer>
|
||||
</footer>
|
||||
</html>
|
||||
Loading…
Reference in New Issue