Guest User

Use http://dataurl.net/#dataurlmaker to generate the images.

a guest
Feb 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. (function () {
  2. function line(sx, sy, tx, ty, color) {
  3. lastDrawingPoint.x = sx,
  4. lastDrawingPoint.y = sy,
  5. drawingMouseDown = !0;
  6. selectedColour = color;
  7. selectedSize = "medium";
  8. var b = 0;
  9. "small" == selectedSize ? b = 5 : "medium" == selectedSize ? b = 10 : "large" == selectedSize && (b = 20), players[localId].drawing.graphics.ss(b, "round").s(selectedColour), players[localId].drawing.graphics.mt(lastDrawingPoint.x, lastDrawingPoint.y);
  10. var c = { x: tx, y: ty };
  11. players[localId].drawing.graphics.lt(c.x, c.y);
  12. var d = new EncodePath;
  13. d.moveTo(lastDrawingPoint.x, lastDrawingPoint.y).lineTo(c.x, c.y), encodedPathBuffer.push(d.code), lastDrawingPoint.x = c.x, lastDrawingPoint.y = c.y;
  14. var e = "#fff" == selectedColour;
  15. players[localId].drawingContainer.updateCache(e ? "destination-out" : "source-over"), players[localId].drawing.graphics.clear()
  16. emitDrawing(!0);
  17. }
  18. function componentToHex(c) {
  19. var hex = c.toString(16);
  20. return hex.length == 1 ? "0" + hex : hex;
  21. }
  22.  
  23. function rgbToHex(r, g, b) {
  24. return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
  25. }
  26. var img = $('<img id="picture" style="display: none" src="{{INSERT BASE64image here}}">')[0];
  27. var canvas = $('<canvas />')[0];
  28. canvas.width = img.width;
  29. canvas.height = img.height;
  30. canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);
  31. var pixelData = canvas.getContext('2d').getImageData(0, 0, img.width, img.height).data;
  32. var offset_x = 0, offset_y = 800;
  33. var x = 0, y = 0;
  34. var step = 8;
  35. for(x = 0; x < img.width; x += step) {
  36. for(y = 0; y < img.height; y += step) {
  37. line(x + offset_x, y + offset_y, x + offset_x, y + offset_y, rgbToHex(pixelData[(x + y*img.width)*4], pixelData[(x + y*img.width)*4 + 1], pixelData[(x + y*img.width)*4+2]));
  38. }
  39. }
  40. return pixelData;
  41. })()
Add Comment
Please, Sign In to add comment