Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript Canvas drawing problem
    primarykey
    data
    text
    <p>So I have a bunch of javascript to make some random points, and then connects them via a minimum spanning tree. That all works fine.</p> <p>Then after that it draws the points and paths onto the canvas; and it draws an image like this:</p> <p><img src="https://i.stack.imgur.com/EKE64.png" alt="First example"></p> <p>- Randomly generated each time.</p> <p>The problem I have with this, is that I'd like to have each of the circles be a black circle with a yellow outline. The circles are drawn like so:</p> <pre><code>context.fillStyle = "#ffff00"; for(var i = 0; i &lt; syscount; i++){ context.moveTo(systemsX[i],systemsY[i]); context.arc(systemsX[i],systemsY[i],4,0,Math.PI*2,true); } context.fill(); </code></pre> <p>and that works fine, but I want to draw a black circle, and have a yellow trace. I want to do it this way because it's much easier than stopping the lines that join the dots stop a few pixels earlier than they normally would.</p> <p>This was my attempt:</p> <pre><code>context.fillStyle = "#000000"; for(var i = 0; i &lt; syscount; i++){ context.moveTo(systemsX[i],systemsY[i]); context.arc(systemsX[i],systemsY[i],ssize,0,Math.PI*2,true); } context.fill(); context.strokeStyle = "#ffff00"; for(var i = 0; i &lt; syscount; i++){ context.moveTo(systemsX[i]+ssize,systemsY[i]); context.arc(systemsX[i],systemsY[i],ssize,0,Math.PI*2,true); } context.stroke(); </code></pre> <p>but it draws this:</p> <p><img src="https://i.stack.imgur.com/WTRp5.png" alt="Second example"></p> <p>?!! It redraws over the other path. Why?!</p> <p>Zip of the page: <a href="http://rapidshare.com/files/415710231/page.zip" rel="nofollow noreferrer">http://rapidshare.com/files/415710231/page.zip</a> (html file and a css file inside the zip). The snippet of code for drawing the circles starts at line 164.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload