Skip to content
Snippets Groups Projects
Commit 52202b71 authored by coco's avatar coco
Browse files

changed text generator

parent 061a17d3
No related branches found
No related tags found
No related merge requests found
Pipeline #9625 passed
......@@ -40,7 +40,7 @@
<script type="text/javascript" >
function drawText () {
var fontName = document.getElementById("fontName").value;
var fontColor = document.getElementById("fontColor").value;
var fontColors = document.getElementById("fontColor").value.split(',');
var marginTop = Number(document.getElementById("marginTop").value);
var marginLeft = Number(document.getElementById("marginLeft").value);
var fontSize = document.getElementById("fontSize").value;
......@@ -54,9 +54,10 @@
var maxRows = (canvas.height / tileHeight) - 1;
var row = 0;
var column = 0;
var colorIndex = 0;
canvasContext.font = fontInfo;
canvasContext.fillStyle = fontColor;
canvasContext.fillStyle = fontColors[colorIndex];
canvasContext.textAlign = "left";
canvasContext.textBaseline = "hanging";
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
......@@ -64,7 +65,14 @@
for(var n=0; n<lines.length; n++) {
var x = (column * 128) + marginLeft;
var y = (row * tileHeight) + marginTop;
var y = (row * tileHeight) + marginTop;
colorIndex++;
if(colorIndex == fontColors.length){
colorIndex = 0;
}
canvasContext.fillStyle = fontColors[colorIndex];
canvasContext.fillText(lines[n], x, y, 128-marginLeft);
row++;
......@@ -95,13 +103,13 @@
<label>Size</label> <input id="fontSize" value="8" style="width:3em"; /> px
</div>
<div class="setting">
<label>Margin top</label> <input id="marginTop" value="18" style="width:3em"; /> px
<label>Margin top</label> <input id="marginTop" value="17" style="width:3em"; /> px
</div>
<div class="setting">
<label>Margin left</label> <input id="marginLeft" value="20" style="width:3em"; /> px
</div>
<div class="setting">
<label>Color</label> <input id="fontColor" value="#cccccc" style="width:7em"; />
<label>Color</label> <input id="fontColor" value="#ff1e88,#ee3aff,#79ffe4,#5cff78,#ffe378" style="width:28em"; />
</div>
</form>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment