Skip to content

Instantly share code, notes, and snippets.

Created February 20, 2018 01:04
Show Gist options
  • Save anonymous/daec0bfaffc2526304258a8dae532372 to your computer and use it in GitHub Desktop.
Save anonymous/daec0bfaffc2526304258a8dae532372 to your computer and use it in GitHub Desktop.
#6 pop fractal art | pure CSS
mixin fractal(levels)
while levels--
div
- layers = 9
- levels = 18
while layers--
article
- arms = 3
while arms--
section.set
+fractal(levels)
$layers: 9;
$levels: 30;
$arms: 3;
body {
margin: 0;
overflow: hidden;
height: 100vh;
font-size: 150px;
background: black;
}
.set {
position: absolute;
top: 50%;
left: 50%;
height: 1em;
width: 1em;
margin: -0.5em;
//visibility: hidden;
@for $i from 1 through $arms {
&:nth-child(#{$i}) {
transform: rotate(360deg/$arms*$i);
}
}
}
article {
position: absolute;
top: 50%;
left: 50%;
height: 1em;
width: 1em;
margin: -0.5em;
@for $i from 1 through $layers {
&:nth-child(#{$i}) {
transform: rotate($i*90deg) scale(pow(0.7,$i));
color: hsla(5*$i,50%,40%,1);
}
}
}
div {
position: absolute;
top: 50%;
left: 50%;
height: 1em;
width: 1em;
border-radius: 100%;
background-color: currentColor;
background-image: linear-gradient(to top, rgba(white,0.5), rgba(black,0.5));
box-shadow: 0 0 0 2px rgba(black,0.3);
&:before, &:after {
content: '';
position: absolute;
top: 50%;
left: 50%;
height: 0.5em;
width: 0.5em;
margin: -0.25em;
border-radius: inherit;
background: inherit;
box-shadow: inherit;
visibility: visible;
}
&:before {
transform: rotate(50deg) translateY(0.6em) rotate(150deg);
}
&:after {
transform: rotate(150deg) translateY(0.6em) rotate(50deg);
}
@for $i from 1 through $levels {
&:nth-child(#{$i}) {
font-size: 1em - 1/($levels + 1)*$i;
transform: rotate($i*10deg - pow($i,2)/3) translateY(-3em) rotate(-70deg*sin(-20deg*$i));
filter: hue-rotate(20deg*$i);
}
}
}
<link href="https://codepen.io/pixelass/pen/EozGLB.scss" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment