Skip to content

Commit

Permalink
Some test image
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszmigas committed Mar 2, 2024
1 parent b296439 commit c72437f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Binary file added apps/web/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion apps/web/public/vite.svg

This file was deleted.

22 changes: 21 additions & 1 deletion apps/web/src/components/canvasHost.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
import { useLayoutEffect, useRef } from "react";

export const CanvasHost = () => {
const canvasRef = useRef<HTMLCanvasElement>(null);

useLayoutEffect(() => {
if (!canvasRef.current) return;

const context = canvasRef.current.getContext("2d");
if (!context) return;

const image = new Image();
image.onload = () => context.drawImage(image, 0, 0);
image.src = "/logo.png";

context.font = "30px Arial";
context.fillText("Hello, World!", 300, 400);
}, []);

return (
<div className="bg-gray-100" style={{ width: 800, height: 600 }}></div>
<div className="bg-gray-100" style={{ width: 800, height: 600 }}>
<canvas ref={canvasRef} width={800} height={600}></canvas>
</div>
);
};

0 comments on commit c72437f

Please sign in to comment.