How can I display letters using html table cells as colored pixels?

后端 未结 2 1029
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-27 11:49

Let\'s say I have an html table (50 x 50 cells) with a yellow background. I would like to use the background colors of the cells to print letters (A-Z) (e.g. some cells blue and

2条回答
  •  天命终不由人
    2021-01-27 12:04

    Use Canvas (Edit: only for the generation of the letter coordinates in the 50x50 grid, no usage of canvas afterwards).

    • For each letter possible, print the char on a 50x50 html5/javascript canvas in black and white using something like: http://typeface.neocracy.org/examples.html

    • Then access the canvas in each pixel to check if it black or white, and save it in multidimensional javascript arrays. getPixel from HTML Canvas?

    • print the output and create javascript code or JSON object that saves those coordinates for your use.

    After that you'll have all you need: the coordinates for each letter, and (bonus) with a font of your choice.

提交回复
热议问题