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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:42:58+00:00 2026-05-30T13:42:58+00:00

I’m having a little problem with drawn lines on a canvas, Basically I want

  • 0

I’m having a little problem with drawn lines on a canvas,

Basically I want the lines to be nice and soft and semi opaque however the canvas only seems to want to do this with last rendered line segment.

Have a look here, you will see that the last line segment drawn is nice and.. well how I want it) however as the animation plays, the lines drawn prior get all jaggy and nasty.

I’ve noticed that if i use closepath this doesn’t happen however, because of the interval/animation i cant use this each render as the line goes all over the place:

http://jsfiddle.net/xSPuM/1/

anyone have any ideas on how to stop this happening, i’d be very grateful.

Thanks very much
A

  • 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-05-30T13:42:59+00:00Added an answer on May 30, 2026 at 1:42 pm

    Strange code! The animation is neat though the way of doing this seems a bit unique, so lets take a look.

    First just to be completely clear, when you are making a path you can continue to stroke it over and over.

    So if you have a path with three line segments A,B,C and you do:

    A, stroke, B, stroke, C, stroke

    You will get segment A stroked 3 times, B stroked 2 times and C stroked once.

    This is essentially what you’re doing here.

    You can avoid that easily by stroking only once at the end of your path:

    http://jsfiddle.net/xSPuM/5/

    This stops the animation but illustrates what the problem is. You can fix the animation by clearing the screen. So with segments ABC we’d be doing:

    A, clear, stroke, B, clear, stroke, C, clear, stroke

    Then you’d get segment A stroked once, the screen is cleared and then segment A-B stroked once and the screen is cleared a final time so segment A-B-C gets stroked once. This is what you want.

    The problem with this is that clearing the screen means clearing all your previously drawn shapes! See here:

    http://jsfiddle.net/xSPuM/7/

    There are a few ways to fix this:

    1. Save the object currently being drawn on a temporary canvas (might be tricky)
    2. Save the previously drawn state to a temporary canvas (less tricky)
    3. Keep track of the three paths as if they were one path (easy peasy so I’ll do it for you)

    To do #3 all we gotta do is not call beginPath at the start of each new part. Instead we only call beginPath just once at the very start, and each new part is simply a moveTo operation!

    http://jsfiddle.net/xSPuM/8/

    That should be enough info to get you on the right track!

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
i want to parse a xhtml file and display in UITableView. what is the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.