D
D
distorting_reality2014-07-09 22:51:24
css
distorting_reality, 2014-07-09 22:51:24

I drew 2 shapes through Canvas (JS). The first disappeared, the second remained. Why is that?

First I drew the first figure. Everything is correct and working. When I drew the second one, the first one disappeared. And even the second figure is drawn much lower than the first. How to fix? Help me please.
The whole code is too capacious, so I will write only the parameters that I mainly used:

context.beginPath();
context.moveTo();
context.quadraticCurveTo();
context.lineWidth = value;
context.strokeStyle = "color";
context.stroke();

Each figure began with
window.onload = function() {
  var canvas = document.getElementById("example");
  var context = canvas.getContext("2d");

PS There are no errors in the code. Another figure - another ID.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Taratin, 2014-07-09
@distorting_reality

You do not need to start each figure with

var canvas = document.getElementById("example");
  var context = canvas.getContext("2d");

The context is enough to get 1 time

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question