Skip to main content

html code for paint application

 Use This HTML Code to make Paint Application. Copy this code and visit on appcreator24/webintoapp platform to make application.


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Paint Application</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"></link>
    <style>
        #canvas {
            border: 1px solid #000;
        }
    </style>
</head>
<body class="bg-gray-100 flex flex-col items-center justify-center min-h-screen">
    <div class="bg-white p-4 rounded shadow-md w-full max-w-4xl">
        <h1 class="text-2xl font-bold mb-4 text-center">Paint Application</h1>
        <div class="flex justify-between items-center mb-4">
            <div class="flex space-x-2">
                <button id="clear" class="bg-red-500 text-white px-4 py-2 rounded">Clear</button>
                <input type="color" id="colorPicker" class="border rounded p-1">
                <select id="brushSize" class="border rounded p-1">
                    <option value="2">2px</option>
                    <option value="4">4px</option>
                    <option value="6">6px</option>
                    <option value="8">8px</option>
                    <option value="10">10px</option>
                </select>
                <button id="erase" class="bg-gray-500 text-white px-4 py-2 rounded"><i class="fas fa-eraser"></i></button>
            </div>
            <div>
                <button id="save" class="bg-green-500 text-white px-4 py-2 rounded">Save</button>
            </div>
        </div>
        <div class="flex justify-center">
            <canvas id="canvas" width="800" height="600" class="bg-white"></canvas>
        </div>
    </div>

    <script>
        const canvas = document.getElementById('canvas');
        const ctx = canvas.getContext('2d');
        const clearButton = document.getElementById('clear');
        const colorPicker = document.getElementById('colorPicker');
        const brushSize = document.getElementById('brushSize');
        const saveButton = document.getElementById('save');
        const eraseButton = document.getElementById('erase');

        let painting = false;
        let color = '#000000';
        let lineWidth = 2;
        let erasing = false;

        canvas.addEventListener('mousedown', startPosition);
        canvas.addEventListener('mouseup', endPosition);
        canvas.addEventListener('mousemove', draw);

        canvas.addEventListener('touchstart', startTouch, false);
        canvas.addEventListener('touchend', endTouch, false);
        canvas.addEventListener('touchmove', drawTouch, false);

        clearButton.addEventListener('click', clearCanvas);
        colorPicker.addEventListener('input', changeColor);
        brushSize.addEventListener('change', changeBrushSize);
        saveButton.addEventListener('click', saveCanvas);
        eraseButton.addEventListener('click', toggleEraser);

        function startPosition(e) {
            painting = true;
            draw(e);
        }

        function endPosition() {
            painting = false;
            ctx.beginPath();
        }

        function draw(e) {
            if (!painting) return;

            const rect = canvas.getBoundingClientRect();
            const x = e.clientX - rect.left;
            const y = e.clientY - rect.top;

            ctx.lineWidth = lineWidth;
            ctx.lineCap = 'round';
            ctx.strokeStyle = erasing ? '#FFFFFF' : color;

            ctx.lineTo(x, y);
            ctx.stroke();
            ctx.beginPath();
            ctx.moveTo(x, y);
        }

        function startTouch(e) {
            e.preventDefault();
            painting = true;
            drawTouch(e);
        }

        function endTouch(e) {
            e.preventDefault();
            painting = false;
            ctx.beginPath();
        }

        function drawTouch(e) {
            e.preventDefault();
            if (!painting) return;

            const rect = canvas.getBoundingClientRect();
            const touch = e.touches[0];
            const x = touch.clientX - rect.left;
            const y = touch.clientY - rect.top;

            ctx.lineWidth = lineWidth;
            ctx.lineCap = 'round';
            ctx.strokeStyle = erasing ? '#FFFFFF' : color;

            ctx.lineTo(x, y);
            ctx.stroke();
            ctx.beginPath();
            ctx.moveTo(x, y);
        }

        function clearCanvas() {
            ctx.clearRect(0, 0, canvas.width, canvas.height);
        }

        function changeColor(e) {
            color = e.target.value;
            erasing = false;
        }

        function changeBrushSize(e) {
            lineWidth = e.target.value;
        }

        function toggleEraser() {
            erasing = !erasing;
        }

        function saveCanvas() {
            const link = document.createElement('a');
            link.download = 'painting.png';
            link.href = canvas.toDataURL();
            link.click();
        }
    </script>
</body>
</html>

Comments

Popular posts from this blog

Earn Money From Google AdMob ( Make Money Online 2024 ) | PASSIVE INCOME 2024

Earn Passive Money From Google AdMob ( Make Money Online ) |  https://cpamarketingbeginners.blogspot.com/ Admob Earnings Earn Instantly Hundreds of dollars without doing hard work with Google AdMob. Google Ad Mob is a Google's Product. AdMob is A Just like AdSense. You can Earn Money From Your Website and YouTube Channel Using AdSense. But if you want to earn money from Your app and Game then you can Use AdMob.  Google Run Ads on Website, YouTube Channel, App and Game Application. when Someone Clicks on that ads then You can Earn money. You can Earn $1 - $5 only on one Click.  Earning depends on Traffic quality and Category. If you have made your website, YouTube Channel or App on Business category and If you are getting traffic from United states, United kingdom, Canada, Germany.... then you can earn high amount of money. In this article, I am going to share with you how you can earn money from admob. read this full article. Guys, First of all you will have to make game ...

Submit Your Website on all Search Engines to get Traffic on your website

  Submit Your Website on all Search Engines to get Traffic on your website In this article, I'm going to give you 63 Big Search engines to submit your website. after submit your website on these Search engines your website can Instantly start to get lots of traffic. you will have to submit your website on all search engines. if you will not submit your website on search engines then your website will not show in Search results.  yandex search engines like when someone will try to search your website on Google then your website will not show in search result. you will have to submit your website on Google Console. similarly I have collected all search Engines to submit your website and get free lots of traffic. read this full articles. 63+ Search Engines that I have collected to submit your website and get over 500K free traffic instantly Today..   Check out all these search engines -  1 -  ASR (Active Search Results ) 2 -  Google 3-  Amidalla 4 - ...

CrakRevenue Tutorials for Beginners ( Earn Money Online in 2024 )

Best and High paying Crakrevenue Affiliate Network. (CrakRevenue Tutorials for Beginners) In this article, I'm going to share with you best crakrevenue earning methods. it's for completely beginners. You can start making money from today. i will also share with you my crakrevenue earnings . Read this full articles.  (CrakRevenue Tutorials for Beginners) First of all you will have to create account on crakrevenue affiliate network. after that you can promote high paying cpa offers. Crakrevenue cpa offers you can promote Jerkmate cpa offers. when someone will click on this Jerkmate cpa offer and sign up after that they will verify their email address then you will earn $7.50 per sign up. as you can see in the Image. this offer is DOI. That means Sign up + Confirm Email address. suppose if it will be SOI Offers then you just need to generate only Sign up. when someone will just sign up then you can earn. (CrakRevenue Tutorials for Beginners) Next step you will have to create ...