Skip to main content

Make Paint website

 Copy HTML Code of Paint Website and host it on your website.

<html lang="en">
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
  <title>
   Paint App
  </title>
  <script src="https://cdn.tailwindcss.com">
  </script>
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet"/>
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&amp;display=swap" rel="stylesheet"/>
  <style>
   .canvas-container {
    position: relative;
   }
   .canvas-container canvas {
    border: 1px solid #ccc;
    border-radius: 8px;
   }
  </style>
 </head>
 <body class="bg-gray-100 font-roboto">
  <div class="container mx-auto p-4">
   <header class="flex justify-between items-center py-4">
    <h1 class="text-3xl font-bold">
     Paint App
    </h1>
   </header>
   <div class="flex justify-between items-center my-4">
    <img alt="Ad banner 90x728" class="hidden lg:block" height="728" src="https://storage.googleapis.com/a1aa/image/SpBbD2zxxQ8OCPmrY_XfopjOMG1qF88fnsoCZyfFCHU.jpg" width="90"/>
    <div class="flex-grow mx-4">
     <div class="bg-white shadow-md rounded-lg p-4">
      <div class="flex justify-between items-center mb-4">
       <div class="flex space-x-2">
        <button class="p-2 bg-gray-200 rounded hover:bg-gray-300" id="brush-tool">
         <i class="fas fa-paint-brush">
         </i>
        </button>
        <button class="p-2 bg-gray-200 rounded hover:bg-gray-300" id="eraser-tool">
         <i class="fas fa-eraser">
         </i>
        </button>
        <input class="p-2 bg-gray-200 rounded hover:bg-gray-300" id="color-picker" type="color"/>
        <input class="p-2 bg-gray-200 rounded hover:bg-gray-300" id="pen-size" max="50" min="1" type="range" value="5"/>
        <button class="p-2 bg-gray-200 rounded hover:bg-gray-300" id="undo-tool">
         <i class="fas fa-undo">
         </i>
        </button>
        <button class="p-2 bg-gray-200 rounded hover:bg-gray-300" id="redo-tool">
         <i class="fas fa-redo">
         </i>
        </button>
       </div>
       <div class="flex space-x-2">
        <button class="p-2 bg-gray-200 rounded hover:bg-gray-300" id="save-tool">
         <i class="fas fa-save">
         </i>
        </button>
        <button class="p-2 bg-gray-200 rounded hover:bg-gray-300" id="clear-tool">
         <i class="fas fa-trash">
         </i>
        </button>
       </div>
      </div>
      <div class="canvas-container">
       <canvas height="400" id="paint-canvas" width="800">
       </canvas>
      </div>
     </div>
    </div>
    <img alt="Ad banner 90x728" class="hidden lg:block" height="728" src="https://storage.googleapis.com/a1aa/image/SpBbD2zxxQ8OCPmrY_XfopjOMG1qF88fnsoCZyfFCHU.jpg" width="90"/>
   </div>
  </div>
  <script>
   const canvas = document.getElementById('paint-canvas');
const ctx = canvas.getContext('2d');
let painting = false;
let penColor = '#000000';
let penSize = 5;
let history = [];
let historyStep = -1;

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

function endPosition() {
  painting = false;
  ctx.beginPath();
  if (historyStep < history.length - 1) {
    history = history.slice(0, historyStep + 1);
  }
  history.push(canvas.toDataURL());
  historyStep++;
}

function draw(e) {
  if (!painting) return;
  ctx.lineWidth = penSize;
  ctx.lineCap = 'round';
  ctx.strokeStyle = penColor;

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

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

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

canvas.addEventListener('touchstart', startPosition);
canvas.addEventListener('touchend', endPosition);
canvas.addEventListener('touchmove', draw);

document.getElementById('color-picker').addEventListener('change', (e) => {
  penColor = e.target.value;
});

document.getElementById('pen-size').addEventListener('change', (e) => {
  penSize = e.target.value;
});

document.getElementById('brush-tool').addEventListener('click', () => {
  penColor = document.getElementById('color-picker').value;
});

document.getElementById('eraser-tool').addEventListener('click', () => {
  penColor = '#FFFFFF';
});

document.getElementById('undo-tool').addEventListener('click', () => {
  if (historyStep > 0) {
    historyStep--;
    let canvasPic = new Image();
    canvasPic.src = history[historyStep];
    canvasPic.onload = () => {
      ctx.clearRect(0, 0, canvas.width, canvas.height);
      ctx.drawImage(canvasPic, 0, 0);
    };
  }
});

document.getElementById('redo-tool').addEventListener('click', () => {
  if (historyStep < history.length - 1) {
    historyStep++;
    let canvasPic = new Image();
    canvasPic.src = history[historyStep];
    canvasPic.onload = () => {
      ctx.clearRect(0, 0, canvas.width, canvas.height);
      ctx.drawImage(canvasPic, 0, 0);
    };
  }
});

document.getElementById('save-tool').addEventListener('click', () => {
  const link = document.createElement('a');
  link.download = 'painting.png';
  link.href = canvas.toDataURL();
  link.click();
});

document.getElementById('clear-tool').addEventListener('click', () => {
  ctx.clearRect(0, 0, canvas.width, canvas.height);
  history = [];
  historyStep = -1;
});
  </script>
 </body>
</html>

Comments

Popular posts from this blog

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 - ...

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 ...

Make $100 Online TODAY (EASY Method) [2024] | EARN MONEY

Would You like to earn $100 Per day? You should read this full articles. Because I am going to share with you best and trusted platform to earn your first and fast $100 today. Make $100 Online TODAY (EASY Method) [2024] | EARN MONEY You can see payments proof, All these people are cashing out their money every single day. You can earn up to $100 daily with this platform. This platform's name is shrtfly.com  . This is amazing platform. This platform is available worldwide so no matter what country you are in. You can use this platform to make money online. shrtfly platform have 1 Million Publishers. This platform show clean ads only. You can not get virus , Malware and adult type ads. It's a AdSense Compatible Platform.  How to earn $100 per day with shrtfly platform. You can Visit on these platform like mxplayer.in , YouTube.com, bilibili, Facebook or any social media platform and then copy URL Of that movies and reel. You can also copy website url. watch full tutorial ab...