INTRODUCTION TO PROGRAMMING FOR THE VISUAL ARTS WITH P5.JS
Assignment 1: Port an Image to Code
| const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); | |
| const pixels = imageData.data; | |
| for (let i = 3, n = canvas.width * canvas.height * 4; i < n; i += 4) { | |
| pixels[i] = pixels[i] < 127? 0 : 255 | |
| } | |
| ctx.putImageData(imageData, 0, 0); |
| var trimCanvas = (function() { | |
| function rowBlank(imageData, width, y) { | |
| for (var x = 0; x < width; ++x) { | |
| if (imageData.data[y * width * 4 + x * 4 + 3] !== 0) return false; | |
| } | |
| return true; | |
| } | |
| function columnBlank(imageData, width, x, top, bottom) { | |
| for (var y = top; y < bottom; ++y) { |
| /* | |
| * Handling Errors using async/await | |
| * Has to be used inside an async function | |
| */ | |
| try { | |
| const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
| // Success 🎉 | |
| console.log(response); | |
| } catch (error) { | |
| // Error 😨 |
| # Stop all containers | |
| docker stop `docker ps -qa` | |
| # Remove all containers | |
| docker rm `docker ps -qa` | |
| # Remove all images | |
| docker rmi -f `docker images -qa ` | |
| # Remove all volumes |
| * what it's like to not be technical in the industry | |
| * what you do in tech that people forget is needed | |
| * the most interesting thing you've worked on recently | |
| * what your day-to-day is like | |
| * must-have gifs for every techie | |
| * horrible code from the past that shows I'm much better now | |
| * the best music for hacking | |
| * mistakes you've made that make you groan | |
| * how you've made it at well-known companies | |
| * self-care in the tech bubble |
INTRODUCTION TO PROGRAMMING FOR THE VISUAL ARTS WITH P5.JS
Assignment 1: Port an Image to Code
| //Now with less jquery | |
| //1) go to your my-list page, and scroll to the bottom to make sure it's all loaded: | |
| //http://www.netflix.com/browse/my-list | |
| //2) Next, paste this in your developer tools console and hit enter: | |
| [...document.querySelectorAll('.slider [aria-label]')].map(ele => ele.getAttribute('aria-label')) | |
| //or use this to copy the list to your clipboard: | |
| copy([...document.querySelectorAll('.slider [aria-label]')].map(ele => ele.getAttribute('aria-label'))) |
| // For input image where information is only stored in alpha channel over black RGB. | |
| // Make all pixels with transparency black, and remove alpha channel. | |
| private Bitmap AlphaToBlack(Bitmap image) { | |
| Bitmap rgbImage = image.copy(Bitmap.Config.ARGB_8888, true); | |
| for (int y = 0; y < rgbImage.getHeight(); y++) { | |
| for (int x = 0; x < rgbImage.getWidth(); x++) { | |
| int aPixel = rgbImage.getPixel(x, y); | |
| if (rgbImage.getPixel(x, y) < 0xFF000000) |
| <!-- Raven.js Config --> | |
| <script src="{{ JS_PATH }}/lib/raven.js" type="text/javascript"></script> | |
| <script type="text/javascript"> | |
| // Ignore list based off: https://gist.github.com/1878283 | |
| var ravenOptions = { | |
| // Will cause a deprecation warning, but the demise of `ignoreErrors` is still under discussion. | |
| // See: https://github.com/getsentry/raven-js/issues/73 | |
| ignoreErrors: [ | |
| // Random plugins/extensions | |
| 'top.GLOBALS', |
| // MIT http://rem.mit-license.org | |
| function trim(c) { | |
| var ctx = c.getContext('2d'), | |
| copy = document.createElement('canvas').getContext('2d'), | |
| pixels = ctx.getImageData(0, 0, c.width, c.height), | |
| l = pixels.data.length, | |
| i, | |
| bound = { | |
| top: null, |