Skip to content

Commit bc18aa2

Browse files
committed
project complete
1 parent 3084998 commit bc18aa2

18 files changed

+207
-160
lines changed

conj/index.js

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"use strict";
2+
3+
function conj(verb, pron) {
4+
const pronoun = ['я', 'мы', 'ты', 'вы', 'он', 'она', 'оно', 'они'];
5+
6+
const conjugationFirst = ['ать', 'оть', 'уть', 'еть', 'ять'];
7+
const conjugationSecond = 'ить';
8+
9+
const verbChank = verb.slice(0, verb.length - 3);
10+
if (verb.includes(conjugationSecond)) {
11+
switch (pron) {
12+
case pronoun[0]:
13+
console.log(`${verbChank}лю`);
14+
break;
15+
case pronoun[1]:
16+
console.log(`${verbChank}им`);
17+
break;
18+
case pronoun[2]:
19+
console.log(`${verbChank}ишь`);
20+
break;
21+
case pronoun[3]:
22+
console.log(`${verbChank}те`);
23+
break;
24+
case pronoun[4]:
25+
case pronoun[5]:
26+
case pronoun[6]:
27+
console.log(`${verbChank}ит`);
28+
break;
29+
case pronoun[7]:
30+
console.log(`${verbChank}ят`);
31+
break;
32+
default:
33+
break;
34+
}
35+
}
36+
37+
for (const i of conjugationFirst) {
38+
if (verb.includes(i)) {
39+
switch (pron) {
40+
case pronoun[0]:
41+
console.log(`${verbChank}ою`);
42+
break;
43+
case pronoun[1]:
44+
console.log(`${verbChank}оём`);
45+
break;
46+
case pronoun[2]:
47+
console.log(`${verbChank}оёшь`);
48+
break;
49+
case pronoun[3]:
50+
console.log(`${verbChank}оёте`);
51+
break;
52+
case pronoun[4]:
53+
case pronoun[5]:
54+
case pronoun[6]:
55+
console.log(`${verbChank}оёт`);
56+
break;
57+
case pronoun[7]:
58+
console.log(`${verbChank}оют`);
59+
break;
60+
default:
61+
break;
62+
}
63+
}
64+
}
65+
}
66+
67+
conj('петь', 'оно');

public/favicon.ico

-3.78 KB
Binary file not shown.

public/index.html

+10-37
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,16 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1" />
7-
<meta name="theme-color" content="#000000" />
8-
<meta
9-
name="description"
10-
content="Web site created using create-react-app"
11-
/>
12-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13-
<!--
14-
manifest.json provides metadata used when your web app is installed on a
15-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16-
-->
17-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18-
<!--
19-
Notice the use of %PUBLIC_URL% in the tags above.
20-
It will be replaced with the URL of the `public` folder during the build.
21-
Only files inside the `public` folder can be referenced from the HTML.
223

23-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24-
work correctly both with client-side routing and a non-root public URL.
25-
Learn how to configure a non-root public URL by running `npm run build`.
26-
-->
27-
<title>React App</title>
28-
</head>
29-
<body>
30-
<noscript>You need to enable JavaScript to run this app.</noscript>
31-
<div id="root"></div>
32-
<!--
33-
This HTML file is a template.
34-
If you open it directly in the browser, you will see an empty page.
4+
<head>
5+
<meta charset="utf-8" />
6+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<title>React Canvas</title>
9+
</head>
3510

36-
You can add webfonts, meta tags, or analytics to this file.
37-
The build step will place the bundled scripts into the <body> tag.
11+
<body>
12+
<div id="root"></div>
13+
14+
</body>
3815

39-
To begin the development, run `npm start` or `yarn start`.
40-
To create a production bundle, use `npm run build` or `yarn build`.
41-
-->
42-
</body>
4316
</html>

public/logo192.png

-5.22 KB
Binary file not shown.

public/logo512.png

-9.44 KB
Binary file not shown.

public/manifest.json

-25
This file was deleted.

public/robots.txt

-3
This file was deleted.

src/App.css

