RAF

Joined
Jul 10, 2022
Messages
1
Reaction score
0
JavaScript:
`var id = document.getElementById('canvas');

var ctx = id.getContext('2d');





!((_rAF) => {

      function render() {

  window.requestAnimationFrame = (cb) => {

    _rAF((t) => {

    ctx.beginPath();

    ctx.moveTo(75, 50);

    ctx.lineTo(100, 75);

    ctx.lineTo(100, 50);

    ctx.fillStyle = "#643A9C";

    ctx.fill();

      cb(t);

      render();

    })

  }

      }

})(window.requestAnimationFrame);
so im trying to make a rAF triangle thing here. However the triangle doesn't render. What can I do to fix it?
 
Joined
Jul 24, 2022
Messages
1
Reaction score
0
a smaller version seems to work ok...
Code:
function draw() {
    const canvas = document.getElementById('canvas');
    const ctx    = canvas.getContext('2d');   
    ctx.beginPath();
    ctx.moveTo(75, 50);
    ctx.lineTo(100, 75);
    ctx.lineTo(100, 50);
    ctx.fillStyle = "#643A9C";
    ctx.fill();   
};
draw();

do you have the correct canvas element, not a div?
<canvas id="canvas"></canvas>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,808
Messages
2,569,684
Members
45,446
Latest member
TeddyScull

Latest Threads

Top