Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <div id="root"></div>

              
            
!

CSS

              
                body {
  margin: 0;
  cursor: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/820793/cursor-auto.png), auto;
  background: white;
}

g, path {
  transform-origin: 240px 244px;  
}

@keyframes scale {
  to { transform: scale(1, 1); }
}

@keyframes draw {
  to { stroke-dashoffset: 0 };
}
              
            
!

JS

              
                function renderTheScene() {
  const RAYS = 13;
  const ANGLE = 180 / (RAYS - 1);

  ReactDOM.render(
    <Scene>
      <AxialSymetry>
        <DrawnPath
          id="Mountain__Large"
          d="M144.74 244l37.38-54 37.39 54H48"
          pathLength={302.9}
          duration={1.2}
          delay={-0.1}
        />
        <DrawnPath
          id="Mountain__Small"
          d="M123 244l24.92-36 24.93 36"
          pathLength={87.6}
          duration={0.6}
          delay={0.8}
        />
      </AxialSymetry>
      <CentralSymetry repeat={RAYS} angle={ANGLE}>
        <DrawnPath
          id="Ray__Main"
          d="M124 244H48"
          pathLength={76}
          duration={0.8}
          delay={1.2}
        />
        <DrawnPath
          id="Ray__Tip"
          d="M41 244h-9"
          pathLength={9}
          duration={0.1}
          delay={2}
        />
      </CentralSymetry>
      <CentralSymetry repeat={RAYS - 1} angle={ANGLE} offset={ANGLE / 2}>
        <DrawnPath
          id="Ray__Separator"
          d="M124 244H86"
          pathLength={38}
          duration={0.3}
          delay={1.2}
        />
      </CentralSymetry>
      <ScaledPath
        id="Tree__Evergreen"
        d="M261 217h-42l21-64z"
        duration={0.6}
        delay={1.9}
        x={0}
        y={0}
        style={{
          fill: "black",
          strokeWidth: 0,
          transformOrigin: '240px 215px',
        }}
      />
      <DrawnPath
        id="Tree__Trunk"
        pathLength={9}
        duration={0.1}
        delay={1.8}
        style={{ stroke: 'black' }}
        d="M240 231v-9"
      />
      <ScaledPath
        d="M116 258h248"
        id="Baseline"
        // only scale the line on the X axis
        y={1}
        duration={0.6}
        delay={1.7}
      />
    </Scene>,
    document.getElementById('root')
  );
}

function CentralSymetry({ children, offset = 0, angle, repeat }) {
  return Array.from({ length: repeat }, (_, index) =>
    React.Children.map(children, kid => (
      <g style={{ transform: `rotate(${offset + angle * index}deg)` }}>{kid}</g>
    ))
  );
}

function AxialSymetry(props) {
  return React.Children.map(props.children, kid => (
    <React.Fragment>
      {kid}
      <g style={{ transform: 'scale(1, -1) rotate(180deg)' }}>{kid}</g>
    </React.Fragment>
  ));
}

function ScaledPath({ x = 0, y = 0, duration, delay, style, ...rest }) {
  return (
    <path
      style={{
        transform: `scale(${x}, ${y})`,
        animation: `scale ${duration}s ease-out forwards ${delay}s`,
        ...style,
      }}
      {...rest}
    />
  )
}

function DrawnPath({ pathLength, duration, delay, style, ...rest }) {
  return (
    <path
      style={{
        strokeDashoffset: pathLength,
        strokeDasharray: pathLength,
        animation: `draw ${duration}s ease-out forwards ${delay}s`,
        ...style,
      }}
      {...rest}
    />
  );
}

function Scene(props) {
  return (
    <div
      style={{
        background: 'white',
        height: '100vh',
        display: 'flex',
        flexDirection: 'column',
        justifyContent: 'center',
        alignItems: 'center',
      }}
    >
      <svg
        viewBox="0 0 480 300"
        xmlns="http://www.w3.org/2000/svg"
        strokeWidth={5}
        fill="none"
        stroke="black"
      >
        {props.children}
      </svg>
    </div>
  );
}

renderTheScene();

              
            
!
999px

Console