I am trying to create a meme generator similar to imgflip.com
I know javascript but not sure how to implement this.
I want users to be able to move text around the canvas using mousemove event listener.
But I am not sure if they are moving the text on the canvas or are they creating an overlay div then transform the dimension's to canvas?

Creating a meme generator sounds like a fun project! To allow users to move text around the canvas using the mousemove event, you'll want to directly manipulate the text within the canvas rather than using an overlay div.
See Example:

const canvas = document.getElementById('yourCanvasId');
const ctx = canvas.getContext('2d');

// User input and rendering
const userInput = 'Your Text Here';
ctx.fillText(userInput, x, y);  // Initial text rendering

// Mouse interaction
canvas.addEventListener('mousemove', (e) => {
  // Update text position based on mouse coordinates
  x = e.clientX - canvas.getBoundingClientRect().left;
  y = e.clientY - canvas.getBoundingClientRect().top;

  // Clear and redraw the canvas with the updated text position
  ctx.clearRect(0, 0, canvas.width, canvas.height);
  ctx.fillText(userInput, x, y);
});
commented: Thank you very much :) +10

Implement text movement on the canvas using mousemove. Update text position within the canvas for efficiency; avoid overlay divs. Aligns with the graphical nature of meme generation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.