Generating random patterns for profile pictures tags identifiers listSym function rc var o Math round r Math random s 255 return rgb o r s o r s o r s function create_square border draw randColor element size let cc randColor if element Math round size 2 cc listSym pop console log pop element element listSym length listSym length size 2 size 2 else listSym push randColor console log push element element listSym length listSym length size 2 size 2 draw fillStyle cc fillRect x y width height draw fillRect border 0 border 1 border 2 border 3 function create_invader border draw size let x0 border 0 let y0 border 1 let x1 border 2 let y1 border 3 let squareSize x1 x0 size let randColors rc rc rc rgb 0 0 0 rgb 0 0 0 rgb 0 0 0 let i 1 for let y 0 y size y element 0 for let x 0 x size x topLeftX x squareSize x0 topLeftY y squareSize y0 botRightX topLeftX squareSize botRightY topLeftY squareSize let rc randColors Math floor Math random randColors length create_square topLeftX topLeftY squareSize squareSize draw rc element size element i function main size invaders imgSize origImage document createElement canvas document body appendChild origImage origImage width imgSize origImage height imgSize var drawctx origImage getContext 2d invaderSize imgSize invaders padding invaderSize size for let x 0 x invaders x for let y 0 y invaders y topLeftX x invaderSize padding 2 topLeftY y invaderSize padding 2 botRightX topLeftX invaderSize padding botRightY topLeftY invaderSize padding create_invader topLeftX topLeftY botRightX botRightY drawctx size 7 30 1900 SPRITE_DIMENSIONS NUMBER IMAGE_SIZE single image main 8 1 200 main 8 10 800
uareSize x0 topLeftY y squareSize y0 botRightX topLeftX squareSize botRightY topLeftY squareSize let rc randColors Math floor Math random randColors length create_square topLeftX topLeftY squareSize squareSize draw rc element size element i function main size invaders imgSize origImage document createElement canvas document body appendChild origImage origImage width imgSize origImage height imgSize var drawctx origImage getContext 2d invaderSize imgSize invaders padding invaderSize size for let x 0 x invaders x for let y 0 y invaders y topLeftX x invaderSize padding 2 topLeftY y invaderSize padding 2 botRightX topLeftX invaderSize padding botRightY topLeftY invaderSize padding create_invader topLeftX topLeftY botRightX botRightY drawctx size 7 30 1900 SPRITE_DIMENSIONS NUMBER IMAGE_SIZE single image main 8 1 200 main 8 10 800