+16-29
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,25 @@
1-
.App {
2-
text-align: center;
1+
body {
2+
background: #f8f8f8;
33
}
44

5-
.App-logo {
6-
height: 40vmin;
7-
pointer-events: none;
8-
}
9-
10-
@media (prefers-reduced-motion: no-preference) {
11-
.App-logo {
12-
animation: App-logo-spin infinite 20s linear;
13-
}
14-
}
15-
16-
.App-header {
17-
background-color: #282c34;
18-
min-height: 100vh;
5+
.container {
196
display: flex;
207
flex-direction: column;
21-
align-items: center;
22-
justify-content: center;
23-
font-size: calc(10px + 2vmin);
24-
color: white;
8+
margin: 30px auto;
9+
}
10+
11+
.form {
12+
margin: 10px auto;
2513
}
2614

27-
.App-link {
28-
color: #61dafb;
15+
.input {
16+
width: 50px;
17+
margin: 0 30px 0 5px;
18+
background: #ffffff;
2919
}
3020

31-
@keyframes App-logo-spin {
32-
from {
33-
transform: rotate(0deg);
34-
}
35-
to {
36-
transform: rotate(360deg);
37-
}
21+
.canvas {
22+
margin: auto;
23+
background-color: #ffffff;
24+
outline: 1px solid #a8a8a8;
3825
}

src/App.js

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
import logo from './logo.svg';
1+
import { useEffect, useRef, useState } from 'react';
2+
import { Canvas } from './components/Canvas';
3+
import { Form } from './components/Form';
4+
import { handleCanvas } from './handlers/handleCanvas';
25
import './App.css';
36

4-
function App() {
7+
export default function App() {
8+
const [lineWidth, setLineWidth] = useState(1);
9+
const [canvasWidth, setCanvasWidth] = useState(800);
10+
const [canvasHeight, setCanvasHeight] = useState(600);
11+
const canvasRef = useRef(null);
12+
13+
useEffect(() => {
14+
handleCanvas(canvasRef, lineWidth);
15+
}, [lineWidth, canvasWidth, canvasHeight]);
16+
517
return (
6-
<div className="App">
7-
<header className="App-header">
8-
<img src={logo} className="App-logo" alt="logo" />
9-
<p>
10-
Edit <code>src/App.js</code> and save to reload.
11-
</p>
12-
<a
13-
className="App-link"
14-
href="https://reactjs.org"
15-
target="_blank"
16-
rel="noopener noreferrer"
17-
>
18-
Learn React
19-
</a>
20-
</header>
18+
<div className="container">
19+
<Form
20+
canvasWidth={canvasWidth}
21+
canvasHeight={canvasHeight}
22+
setLineWidth={setLineWidth}
23+
setCanvasWidth={setCanvasWidth}
24+
setCanvasHeight={setCanvasHeight} />
25+
<Canvas
26+
canvasRef={canvasRef}
27+
width={canvasWidth}
28+
height={canvasHeight} />
2129
</div>
2230
);
2331
}
24-
25-
export default App;

src/App.test.js

-8
This file was deleted.

src/components/Canvas.jsx

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const Canvas = ({ canvasRef, width, height }) => {
2+
return (
3+
<canvas className="canvas" ref={canvasRef} width={width} height={height} />
4+
);
5+
};

src/components/Form.jsx

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
export const Form = ({
2+
canvasWidth,
3+
canvasHeight,
4+
setLineWidth,
5+
setCanvasWidth,
6+
setCanvasHeight,
7+
}) => {
8+
return (
9+
<div className="form">
10+
<label htmlFor="line-width">Толщина линии</label>
11+
<input
12+
onChange={(e) => setLineWidth(e.target.value)}
13+
className="input"
14+
id="line-width"
15+
type="number"
16+
defaultValue={1}
17+
min={1}
18+
max={10}
19+
/>
20+
<label htmlFor="line-width">Ширина холста</label>
21+
<input
22+
onChange={(e) => setCanvasWidth(e.target.value)}
23+
className="input"
24+
id="line-width"
25+
type="text"
26+
value={canvasWidth}
27+
/>
28+
<label htmlFor="line-height">Высота холста</label>
29+
<input
30+
onChange={(e) => setCanvasHeight(e.target.value)}
31+
className="input"
32+
id="line-height"
33+
type="text"
34+
value={canvasHeight}
35+
/>
36+
</div>
37+
);
38+
};

src/handlers/handleCanvas.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
export const handleCanvas = (ref, lineWidth) => {
2+
const canvas = ref.current;
3+
const ctx = canvas.getContext('2d');
4+
5+
ctx.lineWidth = lineWidth;
6+
let currentX = 0;
7+
let currentY = 0;
8+
let draw = false;
9+
let saved = null;
10+
11+
function drawLine(x, y) {
12+
const img = new Image();
13+
img.src = saved;
14+
img.onload = async function () {
15+
ctx.clearRect(0, 0, canvas.width, canvas.height);
16+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
17+
ctx.beginPath();
18+
ctx.moveTo(currentX, currentY);
19+
ctx.lineTo(x, y);
20+
ctx.stroke();
21+
}
22+
}
23+
24+
function mouseDown(e) {
25+
draw = true;
26+
currentX = e.pageX - e.target.offsetLeft;
27+
currentY = e.pageY - e.target.offsetTop;
28+
ctx.beginPath();
29+
ctx.moveTo(currentX, currentY);
30+
saved = canvas.toDataURL();
31+
}
32+
33+
function mouseMove(e) {
34+
if (draw) {
35+
drawLine(e.pageX - e.target.offsetLeft, e.pageY - e.target.offsetTop);
36+
}
37+
}
38+
39+
function mouseUp() {
40+
draw = false;
41+
}
42+
43+
canvas.addEventListener("mousedown", mouseDown, false);
44+
canvas.addEventListener("mousemove", mouseMove, false);
45+
canvas.addEventListener("mouseup", mouseUp, false);
46+
}

src/index.css

-13
This file was deleted.

src/index.js

-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import './index.css';
43
import App from './App';
5-
import reportWebVitals from './reportWebVitals';
64

75
ReactDOM.render(
86
<React.StrictMode>
97
<App />
108
</React.StrictMode>,
119
document.getElementById('root')
1210
);
13-
14-
// If you want to start measuring performance in your app, pass a function
15-
// to log results (for example: reportWebVitals(console.log))
16-
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17-
reportWebVitals();

src/logo.svg

-1
This file was deleted.

0 commit comments

Comments
 (0)