GithubHelp home page GithubHelp logo

pengfeiw / react-paint Goto Github PK

View Code? Open in Web Editor NEW
116.0 4.0 17.0 1.18 MB

windows 画板 —— Microsoft Paint

Home Page: https://pengfeiw.github.io/minicode/react-paint

License: MIT License

JavaScript 2.14% HTML 1.16% TypeScript 87.38% Less 9.29% Shell 0.02%
reactjs paint canvas typescript react

react-paint's Introduction

React Paint

中文说明

Microsoft Paint realized with reactjs.

online: https://pengfeiw.github.io/minicode/react-paint

Microsoft Paint

Feature

Support mouse and touch screen, so you can use it with IPad.

  • pen
  • eraser
  • fill
  • change color
  • change linewidth
  • many shapes
  • two linestyle: solid and dot
  • redo and undo
  • extract color

Run in local

  • clone repository: git clone https://github.com/pengfeiw/react-paint.git
  • install package: npm install
  • start server: npm run start
  • open in browser:http://localhost:3000

Technique

  • TypeScript
  • React
  • Material-UI
  • 2D drawing with canvas

Has issue?

If you run into any problems, you can leave a message in <<react实现简易画板程序>> or commit an issue.

More fun and interesting things, visit minicode.

react-paint's People

Contributors

pengfeiw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-paint's Issues

Resize issue on canvas

Image is clipped when resize window.

How to replicate the issue:

  1. Draw a image like screenshot-1
  2. Adjust the window to small one
  3. Then the original image will be clipped like screenshot-2

my suggestion as below:

      window.addEventListener('resize', () => {
        // Get current snapshot
        const currentSnapshot = snapshot.current;
        // Create dummy canvas, then draw current snapshot
        const dummyCanvas = document.createElement('canvas');
        const dummyCanvasCtx = dummyCanvas.getContext('2d');
        dummyCanvas.width = currentSnapshot.width;
        dummyCanvas.height = currentSnapshot.height;
        if (dummyCanvasCtx) {
          dummyCanvasCtx.putImageData(currentSnapshot, 0, 0);
        }
        // Redraw to Resized canvas
        canvas.height = canvas.clientHeight;
        canvas.width = canvas.clientWidth;
        Tool.ctx.drawImage(dummyCanvas, 0, 0, dummyCanvas.width, dummyCanvas.height, 0, 0, canvas.width, canvas.height);
      });

screenshot-1

screenshot-2

Filling issue

Will leave some weird edge after filling.

How to replicate:

  1. Fill the whole background with green color, refer to: screenshot-1
  2. Draw a circle with red color, refer to: screenshot-2
  3. Fill red color inside the circle, refer to: screenshot-3
  4. Fill red color outside the circle, refer to: screenshot-4

By right all the canvas will the in red color, but actually not.

Could you help on this?
Thank you.

screenshot-1

screenshot-2

screenshot-3

screenshot-4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.