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

  • SEARCH
  • Home
  • 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 8301855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:08:48+00:00 2026-06-08T17:08:48+00:00

I have adopted and adapted an HTML5 canvas extension which draws dotted lines, but

  • 0

I have adopted and adapted an HTML5 canvas extension which draws dotted lines, but it has a couple of problems as shown in http://jsfiddle.net/VxCYL/2/

Example 1: How can I avoid the “bunching” up of dots where the distance between two points is very small (see the first corner at 30,50 going to 32,50). I guess I need to check the distance from the last point when determining whether to draw or move to the next point? The output looks clumsy when I have lots of points.

Example 2: Where the from.x is less than the to.x or the from.y is less than the to.y i.e. drawing backwards the moveTo does not behave as I would expect i.e. in the example shown the lines should still be joined up.

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-08T17:08:49+00:00Added an answer on June 8, 2026 at 5:08 pm

    The first problem is not easily fixed in the library as it stands. It requires a wrapper method that takes an array of points so that it can accumulate and keep track of the current dot/dash state when ’rounding a corner’. (Time permitting I will write a method that does this; if I do so I will edit this answer and add a notification comment.)

    You cannot handle this with the current current code by changing your dashArray.

    For example, with a nominal dashArray of [2,9] the pattern repeats every 11px. If your first line is 115px, it means that you will have drawn 10 copies of the pattern, 2px of dot and 3px of dash. You want your next line thus to start with a 6px offset before drawing the next dot. You would need a dashArray of [0,6,2,9,2,9,2,9,2,9,2,9,...] until you had covered the length of your next line. :/


    The second example is clearly a bug in the code. Here’s a slightly simpler demo showing it:

    Broken: http://jsfiddle.net/VxCYL/3/

    To fix it, we need to ensure that xStep is negative when dx is negative. We add this one line in:

    if (dx<0) xStep = -xStep;
    

    Fixed: http://jsfiddle.net/VxCYL/4/

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

Sidebar

Related Questions

I have a simple java project (adapted from the example here ), which is
Ok found some great code on Stack. Have adapted it slightly. But in essence
I have a questions.xml file which has a list of questions for my quiz,
I work for a large company that has adopted sharepoint. I have been tasked
I have a JQuery carousel which I have adapted for my needs. I need
I have some problems with making my web-app adapted for remote user browseres language
I have adapted some code from a great article I found about circle drawing
I have adopted an iOS app and am having problem asynchronous requests. We have
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=

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.