Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
开发者_运维知识库Closed 5 years ago.
Improve this questionI'll admit, I'm not quite well-versed in canvas or javascript yet (heck, I haven't done trig in many many years), but I was able to find something similar to what I was looking for in some canvas demos.
Rotating Sphere: http://www.javascriptdemos.com/?demoid=1
It's almost exactly what I wanted, but I was wondering if someone can help me draw lines in rather than it being dotted for longitude and latitude.
Any assistance will be greatly appreciated.
To draw a line on an HTML Canvas context:
var ctx = mycanvas.getContext('2d');
...
ctx.lineWidth = 2; //px
ctx.strokeStyle = '#000'; // black
ctx.beginPath();
ctx.moveTo(14,42); // First point
ctx.lineTo(20,30); // Repeat as desired
ctx.lineTo(25,35); // Repeat as desired
ctx.stroke(); // Actually draw the path!
I suspect you're missing the call to stroke()
in your attempts. Note that you can call moveTo()
multiple times during a single path, as long as you want to use the same lineWidth/strokeStyle for all segments (as it sounds like you do).
精彩评论