Calculator Tools Calculator Tools
Create

Quick! Draw! App

Nov 12, 2023

About this app

A fun single-page web app where the AI guesses what you draw.

Quick! Draw! App 🔍 Guess My Drawing! 📤 Upload My Drawing!

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>Quick! Draw! App</title>
<meta name="description" content="A fun single-page web app where the AI guesses what you draw.">
<meta name="keywords" content="AI, Draw, Fun, Art">

<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 {
var canvas, context, tool;
var img;

function init() {
canvas = document.getElementById('canvas');
context = canvas.getContext('2d');

tool = new tool_pencil();
canvas.addEventListener('mousedown', ev_canvas, false);
canvas.addEventListener('mousemove', ev_canvas, false);
canvas.addEventListener('mouseup', ev_canvas, false);
}

function tool_pencil() {
var tool = this;
this.started = false;

this.mousedown = function (ev) {
context.beginPath();
context.moveTo(ev._x, ev._y);
tool.started = true;
};

this.mousemove = function (ev) {
if (tool.started) {
context.lineTo(ev._x, ev._y);
context.stroke();
}
};

this.mouseup = function (ev) {
if (tool.started) {
tool.mousemove(ev);
tool.started = false;
}
};
}

function ev_canvas(ev) {
if (ev.layerX || ev.layerX == 0) {
ev._x = ev.layerX;
ev._y = ev.layerY;
}

var func = tool[ev.type];
if (func) {
func(ev);
}
}

function saveImage() {
img = canvas.toDataURL("image/png");
}

function uploadImage() {
alert("Sorry, this feature is not available in the offline version of the app.");
}

document.addEventListener("DOMContentLoaded", function() {
init();
});

} catch (error) {
throw error;
}
</script>

<style>
body, canvas { cursor: crosshair; }
canvas { border: 1px solid #000; }
</style>
</head>
<body>
<div id="main-container" class="container">
<canvas id="canvas" width="800" height="600"></canvas>
<br/>
<button onclick="saveImage()">🔍 Guess My Drawing!</button>
<button onclick="uploadImage()">📤 Upload My Drawing!</button>
</div>
</body>
</html>