Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9021737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:19:37+00:00 2026-06-16T05:19:37+00:00

What would be the simplest solution to draw sine waves in SVG? I guess

  • 0

What would be the simplest solution to draw sine waves in SVG?
I guess sine waves should be repeated in a simple loop with JavaScript… 🙂

Here are the X-Y coordinates as a good start… 🙂

http://jsbin.com/adaxuy/1/edit

<svg>
  <line x1="0" y1="250" x2="500" y2="250"
        style="stroke:black;stroke-width:1"/>
  <line x1="250" y1="0" x2="250" y2="500"
        style="stroke:black;stroke-width:1"/>
</svg>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:19:38+00:00Added an answer on June 16, 2026 at 5:19 am

    Here is a proof of concept that adds multiple line elements to the SVG element:

    var svg = document.getElementById('sine_wave').children[0];
    var origin = { //origin of axes
        x: 100,
        y: 100
    };
    var amplitude = 10; // wave amplitude
    var rarity = 1; // point spacing
    var freq = 0.1; // angular frequency
    var phase = 0; // phase angle
    
    for (var i = -100; i < 1000; i++) {
        var line = document.createElementNS("http://www.w3.org/2000/svg", "line");
    
        line.setAttribute('x1', (i - 1) * rarity + origin.x);
        line.setAttribute('y1', Math.sin(freq*(i - 1 + phase)) * amplitude + origin.y);
    
        line.setAttribute('x2', i * rarity + origin.x);
        line.setAttribute('y2', Math.sin(freq*(i + phase)) * amplitude + origin.y);
    
        line.setAttribute('style', "stroke:black;stroke-width:1");
    
        svg.appendChild(line);
    }
    html, body, div{
        height:100%;
    }
    <div id="sine_wave">
    
      <svg width="1000" height="1000">
        <line x1="100" y1="0" x2="100" y2="200"
              style="stroke:black;stroke-width:1"/>
        <line x1="0" y1="100" x2="1000" y2="100"
              style="stroke:black;stroke-width:1"/>
      </svg>
    
    </div>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know the simplest solution to changing the underscores of my
I've come across a problem to which the simplest solution would be to extend
Would the simplest way to create a threadpool (or, at least obtain the code
The simplest example would be the built in class keyValuePair(of T,U). I would like
What would be the best way (ideally, simplest) to convert an int to a
What is the simplest way to customize the content display of ComboBoxItem? I would
Would like a for loop in jquery so that: For every hover_link: show hidden
Following problem. I just tried to draw little things with C#. I would like
I have a very annoying problem and I'm trying to find the simplest solution
If I define a simple string variable, how would I count and output the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.