My attempt for @CodePen's "100 dots" challenge using #zdog by @metafizzyco. https://codepen.io/corentinth/pen/WNeRdWP/right
Created
July 22, 2020 02:32
-
-
Save kiritodeveloper/ec222faaa2a0b2550d263ddd62644a3d to your computer and use it in GitHub Desktop.
100 dots - DNA Helix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
canvas#canvas | |
p.top (drag to rotate) | |
p.bottom | |
| By | |
a(href='https://twitter.com/cthmsst') Corentin Thomasset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const LINE_W = 50; | |
const BALL_W = 8; | |
const COUNT = 50; | |
const SPACING = 14; | |
const illo = new Zdog.Illustration({ | |
element: "#canvas", | |
dragRotate: true, | |
resize: "fullscreen" | |
}); | |
const Line = new Zdog.Shape({ | |
path: [{ x: LINE_W }, { x: -LINE_W }], | |
stroke: 2, | |
color: "#ffd460" | |
}); | |
const Dot = new Zdog.Shape({ | |
stroke: BALL_W * 2, | |
color: "#ea5455" | |
}); | |
for (let i = 0; i < COUNT; ++i) { | |
const line = Line.copy({ | |
addTo: illo, | |
rotate: { | |
y: Zdog.TAU / COUNT * 2 * i | |
}, | |
translate: { | |
y: -(COUNT / 2 * SPACING) + i * SPACING | |
} | |
}); | |
Dot.copy({ | |
addTo: line, | |
translate: { | |
x: -(BALL_W + LINE_W + 10) | |
} | |
}); | |
Dot.copy({ | |
addTo: line, | |
translate: { | |
x: BALL_W + LINE_W+10 | |
} | |
}); | |
} | |
illo.updateRenderGraph(); | |
const animate = () => { | |
illo.rotate.y += 0.02; | |
illo.updateRenderGraph(); | |
requestAnimationFrame(animate); | |
} | |
animate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://unpkg.com/zdog@1/dist/zdog.dist.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
box-sizing: border-box; | |
} | |
html, | |
body { | |
margin: 0; | |
width: 100%; | |
height: 100%; | |
overflow: hidden; | |
position: relative; | |
} | |
#canvas { | |
background: #2d4059; | |
} | |
p{ | |
position: absolute; | |
margin: 10px; | |
font-family: Calibri, sans-serif; | |
right: 0; | |
&, a{ | |
color: #b1592c; | |
} | |
&.top{ | |
top:0; | |
} | |
&.bottom{ | |
bottom:0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment