Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // How to post images to /r/layer
- // First, get an image you want to post, make sure it's a PNG
- // Use https://base64.guru/converter/encode/image to get the image as base64
- // Keep the text from the output handy
- // Using Chrome...
- // Create a new layer, the Layer creation itnterface will open
- // Click to create at least one line or dot with the standard paint tool
- // Right click within the layer maker window and click 'inspect'
- // In the elements tab of Chrome Dev Tools, click on the line which begins with '<layer-maker'
- // Navigate to the console tab in Chrome Dev Tools
- // Paste the following
- let layerMaker = document.getElementsByTagName('layer-maker')[0];
- const imageToPost = new Image();
- let layerUndoReplacer = function(undoManager, imageData){
- for(let i = 0; i < undoManager.states.length; i++){
- let state = undoManager.states[i];
- state.next = {
- imageData: imageData,
- x: 0, y: 0
- }
- state.prev = {
- imageData: imageData,
- x: 0, y: 0
- }
- }
- }
- // Paste your Base64 data in here,, after the comma and ending with the last double quotes
- imageToPost.src = "data:image/png;base64,YOURBASE64HERE"
- layerMaker.canvas.ctxDisplay.drawImage(imageToPost, 0, 0, 1000, 1000)
- let imageData = layerMaker.canvas.ctxDisplay.getImageData(0,0,1000,1000);
- layerUndoReplacer(layerMaker.canvas.undoManager, imageData);
- // Press undo/redo until the image looks correct
- // Submit and enjoy!
Add Comment
Please, Sign In to add comment