开发者

Rotating Wireframe Sphere in Canvas [closed]

Closed. This question needs debugging details. It is not currently accepting answers.

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 question

I'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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