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

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