Giter VIP home page Giter VIP logo

poormanspaint's Introduction

Poor Man's MSPaint v1.0

This is a simple vector drawing application written in Java/Swing. It supports drawing lines, circles, ellipses, rectangles, squares and isosceles triangles in various colours as well as exporting drawing to jpg, among other features.

I developed this for the third coursework of the CS5001 Object Oriented Programming and Modelling module at the University of St Andrews. I scored 18 out of 20 on it.

For the complete coursework specifications, please refer to CS5001_P3_Vector_Drawing.pdf.

How to compile and run

From the parent/root directory of this project do the following:

If the bin folder does not exist, create it with:

mkdir bin

then run javac as follows:

javac -cp 'lib/junit-4.13.2.jar:lib/javax.json-1.0.jar' -d bin/ $(find src/ -name '*.java')

This will find all the .java files inside the src directory and compile them to the bin directory using the neccessary libraries specfied in lib.

If you then change to the bin directory with:

cd bin

you can then run the app using:

java Main

Running the tests

  • The tests I've written are very basic and I admit that.

  • I used JUnit v4 and it works if you import the project into VSCode and use the Java Extension Manager.

General info

  • Drawing squares and circles is implemented by pressing down the SHIFT key while dragging to create a rectangle or an ellipse.

  • Selecting a previously drawn object is implemented by turning on "Select mode" at the bottom right corner of the app and then picking an object from the canvas using the mouse cursor.

  • The rotation and scale of an object can only be changed while Select Mode is on. Two spinners will appear at the bottom left once you enable select mode that will allow you to change the rotation and scale after you select a shape with the mouse cursor.

  • Changing the border/line color and the fill color can be done by clicking on the "Pick Color" button (top right) and selecting in the dialog that shows up whether you wanna change the fill color or not and what you wanna change it to. If the fill color remains unchecked, only the border color will change.

  • To connect to a drawing server go to Network on the top menu bar and click connect. Enter the server details and your authentication token and click connect.

  • If you successfully connected to a drawing server, you can fetch and push drawings via the "Fetch shapes" and "Push shapes" submenu items present in the Network tab on the top menu bar.

  • To export the canvas as an image go to File on the top menu bar and then click Export. You will be asked for a filename and the directory to save the image.

  • Design choice: The "Clear" button will clear the canvas and any states saved by undo/redo.

What's working partially:

  1. Selecting a rotated or scaled shape. That's because (except for Lines) the rotated shape coordinates are not calculated correctly and the non-rotated coordinates are used. This means that it is still possible to select a scaled/rotated shape but at a specific region/spot only (one where the coordinates are the same as before rotation).

  2. Triangles. My program supports only isosceles triangles not scalenes.

  3. Networking. My program supports only fetching shapes drawn by other users from the user (getDrawings) and pushing locally created shapes (addDrawing). Also, this works for all shapes except Triangles because as previously stated my program supports only isosceles triangles.

What's not working:

  1. Suppose two shapes are drawn, call them A and B. The user clicks undo, so B is removed. The user enters select mode and drags/modifies properties of A. The user exist select mode. The user clicks undo two times. In that case what should happen is that B reappears in the canvas. But in my implementation it gets completely lost. I just noticed this two hours before submission so I have no time to fix it :/

  2. updateDrawing and deleteDrawing from the networking spec have NOT been implemented.

poormanspaint's People

Contributors

jaytohe avatar

Stargazers

 avatar  avatar Andreas Demenagas avatar

Watchers

 avatar

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.