Calculator Tools Calculator Tools
Create

Drawing App

Jan 5, 2024

About this app

A fun and interactive drawing app

Drawing App Drawing App Clear Drawing Credits: Developed by Your Name

Related apps

Put this on your site

Source

                    <html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>Drawing App</title>
<meta name="description" content="A fun and interactive drawing app">
<meta name="keywords" content="drawing, app, game, colors, paint">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script type="text/javascript">
try {
// App Javascript Goes Here. Place your entire script content inside the try block for error handling.

let color = 'black';

// Function to change the color
function changeColor(newColor) {
color = newColor;
}

// Function to clear the drawing
function clearDrawing() {
$('.drawing-canvas').empty();
}

// This will run when the DOM is ready.
document.addEventListener("DOMContentLoaded", function () {
// Add event listener to the drawing canvas
$('.drawing-canvas').on('click', function (event) {
const x = event.pageX - $(this).offset().left;
const y = event.pageY - $(this).offset().top;

$(this).append(`<div class="drawn-point" style="left: ${x}px; top: ${y}px; background-color: ${color};"></div>`);
});
});

} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>

<style>
/* App CSS Goes Here */
.drawing-canvas {
position: relative;
width: 100%;
height: 400px;
background-color: white;
border: 2px solid black;
margin-bottom: 20px;
}

.drawn-point {
position: absolute;
width: 10px;
height: 10px;
border-radius: 50%;
}

.color-selector {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
}

.color-selector button {
width: 30px;
height: 30px;
border-radius: 50%;
border: none;
cursor: pointer;
}

.clear-button {
margin-bottom: 20px;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>Drawing App</h1>
<div class="drawing-canvas"></div>
<div class="color-selector">
<button style="background-color: black" onclick="changeColor('black')"></button>
<button style="background-color: red" onclick="changeColor('red')"></button>
<button style="background-color: blue" onclick="changeColor('blue')"></button>
<button style="background-color: green" onclick="changeColor('green')"></button>
<button style="background-color: yellow" onclick="changeColor('yellow')"></button>
</div>
<button class="clear-button" onclick="clearDrawing()">Clear Drawing</button>
<h3>Credits:</h3>
<p>Developed by Your Name</p>
</div>
</body>
</html>