Added room type definitions, drafted room drawing funtion

This commit is contained in:
Dmitriy Shishkov 2021-09-04 03:10:03 +03:00
parent d8a4852202
commit 8560d3c0ce
No known key found for this signature in database
GPG Key ID: 14358F96FCDD8060
3 changed files with 35 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import {
} from "@material-ui/core";
import { RoomContextProvider } from "./context";
import { BuildingPlan } from "./components/BuildingPlan";
export const App = () => {
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
@ -25,7 +26,7 @@ export const App = () => {
<ThemeProvider theme={theme}>
<RoomContextProvider>
<CssBaseline />
Here goes content soon!
<BuildingPlan height={window.innerHeight} width={window.innerWidth} />
</RoomContextProvider>
</ThemeProvider>
);

View File

@ -0,0 +1,28 @@
import { RoomT } from "../types/room";
import { Canvas } from "./Canvas";
export type BuildingPlanProps = { width: number; height: number };
export const BuildingPlan = ({ width, height }: BuildingPlanProps) => {
const room: RoomT = {
coordinates: { x: 100, y: 200 },
free: true,
size: { h: 100, w: 200 },
};
return (
<Canvas
height={height}
width={width}
draw={(ctx) => {
ctx.fillStyle = room.free ? "green" : "gray";
ctx.fillRect(
room.coordinates.x,
room.coordinates.y,
room.size.w,
room.size.h
);
}}
/>
);
};

5
src/types/room.ts Normal file
View File

@ -0,0 +1,5 @@
export type RoomT = {
coordinates: { x: number; y: number };
size: { w: number; h: number };
free: boolean;
};