SVG sine wave
How do I make an svg sine wave?
Animating points of a polygon with sine wave movement. What is a svg sine wave? How do you make a svg sine wave? This script and codes were developed by Gregor Adams on 25 October 2022, Tuesday.
SVG sine wave - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>SVG sine wave</title> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<svg height="200" width="400"> <polygon/>
</svg> <script src="js/index.js"></script>
</body>
</html>
SVG sine wave - Script Codes CSS Codes
svg { display: inline-block; stroke-width: 4; fill: none; padding: 10px;
}
body { background: #333; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; height: 100vh; overflow: hidden; margin: 0;
}
SVG sine wave - Script Codes JS Codes
'use strict';
function move(amplitude, frequency, length, i) { var points = [0, amplitude * 2]; var width = length; var x = 0, y; while (x++ <= width) { y = Math.sin(x * frequency + i); points.push([x, y * amplitude / 2 + amplitude / 2].join(' ')); } points.push([length, amplitude * 2].join(' ')); points.push([0, amplitude * 2].join(' ')); return points;
}
var svg = document.querySelector('svg');
var polygon = svg.querySelector('polygon');
var counter = 0;
var width = svg.getAttribute('width');
var height = svg.getAttribute('height') / 2;
function draw() { var c = ++counter / 20; polygon.setAttribute('points', move(height, .01, width, c)); svg.setAttribute('stroke', 'hsl(' + c * 10 + ',100%,50%)'); requestAnimationFrame(draw);
}
draw();
Developer | Gregor Adams |
Username | pixelass |
Uploaded | October 25, 2022 |
Rating | 4 |
Size | 2,988 Kb |
Views | 62,744 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Diagonal scroll | 5,113 Kb |
Text stroke helpers for SCSS | 5,647 Kb |
Fractal curve generator | 13,870 Kb |
Google dots animation | 4,211 Kb |
Flat webpage concept | 12,434 Kb |
Material button pure CSS | 3,594 Kb |
Netfix logo animation CSS | 10,303 Kb |
Pure CSS marching ants border | 3,837 Kb |
3D Particle Heart | 5,711 Kb |
RubiCSS cube | 12,148 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
LBCA - Mail canvas | Emnbdx | 3,856 Kb |
A Pen by utcwebdev | Utcwebdev | 2,856 Kb |
A Pen by Adrien Clerbois | AClerbois | 6,501 Kb |
A Pen by Jonas Bjork | Jonasbjork | 3,115 Kb |
Monochrome Form | AlienPiglet | 3,096 Kb |
A Pen by Brendan Skousen | Bskousen | 2,954 Kb |
A Pen by Moeid Saleem | Moeidsaleem | 1,862 Kb |
Rain Landing in a Pond | Edball | 3,009 Kb |
Hard-Stop Gradients | Mackdoyle | 2,288 Kb |
IE11 Test | Boostnewmedia | 4,998 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!