Skip to content

Instantly share code, notes, and snippets.

Created February 20, 2018 01:05
Show Gist options
  • Save anonymous/80a57acf463a11ad2c4bf2ccfa0c217f to your computer and use it in GitHub Desktop.
Save anonymous/80a57acf463a11ad2c4bf2ccfa0c217f to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Feb 20, 2018.
    7 changes: 7 additions & 0 deletions fractal-tree.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    Fractal tree
    ------------
    another simple fractal tree

    A [Pen](https://codepen.io/libertario/pen/aqYzGK) by [Libertar.io](https://codepen.io/libertario) on [CodePen](https://codepen.io).

    [License](https://codepen.io/libertario/pen/aqYzGK/license).
    11 changes: 11 additions & 0 deletions index.pug
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    mixin nesting(n)
    if n > 0
    div(class=`_${n%2}`)
    +nesting(n - 1)
    div(class=`_${n%2}`)
    +nesting(n - 1)

    - depth = 11

    section
    +nesting(depth)
    65 changes: 65 additions & 0 deletions style.scss
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,65 @@
    $c: #F00;
    $f: 4000px;
    $s: 30;
    $r1: 0.7;
    $r2: 0.98;
    $st: 4px;

    body {
    margin: 0;
    overflow: hidden;
    background: #fff;
    height: 100vh;
    transform: scale(0.025);
    transform-origin: 50% 100%;
    }

    section {
    font-size: $f;
    $w: 8em/$s;
    $h: 1em;
    height: $h;
    width: $w;
    position: absolute;
    left: 50%;
    bottom: 0;
    margin-left: $w/-2;
    background: mix($c,black,10%);
    box-shadow:
    $st 0 0 0 mix($c,black,40%),
    $st*-1 0 0 0 mix($c,black,40%);

    }

    div {
    font-size: 1em*$r1;
    position: absolute;
    bottom: calc(100% - 0.1em);
    width: 100%*$r1;
    background: inherit;
    box-shadow: inherit;


    &:nth-child(1) {
    left: 0;
    transform-origin: 0 100%;
    transform: rotate(-35deg);
    &._1 {
    height: 100%*$r1;
    }
    &._0 {
    height: 100%*$r2;
    }
    }
    &:nth-child(2) {
    right: 0;
    transform-origin: 100% 100%;
    transform: rotate(25deg);
    &._1 {
    height: 100%*$r2;
    }
    &._0 {
    height: 100%*$r1;
    }
    }
    }