Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 1700

General Questions/New to Joomla! 5.x • Re: Write on photos

$
0
0
Writing in pencil on the photo would involve several steps, to upload/display the photo, etc. Adding more colors makes it again more difficult, to get you started with the drawing, here are some codes:

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

let drawing = false;

// Function to start drawing
canvas.addEventListener('mousedown', (event) => {
drawing = true;
ctx.beginPath();
ctx.moveTo(event.offsetX, event.offsetY);
});

// Function to draw on the canvas
canvas.addEventListener('mousemove', (event) => {
if (drawing) {
ctx.lineTo(event.offsetX, event.offsetY);
ctx.stroke();
}
});

// Function to stop drawing
canvas.addEventListener('mouseup', () => {
drawing = false;
ctx.closePath();
});

// Optionally, clear the canvas
function clearCanvas() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
}

Statistics: Posted by Euol — Tue Aug 06, 2024 8:15 am



Viewing all articles
Browse latest Browse all 1700

Trending Articles