Skip to content

Commit 7213a60

Browse files
committedFeb 7, 2022
Readme.md
1 parent 4fe97dc commit 7213a60

File tree

3 files changed

+66
-68
lines changed

3 files changed

+66
-68
lines changed
 

‎README.md

+44-44
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
1-
# Getting Started with Create React App
1+
<p align="center"
2+
<img src ="https://upload.wikimedia.org/wikipedia/commons/thumb/e/ef/Stack_Overflow_icon.svg/768px-Stack_Overflow_icon.svg.png" width = 200px>
3+
</p>
24

3-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
5+
<h1 align = 'center'> LetsDraw
6+
</h1>
47

5-
## Available Scripts
8+
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;[![](https://img.shields.io/badge/Made_with-ReactJS-blue?style=for-the-badge&logo=react)](https://reactjs.org/docs/getting-started.html)&emsp;[![](https://img.shields.io/badge/IDE-Visual_Studio_Code-blue?style=for-the-badge&logo=visual-studio-code)](https://code.visualstudio.com/ "Visual Studio Code")
69

7-
In the project directory, you can run:
810

9-
### `npm start`
11+
<h2> About </h2>
12+
<p>
13+
In this project, basic functionality of simple online whiteboard tool are implemented. In my opinion, this project has by far been the best project to learn javascript.
14+
</p>
1015

11-
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
16+
-----------------------------------
1317

14-
The page will reload when you make changes.\
15-
You may also see any lint errors in the console.
18+
### Demo
1619

17-
### `npm test`
20+
<p align="center">
21+
<img src ="./assets/demo.gif" width = 500px>
22+
</p>
1823

19-
Launches the test runner in the interactive watch mode.\
20-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
2124

22-
### `npm run build`
25+
-----------------------------------
2326

24-
Builds the app for production to the `build` folder.\
25-
It correctly bundles React in production mode and optimizes the build for the best performance.
2627

27-
The build is minified and the filenames include the hashes.\
28-
Your app is ready to be deployed!
28+
### 🚀 Features
2929

30-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
30+
<p align="left">
31+
<ul>
32+
<li>Draw, drag, resize Rectangle</li>
33+
<li>Draw, drag, resize Line</li>
34+
<li>Draw, drag Free hand pencil drawing</li>
35+
<li>Maintain drawing history with undo-redo feature</li>
36+
</ul>
37+
</p>
3138

32-
### `npm run eject`
3339

34-
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
40+
-----------------------------------
3541

36-
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
42+
### :guide_dog: Installation Guide
3743

38-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
44+
A step by step series of examples that tell you how to get a development env running
3945

40-
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
46+
In your cmd:
4147

42-
## Learn More
48+
```
49+
git clone https://github.com/RugvedB/LetsDraw/
50+
```
4351

44-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
52+
Then,
4553

46-
To learn React, check out the [React documentation](https://reactjs.org/).
54+
```
55+
cd LetsDraw
56+
npm install
57+
npm start
58+
```
4759

48-
### Code Splitting
60+
You are done with the setup now!
4961

50-
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
5162

52-
### Analyzing the Bundle Size
63+
### :page_with_curl: Acknowledgements & References
5364

54-
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
65+
- Redhwan Nacef - https://www.youtube.com/c/RedhwanNacef
66+
- Javascript - https://developer.mozilla.org/en-US/docs/Web/JavaScript
5567

56-
### Making a Progressive Web App
68+
-----------------------------------
5769

58-
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59-
60-
### Advanced Configuration
61-
62-
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63-
64-
### Deployment
65-
66-
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67-
68-
### `npm run build` fails to minify
69-
70-
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
70+
<h3 align="center"><b>Developed with :heart: <a href="https://github.com/RugvedB">Rugved</a> </b></h1>

‎assets/demo.gif

Loading

‎src/App.js

+22-24
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { getStroke } from 'perfect-freehand'
44

55
const generator = rough.generator()
66

7-
const elementType = {
7+
const elementType = { // (tool)
8+
selection: "selection",
89
line: "line",
910
rectangle: "rectangle",
1011
pencil: "pencil",
@@ -17,12 +18,13 @@ const positionType = {
1718
tr: "tr",
1819
bl: "bl",
1920
br: "br",
21+
start: "start",
22+
end: "end"
2023
}
2124

2225
const actionType = {
2326
writing: "writing",
2427
drawing: "drawing",
25-
selection: "selection",
2628
moving: "moving",
2729
resizing: "resizing",
2830
deleteIt: "deleteIt"
@@ -71,7 +73,6 @@ const positionWithinElement = (x, y, element) => {
7173

7274
switch(type) {
7375
case elementType.rectangle:
74-
console.log("rectangle for selection")
7576
const minX = Math.min(x1, x2)
7677
const maxX = Math.max(x1, x2)
7778
const minY = Math.min(y1, y2)
@@ -85,10 +86,9 @@ const positionWithinElement = (x, y, element) => {
8586

8687
return topLeft || topRight || bottomLeft || bottomRight || insideRect
8788
case elementType.line:
88-
console.log("line for selection")
8989
const insideLine = onLine(x1, y1, x2, y2, x, y, 5)
90-
const start = nearPoint(x, y, x1, y1, "start")
91-
const end = nearPoint(x, y, x2, y2, "end")
90+
const start = nearPoint(x, y, x1, y1, positionType.start)
91+
const end = nearPoint(x, y, x2, y2, positionType.end)
9292
return start || end || insideLine
9393
case elementType.pencil:
9494
// Pencil drawing is basically group of points. Now there is a straight line between each of these points.
@@ -141,13 +141,13 @@ function adjustElementCoordinates(element){
141141

142142
function cursorForPosition(position){
143143
switch(position) {
144-
case "tl":
145-
case "br":
146-
case "start":
147-
case "end":
144+
case positionType.tl:
145+
case positionType.br:
146+
case positionType.start:
147+
case positionType.end:
148148
return "nwse-resize"
149-
case "tr":
150-
case "bl":
149+
case positionType.tr:
150+
case positionType.bl:
151151
return "nesw-resize"
152152
default:
153153
return "move"
@@ -157,15 +157,15 @@ function cursorForPosition(position){
157157
function resizedCoordinates(clientX, clientY, position, coordinates) {
158158
const { x1, y1, x2, y2 } = coordinates
159159
switch(position) {
160-
case "tl":
161-
case "start":
160+
case positionType.tl:
161+
case positionType.start:
162162
return { x1: clientX, y1: clientY, x2, y2 }
163-
case "tr":
163+
case positionType.tr:
164164
return { x1, y1: clientY, x2: clientX, y2 }
165-
case "bl":
165+
case positionType.bl:
166166
return { x1: clientX, y1, x2, y2: clientY }
167-
case "br":
168-
case "end":
167+
case positionType.br:
168+
case positionType.end:
169169
return { x1, y1, x2: clientX, y2: clientY }
170170
default:
171171
return null
@@ -306,12 +306,12 @@ function App() {
306306

307307
const { clientX, clientY } = event
308308

309-
if(tool === "selection"){
309+
if(tool === elementType.selection){
310310
const element = getElementAtPosition(clientX, clientY, elements)
311311

312312
if(element) {
313313

314-
if(element.type === "pencil") {
314+
if(element.type === elementType.pencil) {
315315
const xoffsets = element.points.map(point => clientX - point.x)
316316
const yoffsets = element.points.map(point => clientY - point.y)
317317
setSelectedElement({...element, xoffsets, yoffsets})
@@ -338,14 +338,12 @@ function App() {
338338
const id = elements.length
339339
// First entry will be like element at its place...like a dot
340340
const element = createElement(id, clientX, clientY, clientX, clientY, tool)
341-
console.log("new element created")
342-
console.log(element)
343341
setElements(prevState => [...prevState, element])
344342
setAction(tool === elementType.text ? actionType.writing : actionType.drawing)
345343
setSelectedElement(element)
346344

347345
}
348-
else if(tool === "deleteIt"){
346+
else if(tool === actionType.deleteIt){
349347
const element = getElementAtPosition(clientX, clientY, elements)
350348
if(element){
351349
setElements(prevState => prevState.filter((ele) => element.id !== ele.id))
@@ -385,7 +383,7 @@ function App() {
385383
const handleMouseMove = (event) => {
386384
const { clientX, clientY } = event
387385

388-
if(tool === actionType.selection){
386+
if(tool === elementType.selection){
389387
const element = getElementAtPosition(clientX, clientY, elements)
390388
event.target.style.cursor = element ? cursorForPosition(element.position) : "default"
391389
}

0 commit comments

Comments
 (0)
Please sign in to comment.