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 9203539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:29:44+00:00 2026-06-17T23:29:44+00:00

Is there a way with Javascript (or jQuery) to draw lines between coordinates (not

  • 0

Is there a way with Javascript (or jQuery) to draw lines between coordinates (not necessarily showing those lines) and then repeat an image or a letter along those “paths”?
I am talking straight lines here, no bezier curves or anything.
I would think it doesn’t seem like a big deal and will give it a go, but I’d like to have others’ opinion on this…
something like (imaginary code):

path = point1[x,y], point2[x,y], point3[x,y];
every20pixels-->renderimage('path/to/image') or letter('letter')

am I crazy?
Thanks

  • 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-17T23:29:45+00:00Added an answer on June 17, 2026 at 11:29 pm

    tl;dr

    Here’s a jsFiddle that does what I think you want: click.

    Explanation

    It is quite easy actually, given that you can calculate any point on a line by knowing it’s x-coordinate and two of the points the line goes through:

    // A line, defined by two coordinates
    var s = {x: 0.0, y: 0.0}; // Start
    var e = {x: 300.0, y: 100.0}; // End
    
    var distance = (e.x - s.x)
    var slope = (e.y - s.y) / distance
    

    As soon as you have the slope, you can calculate any “y” on the line by simply multiypling it’s x-coordinate with the slope:

    var step = 32; // Calculate y-coordinate every 32 units
    for(var x=0; x<distance; x+=step) {
        var y = x * slope;
        console.log(s.x + x, s.y + y);
        // The next snippet goes here ↓
    }
    

    Having that, the rest is simply a matter copying an image (or other DOM object) and position it at these coordinates:

    image.clone().appendTo(stage).css({
        left: (s.x + x-imageWidth/2) + "px",
        top: (s.y + y-imageHeight/2) + "px"
    })
    

    The -imageWidth/2 part is there to center the image on the line. Otherwise, the upper left corner of the image would be positioned there. Also, this method relies on the fact that you specify the coordinates relative to their parents containers offset, which must have the position: relative attribute. Every element you position using this technique must then have a position: absolute, as suggested by @Eru’s comment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there a way with javascript/jquery to prevent images from loading? I am building
Is there a way in JavaScript or jQuery to call a function when the
Is there a way to kill the unload function with javascript(jquery)? I am looking
Is there any way that I can use JavaScript (and jQuery) to create a
Is there a way to pass a variable into a regex in jQuery/Javascript? I
Is there a way (in jQuery or JavaScript) to loop through each object and
Is there a way with JQUERY or Javascript, to detect anytime the browser window
I am wondering if there is a better way to write this JavaScript (Jquery)
I'm trying to figure out if there is a way (using JavaScript, or jQuery
Just like in JavaScript : opener.document.getElementByName jQuery: ?? Is there any way to get

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.