script.js 775 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. function Figure(x,y,color) {
  2. this.x = x;
  3. this.y = y;
  4. this.color = color;
  5. };
  6. function Circle(x,y,r,color) {
  7. Figure.call(this,x,y,color);
  8. this.draw = function() {
  9. var canvas = document.getElementById("canvasID"),
  10. ctx = canvas.getContext("2d");
  11. // ctx.strokeStyle = "#000"; - граница
  12. ctx.fillStyle = color;
  13. ctx.beginPath();
  14. ctx.arc(x, y, r, 0, Math.PI*2, true);
  15. ctx.closePath();
  16. // ctx.stroke();
  17. ctx.fill();
  18. };
  19. };
  20. function Canvas() {
  21. this.add = function() {
  22. }
  23. };
  24. //------------------//
  25. // var line = new Line(50, 250, 200, 200, 'red'); // x1, y1, x2, y2, color
  26. var circle = new Circle(120, 100, 50, 'green'); // x, y, r, color
  27. circle.draw();
  28. // var rect = new Rect(260, 130, 60, 120, 'blue'); // x, y, w, h, color