Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function () {
- function line(sx, sy, tx, ty, color) {
- lastDrawingPoint.x = sx,
- lastDrawingPoint.y = sy,
- drawingMouseDown = !0;
- selectedColour = color;
- selectedSize = "medium";
- var b = 0;
- "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);
- var c = { x: tx, y: ty };
- players[localId].drawing.graphics.lt(c.x, c.y);
- var d = new EncodePath;
- d.moveTo(lastDrawingPoint.x, lastDrawingPoint.y).lineTo(c.x, c.y), encodedPathBuffer.push(d.code), lastDrawingPoint.x = c.x, lastDrawingPoint.y = c.y;
- var e = "#fff" == selectedColour;
- players[localId].drawingContainer.updateCache(e ? "destination-out" : "source-over"), players[localId].drawing.graphics.clear()
- emitDrawing(!0);
- }
- function componentToHex(c) {
- var hex = c.toString(16);
- return hex.length == 1 ? "0" + hex : hex;
- }
- function rgbToHex(r, g, b) {
- return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
- }
- var img = $('<img id="picture" style="display: none" src="{{INSERT BASE64image here}}">')[0];
- var canvas = $('<canvas />')[0];
- canvas.width = img.width;
- canvas.height = img.height;
- canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);
- var pixelData = canvas.getContext('2d').getImageData(0, 0, img.width, img.height).data;
- var offset_x = 0, offset_y = 800;
- var x = 0, y = 0;
- var step = 8;
- for(x = 0; x < img.width; x += step) {
- for(y = 0; y < img.height; y += step) {
- 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]));
- }
- }
- return pixelData;
- })()
Add Comment
Please, Sign In to add comment