jspaint/README.md

184 lines
10 KiB
Markdown
Raw Normal View History

2014-05-30 07:00:01 +00:00
# [![](images/icons/32x32.png) JS Paint](https://jspaint.app)
2014-09-22 10:13:18 +00:00
2018-06-29 04:22:50 +00:00
A nice web-based MS Paint remake and more... [Try it out!](https://jspaint.app)
2015-10-19 19:11:10 +00:00
The goal is to remake MS Paint
(including its [little-known features](#did-you-know)),
2019-12-16 06:49:57 +00:00
improve on it, and to extend the types of images it can edit.
2014-10-28 23:09:27 +00:00
So far, it does this pretty well.
2018-06-13 02:37:33 +00:00
![Screenshot](images/meta/main-screenshot.png)
2015-02-24 00:39:43 +00:00
2015-10-19 19:11:10 +00:00
Ah yes, good old paint. Not the one with the [ribbons][]
or the [new skeuomorphic one][Fresh Paint] with the interface that can take up nearly half the screen.
2019-11-10 16:38:06 +00:00
(And not the even newer [Paint 3D][].)
2017-06-02 04:59:44 +00:00
[ribbons]: https://www.google.com/search?tbm=isch&q=MS+Paint+Windows+7+ribbons "Google Search: MS Paint Windows 7 ribbons"
[Fresh Paint]: https://www.google.com/search?tbm=isch&q=MS+Fresh+Paint "Google Search: MS Fresh Paint"
[Paint 3D]: https://www.microsoft.com/en-us/store/p/paint-3d-preview/9nblggh5fv99
2015-10-19 19:11:10 +00:00
Windows 95, 98, and XP were the golden years of paint.
You had a tool box and a color box, a foreground color and a background color,
and that was all you needed.
Things were simple.
But we want to undo more than three actions.
We want to edit transparent images.
We can't just keep using the old paint.
So that's why I'm making JS Paint.
I want to bring good old paint into the modern era.
2014-08-10 03:06:33 +00:00
2014-09-29 01:19:48 +00:00
#### Current improvements include:
2018-01-22 07:46:27 +00:00
* Cross-platform
2014-10-28 23:09:27 +00:00
* Unlimited undos/redos (as opposed to a measly 3 in Windows XP,
2018-01-22 07:46:27 +00:00
or a measly 50 in Windows 7)
2020-04-19 04:06:20 +00:00
* Undo history is *nonlinear*, which means if you undo and do something other than redo, the redos aren't discarded. Instead, a new branch is created in the *history tree*. Jump to any point in history with **Edit > History** or <kbd>Ctrl+Shift+Y</kbd>
2019-12-20 17:52:57 +00:00
* Automatically keeps a backup of your image. Only one backup per image tho, which doesn't give you a lot of safety. Remember to save with **File > Save** or <kbd>Ctrl+S</kbd>! Manage backups with **File > Manage Storage**.
* Edit transparent images! To create a transparent image,
2018-06-29 06:14:31 +00:00
go to **Image > Attributes...** and select Transparent,
2020-12-05 22:21:20 +00:00
then OK, and then **Image > Clear Image** or use the Eraser tool.
2019-10-03 19:54:20 +00:00
Images with *any* translucent pixels will open in Transparent mode.
2020-05-30 09:57:20 +00:00
* Switch themes from the Extras menu. Dark mode included.
* [Vertical Color Box mode](https://jspaint.app/#vertical-color-box-mode), accessible from **Extras > Vertical Color Box**
* [Eye Gaze Mode](https://jspaint.app/#eye-gaze-mode), for use with an eye tracker, head tracker, or other coarse input device, accessible from **Extras > Eye Gaze Mode**. (With just a webcam, you can try it out with [Enable Viacam](https://eviacam.crea-si.com/) (head tracker) or [GazePointer](https://sourceforge.net/projects/gazepointer/) (eye tracker).)
* [Speech Recognition Mode](https://jspaint.app/#speech-recognition-mode).
Using your voice you can select tools and colors, pan the view ("scroll down and to the left", or "go southwest", etc.), explore the menus (but you can activate any menu item without opening the menus first), interact with windows (including scrolling the history view with "scroll up"/"scroll down" etc.), dictate text with the Text tool, and even tell the application to sketch things (for instance, "draw a house")
2018-01-22 07:46:27 +00:00
* Create an animated GIF from the current document history.
Accessible from the Extras menu or with <kbd>Ctrl+Shift+G</kbd>.
It's pretty nifty, you should try it out!
You might want to limit the size of the image though.
2020-05-30 09:57:20 +00:00
* You can shoot at the application [Asteroids style](https://kickassapp.com/)
2019-10-03 19:54:20 +00:00
* When you do **Edit > Paste From...** you can select transparent images.
2015-02-24 00:39:43 +00:00
~~You can even paste a transparent animated GIF and then
hold <kbd>Shift</kbd> while dragging the selection to
2015-02-24 00:39:43 +00:00
smear it across the canvas *while it animates*!~~
Update: This was [due to not-to-spec behavior in Chrome.](https://christianheilmann.com/2014/04/16/browser-inconsistencies-animated-gif-and-drawimage/)
2015-02-24 00:39:43 +00:00
I may reimplement this in the future as I really liked this feature.
2019-12-16 06:49:57 +00:00
* You can open SVG files, though only as a bitmap.
2020-04-19 04:06:20 +00:00
(Note: it may open super large, or tiny. There's no option to choose a size when opening.)
* You can crop the image by making a selection while holding <kbd>Ctrl</kbd>
2018-06-29 06:14:31 +00:00
* Keyboard shortcuts for rotation: <kbd>Ctrl+.</kbd> and <kbd>Ctrl+,</kbd> (<kbd><</kbd> and <kbd>></kbd>)
* Rotate by any arbitrary angle in **Image > Flip/Rotate**
* In **Image > Stretch/Skew**, you can stretch more than 500% at once
2019-10-03 19:54:20 +00:00
* Zoom to an arbitrary scale in **View > Zoom > Custom...**
2020-05-30 09:57:20 +00:00
* Zoom to fit the canvas within the window with **View > Zoom > Zoom To Window**
2019-10-03 19:54:20 +00:00
* Non-contiguous fill: Replace a color in the entire image by holding <kbd>Shift</kbd> when using the fill tool
2019-12-08 00:24:50 +00:00
* You can use the Text tool at any zoom level, and it previews the exact pixels that will end up on the canvas.
* Spellcheck is available in the textbox if your browser supports it.
2018-01-22 07:46:27 +00:00
* Rudimentary **multi-user** support.
Start up a session at
2018-06-09 18:51:14 +00:00
[jspaint.app/#session:multi-user-test](https://jspaint.app/#session:multi-user-test)
and send the link to your friends!
2018-01-22 07:46:27 +00:00
It isn't seamless; actions by other users interrupt what you're doing, and visa versa.
Sessions are not private, and you may lose your work at any time.
If you want better collaboration support, follow the development of [Mopaint](https://github.com/1j01/mopaint).
2018-06-29 06:14:31 +00:00
* Load many different palette formats with **Colors > Get Colors**.
2018-01-22 07:46:27 +00:00
(I made a [library](https://github.com/1j01/palette.js/) for this.)
2020-04-19 04:06:20 +00:00
* Touch support: use two fingers to pan the view.
2015-06-22 00:01:12 +00:00
* Click/tap the selected colors area to swap the foreground and background colors
2018-06-13 02:37:33 +00:00
![JS Paint drawing of JS Paint on a phone](images/meta/mobipaint.png)
2014-05-30 07:00:01 +00:00
#### Limitations:
2014-09-22 10:13:18 +00:00
2019-12-16 06:49:57 +00:00
A few things with the tools aren't done yet.
See [TODO.md](TODO.md#Tools)
2014-09-22 10:13:18 +00:00
Full clipboard support in the web app requires a browser supporting the [Async Clipboard API w/ Images](https://developers.google.com/web/updates/2019/07/image-support-for-async-clipboard), namely Chrome 76+ at the time of writing.
In other browsers you can still can copy with <kbd>Ctrl+C</kbd>, cut with <kbd>Ctrl+X</kbd>, and paste with <kbd>Ctrl+V</kbd>,
2014-11-25 05:39:16 +00:00
but data copied from JS Paint can only be pasted into other instances of JS Paint.
External images can be pasted in.
2018-08-24 22:42:37 +00:00
2014-05-30 07:00:01 +00:00
## Did you know?
2014-08-10 03:06:33 +00:00
2018-06-29 06:14:31 +00:00
* There's a black and white mode with *patterns* instead of colors in the palette,
which you can get to from **Image > Attributes...**
2014-10-28 23:09:27 +00:00
* You can drag the color box and tool box around if you grab them by the right place.
2015-02-24 00:39:43 +00:00
You can even drag them out into little windows.
2017-06-02 04:59:44 +00:00
You can dock the windows back to the side by double-clicking on their title bars.
2014-10-28 23:09:27 +00:00
* In addition to the left-click foreground color and the right-click background color,
2018-01-22 07:46:27 +00:00
there's a third color you can access by holding <kbd>Ctrl</kbd> while you draw.
2014-10-28 23:09:27 +00:00
It starts out with no color so you'll need to hold <kbd>Ctrl</kbd> and select a color first.
2018-01-22 07:46:27 +00:00
The fancy thing about this color slot is you can
2019-10-28 18:46:03 +00:00
press and release <kbd>Ctrl</kbd> to switch colors *while drawing*.
2014-10-28 23:09:27 +00:00
2018-01-22 07:46:27 +00:00
* You can apply image transformations like Flip/Rotate, Stretch/Skew or Invert (in the Image menu) either to the whole image or to a selection.
2019-10-28 18:46:03 +00:00
Try scribbling with the Free-Form Select tool and then doing **Image > Invert**
2014-12-08 02:45:23 +00:00
* These Tips and Tricks from [a tutorial for MS Paint](https://www.albinoblacksheep.com/tutorial/mspaint)
2019-10-28 18:46:03 +00:00
also work in JS Paint:
2014-02-07 02:47:16 +00:00
2014-09-22 10:13:18 +00:00
* [x] Brush Scaling (<kbd>+</kbd> & <kbd>-</kbd> on the Numpad to adjust brush size)
* [x] "Custom Brushes" (hold <kbd>Shift</kbd> and drag the selection to smear it)
* [x] The 'Stamp' "Tool" (hold <kbd>Shift</kbd> and click the selection to stamp it)
* [x] Image Scaling (<kbd>+</kbd> & <kbd>-</kbd> on the Numpad to scale the selection by factors of 2)
2018-01-22 07:46:27 +00:00
* [x] Color Replacement (right mouse button with Eraser to selectively replace the foreground color with the background color)
2019-09-30 15:56:07 +00:00
* [x] The Grid (<kbd>Ctrl+G</kbd> & Zoom to 4x+)
2019-09-29 03:16:51 +00:00
* [x] Quick Undo (Pressing a second mouse button cancels the action you were performing.
I also made it redoable, in case you do it by accident!)
2015-06-15 23:50:31 +00:00
* [ ] Scroll Wheel Bug (Hmm, let's maybe not recreate this?)
2014-10-24 00:54:05 +00:00
2018-08-24 22:42:37 +00:00
## Desktop App
2020-04-19 04:06:20 +00:00
JS Paint can be installed as a PWA, altho it doesn't work offline.
2018-08-24 22:42:37 +00:00
2020-04-19 04:06:20 +00:00
(Also I made some effort to build it into a desktop app with [Electron][] and [Electron Forge][], but this will use unnecessary system resources and is not recommended. See [this issue](https://github.com/1j01/jspaint/issues/2).)
2018-08-24 22:42:37 +00:00
[Electron]: https://electronjs.org/
[Electron Forge]: https://electronforge.io/
2018-06-10 03:50:03 +00:00
## Development Setup
[Clone the repo.](https://help.github.com/articles/cloning-a-repository/)
2018-08-24 22:42:37 +00:00
Install [Node.js][] if you don't have it, then open up a command prompt / terminal in the project directory.
2019-11-10 16:38:06 +00:00
### Testing
Run `npm run lint` to check for code problems.
Run `npm test` to run browser-based tests with Cypress. (It's slow to start up and run tests, unfortunately.)
2018-08-24 22:42:37 +00:00
2019-11-10 16:38:06 +00:00
Run `npm run accept` to accept any visual changes.
This unfortunately re-runs all the tests, rather than accepting results of the previous test, so you could end up with different results than the previous test.
If you use [GitHub Desktop](https://desktop.github.com/), you can view diffs of images, in four different modes.
2018-06-10 03:50:03 +00:00
2019-11-10 16:38:06 +00:00
To open the Cypress UI, first run `npm run test:start-server`, then concurrently `npm run cy:open`
Tests are also run in continuous integration [with Travis CI](https://travis-ci.org/1j01/jspaint).
### Web App (https://jspaint.app)
2018-08-24 22:42:37 +00:00
2019-11-10 16:38:06 +00:00
You just need an HTTP server, but [Live Server][] is recommended. It auto reloads when you save changes.
2018-08-24 22:42:37 +00:00
2019-11-10 16:38:06 +00:00
It's included in `package.json` so if you've installed dependencies (`npm i`) you can use `npm run dev` to run it.
(It's configured to ignore some files/directories for reloading.)
2018-08-24 22:42:37 +00:00
### Desktop App (Electron)
2020-04-19 04:06:20 +00:00
This is unreleased and not in development.
2018-08-24 22:42:37 +00:00
- Install dependencies with `npm i`
- Start the electron app with `npm start`
2019-11-10 16:38:06 +00:00
[electron-debug][] and [devtron][] are included, so you can use <kbd>Ctrl+R</kbd> to reload and <kbd>F12</kbd>/<kbd>Ctrl+Shift+I</kbd> to open the devtools, and there's a Devtron tab with tools specific to Electron.
2018-06-10 03:50:03 +00:00
2018-08-24 22:42:37 +00:00
You can build for production with `npm run make`
2018-06-10 03:50:03 +00:00
[Live Server]: https://github.com/tapio/live-server
2018-08-24 22:42:37 +00:00
[Node.js]: https://nodejs.org/
[electron-debug]: https://github.com/sindresorhus/electron-debug
[devtron]: https://electronjs.org/devtron