Answer the question
In order to leave comments, you need to log in
How to display text on canvas html5 and php?
There is a code, you need that when you enter site.ru/minecraft.php?text=test
, a picture with the text that is specified in the url is displayed
<?php
$text = $_GET["text"];
$ses = $text;
?>
<!doctype html>
<html>
<meta charset='utf-8'>
<head>
<title>Minecraft</title>
<style>
@font-face {
font-family: minecraft;
src: url(minecraft.ttf);
}
</style>
</head>
<body>
<canvas id="example" width="320" height="64"></canvas>
<script>
var img = new Image();
img.src = 'achievement.png';
var canvas = document.getElementById("example");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#ffffff";
ctx.drawImage(img, 0, 0);
ctx.font = 'normal 18px minecraft';
ctx.fillText($ses, 60, 50);
</script>
</body>
</html>
<?php
echo $text;
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question