Git Product home page Git Product logo

ashtrayshetty / js-canvas Goto Github PK

View Code? Open in Web Editor NEW
24.0 2.0 7.0 519 KB

:desktop_computer: MS-Paint for Windows98 (Remastered)

Home Page: http://jscanvas.epizy.com/

License: MIT License

HTML 12.94% CSS 5.14% JavaScript 81.92%
canvas drawing art ms-paint html5-canvas html-css-javascript frontend-app vanilla-javascript vanilla-js mspaint image-manipulation image-editor image-editing webapp js-canvas js

js-canvas's Introduction

JS Canvas

A little something I made to test my Javscript skills. Took me a lot of time though!! (Hope it was worth it ๐Ÿ˜ƒ).

IMPORTANT :
Please do note that the proper cursor image isn't visible for some features.

Motivation

There were two primary motivating factors :

There was also the added fact that I wanted to test how well I could do with only Vanilla Javascript.
I also wanted to learn how to work with HTML Canvas.

What is this project even?

This project was supposed to be a "remastered" version of MS Paint for Windows 98. But as I kept finishing up my work, I found out some rather unique behaviour for some of the functions. I decided to keep these and make this project my own and not just some remake/copy of some other project/product. The application might be buggy as there might be some bugs that I might not have come across. Feel free to raise an issue and I will look into it and probably try to resolve it.

Page Layout

A Screenshot of how the app looks!

Features / Functions

Here are the features and what they do :

1 Free Select :

Don't bother a lot about this one. Just deactivates all the other functions (couldn't come up with any other feature and the styling looked bad without the one button).

2 Clip :

This feature lets the user select a rectangular area and allows you to use other features inside this rectangular area (while this feature is selected).

3 Eraser :

Lets the user erase the drawing on the canvas. You can also increase/decrease the eraser size by pressing and holding the '+' and '-' buttons (respectively) on your numpad.

4 Fill Color :

Utilizes the flood-fill algorithm (iterative) to implement the fill bucket feature. Details about the algorithm can be found here.

5 Color Picker :

Lets the user select any color present on the canvas as their foreground color.

6 Magnify :

Zooms into the canvas allowing the user to closely (literally) examine and edit their drawing. The feature persists till the feature is deselected.

7 Pencil :

Draws a 1px "pencil-like drawing" over the canvas. Color of the pencil can be changed.

8 Brush :

Similar to pencil but gives you different brush sizes and shapes.

9 Airbrush :

Gives the airbrush type effect (similar to brush but it's a spray).

10 Text :

Lets the user enter (and then draw) text with many formatting options (bold, italics, underline, different font styles and sizes and colors).

11 Line :

Allows the user to draw a line from point A to point B 1px wide.

12 Curve :

User can enter the coordinates of the control points (their number depends on the length of the line expected to be drawn). Based on these coordinates, users can draw curves. For now, it's a prompt which asks for the coordinates since I've not been able to enable dragging the control points to change the curvature.

13 Rectangle :

Allows the user to draw a rectangle. Three types:

  • Transparent bordered :

    When drawn over another figure, that figure can be seen. Only a rectangle with the border with foreground color on the color pallete is drawn.

  • Opaque bordered :

    Similar to Transparent bordered. But when drawn over a figure, the figure is not visible. Instead, a fill color corresponding to the active background color selected in the color palleter is visible.

  • Fill Rectangle :

    Fills the rectangle drawn with the foreground color on the color pallete. No border for the rectangle.

14 Polygon :

Lets the user draw any type of polygon. Same 3 types of features as rectangle.

15 Ellipse :

Similar to rectangle feature, but an ellipse is drawn. Same three types of features.

16 Rounded Rectangle :

Similar to rectangle but the edges of the rectangle are rounded. Same three types as in the rectangle feature.

How can you contribute?

  • If you feel there is an issue that needs reporting, feel free to raise an issue.
  • If that issue has already been raised, encourage the discussion further so that it can come to my notice quickly.
  • If you feel that you can contribute to help resolve an issue, comment on the issue and I will look into the assigning roles part.
  • Fork the repository and create a new pull request to contribute for new features and/or improve existing ones.

License

This project was created under the MIT License.

js-canvas's People

Contributors

ashtrayshetty avatar david-webber 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

Watchers

 avatar  avatar

js-canvas's Issues

Draw image on canvas

On clicking File->Open, the user should be able to select an image on their computer. On selecting this image, it should be drawn on the canvas over which the user can work on.

Undo Redo feature

Enable undo (Ctrl+Z) and redo (Ctrl+Y) to restore the reverted states of the canvas.

Load the svg document using javascript

Currently for the airbrush feature, I have to make use of the svg xml stuff within the html document. This leads to reduced code readability and just too much unnecessary svg (html as considered by github lmao) code (spanning to 7000-8000 lines). Instead I would like if the svg could be loaded something like a file (blob or something) and then the manipulation could be done. Just something to reduce all the unnecessary clutter in the html file.

Improve styling

There's a lot of white spaces. Also, on zooming in, I would like if there's a scrolling portion of <canvas> and not the entire document. The canvas also overlaps the status bar on zooming.

Fill bucket feature doesn't work properly

The fill-feature, though somewhat optimized (speed and output wise), still has some issues:

  1. It ends up giving only a line (towards the right) on every click. This is problem especially for black color.
  2. It requires a few clicks before it actually fills the whole shape.
  3. Doesn't completely fill the whole canvas.

Luckily though, it works perfectly for very small shapes

A visual indicator of the cursor on using eraser feature

Currently, the output is displayed only on mouseup events. There is no visual indicator of how the output might look like. Although this is fine for features like line, rectangle, ellipse, etc; it's not fine for eraser feature. The user wouldn't know the size of the eraser on increasing or decreasing its size, i.e, they wouldn't know when to stop changing the size of the eraser (which could lead to dissatisfaction from some users).

Fix color selection for airbrush

When the foreground color is changed in the document (selected from the color palette), the color doesn't automatically update. Instead, you have to change the airbrush pattern(select a different spray size) to make the change in color happen. The issue is that I can't move the color change "function" into any of the canvas event handlers (just doesn't show anything).

Flood fill for "Invert Colors"

The Invert Colors option in the menu bar currently takes a lot of time to give an output (especially on larger screens). Because of this, the application gives the user an illusion that it has frozen and the user might quit the application, losing his/her progress.

A suggestion to this would be using the flood fill algorithm which is already being used in the fill bucket feature.
Here's a simple implementation of the algorithm.

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.