Fullscreen colorpicker
This is a light Version of http://colourco.de. colourco.de is an online designer tool, which allows you to easily and intuitively combine colours.
<link href="http://blog.zaku.eu/css/codepen.font.css" rel="stylesheet" />
<link href="http://blog.zaku.eu/css/codepen.font.css" rel="stylesheet" />
<div class="color">
<span></span>
</div>
<div class="menu">
<input type="checkbox" checked id="menu-collapsed" name="menu-collapsed" />
<div class="menu-content">
<h2>How to ...?</h2>
<table>
<tr><th colspan="2"><h3>Change color:</h3></th></tr>
<tr><td>hue:</td><td>mouse left/right</td></tr>
<tr><td>saturation:</td><td>scroll up/down</td></tr>
<tr><td>lightness:</td><td>mouse up/down</td></tr>
<tr><th colspan="2"><h3>Lock color:</h3></th></tr>
<tr><td>click:</td><td>lock color</td></tr>
<tr><td>dblclick:</td><td>release lock</td></tr>
<tr><td colspan="2"><h3>Want more?</h3></td></tr>
<tr><td colspan="2"><a href="http://colourco.de">colourco.de</a></td></tr>
</table>
<a href="https://twitter.com/TaminoMartinius" class="twitter-follow-button" data-show-count="false"></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
<div class="menu-switch">
<label class="collapse" for="menu-collapsed"><</label>
<label class="rise" for="menu-collapsed">!</label>
</div>
</div>
<b>W</b>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/d3/3.0.1/d3.v3.min.js"></script>
html, body {
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
font-family: 'Open Sans Condensed', sans-serif;
}
a, a:visited, a:hover {
color: inherit;
}
b {
font-size: 1.5em;
position: absolute;
display: block;
top: 0;
left: 50%;
margin: 0.5em 0 0 -1em;
width: 2em;
height: 1.5em;
background-color: rgba(0, 0, 0, 0.25);
font-family: RaphaelIcons;
text-align: center;
padding-top: 0.5em;
border-radius: 0.5em;
user-select: none;
cursor: pointer;
}
.color {
width: 100%;
position: absolute;
margin-top: -4em;
text-align: center;
top: 50%;
span {
display: inline-block;
padding: 1em;
border-radius: 1em;
background-color: rgba(0, 0, 0, 0.25);
}
}
.menu {
font-size: 0.85em;
position: relative;
z-index: 10;
user-select: none;
width: 18em;
.menu-content {
transition: margin-left 1s;
padding-left: 1em;
background-color: rgba(0, 0, 0, 0.25);
border-radius: 0 1em 1em 0;
float: left;
width: 13em;
h2 {
font-family: 'Handlee', cursive;
font-weight: normal;
margin-left: 1em;
margin-bottom: 0.2em;
}
h3 {
font-weight: normal;
margin: 0.4em 0 0.2em 0;
}
table {
margin-bottom: 1em;
}
ul {
list-style: none;
}
}
li, label {
color: rgba(252,251,250,0.5);
cursor: pointer;
transition-duration: 1.0s;
&:hover {
transition-duration: 0.3s;
color: rgba(252,251,250,0.9);
}
}
.menu-switch {
padding-top: 12em;
label {
font-family: RaphaelIcons;
background-color: rgba(0, 0, 0, 0.25);
border-radius: 0 1em 1em 0;
padding: 0.2em;
font-size: 3em;
}
}
input {
display: none;
}
#menu-collapsed{
&:checked{
~ .menu-content {
margin-left: -14em;
}
~ .menu-switch .rise {
display: inline-block;
}
~ .menu-switch .collapse {
display: none;
}
}
~ .menu-switch .rise {
display: none;
}
}
}
h = ~~(Math.random() * 360)
h = ~~(Math.random() * 360)
s = 50
l = 50
lock = off
draw = () ->
if lock is off
$('b').hide()
hsl = new d3.hsl h, s / 100.0, l / 100.0
hcl = new d3.hcl hsl
rgb = new d3.rgb hsl
lab = new d3.lab hsl
$('span').html ""
$('span').append hsl.toString()
$('span').append "<br /> rgb(#{rgb.r}, #{rgb.g}, #{rgb.b})"
$('span').append "<br /> hsl(#{h}, #{s}%, #{l}%)"
$('span').append "<br /> hcl(#{(~~hcl.h + 360) % 360}, #{hcl.c.toFixed(2)}%, #{hcl.l.toFixed(2)}%)"
$('span').append "<br /> lab(#{lab.l.toFixed(0)}, #{lab.a.toFixed(0)}, #{lab.b.toFixed(0)})"
$('body').css "background-color", "hsl(#{h}, #{s}%, #{l}%)"
$('body').css "color", "rgb(#{Math.min(rgb.r + 96, 255)}, #{Math.min(rgb.g + 96, 255)}, #{Math.min(rgb.b + 96, 255)})"
else
$('b').show()
$(window).mousemove (e) ->
maxX = window.innerWidth
maxY = window.innerHeight
x = e.pageX
y = e.pageY
h = ~~(x / maxX * 360)
l = ~~(y / maxY * 10000) / 100
draw()
return
wheelEvent = (e) ->
delta = if (e.wheelDelta || e.detail || e.originalEvent.wheelDelta || e.originalEvent.detail) > 0 then 1 else -1
s = Math.max(0, Math.min(100, s + delta * 5))
draw()
return
$('body').bind "mousewheel", wheelEvent
$('body').bind "DOMMouseScroll", wheelEvent
$('b').click () ->
lock = off
$(window).click () ->
lock = on
$(window).dblclick () ->
lock = off
$('b').mouseenter () ->
$('b').html 'w'
$('b').mouseleave () ->
$('b').html 'W'
hash = if location.hash.indexOf('(') > 0 then location.hash.substr(1) else location.hash
if hash.length > 0
hsl = new d3.hsl hash
h = hsl.h
s = hsl.s * 100
l = hsl.l * 100
draw()
lock = on
else
draw()