![]() Just implement it and work with it a bunch and it will start to make sense. You don’t have to understand it right away. I feel like redux (as well as a lot of coding challenges) are best understood through repetition. If you’re new to redux or similar state management frameworks, it can be a lot. That took me while to get my head around. One of the requirements for this project were that we incorporate redux into our React app. The first block is from my CreateSketches component, while the second is from my sketch actions (redux). Here’s how I sent my p5js visual data to my backend. Here’s a stackoverflow article about how to inspect it. If you try to look at a key you put into your FormData in the developer console it will come back empty.Īny methods that exist on FormData return iterators, so you can’t see anything you call on it unless you actually iterate over it. If you haven’t worked with FormData before, it behaves very strangely, and it’s not that straight-forward to inspect it. Additionally, you can’t send binary as json (as far as I know), so FormData came to the rescue as a means of shipping the binary to my backend. I used a query selector to access the p5.js canvas, converted it to a blob, and then put that blob into FormData. It takes an html element and converts it to binary (which is essentially what a blob is). Obviously the information I needed to persist to my database existed. ![]() But what if I just want to send it straight to my backend? And wouldn’t that be rude to save that image to the user’s computer just so I can have it in my server? Writing code to let a user save an asset to their local hard drive is a relatively easy thing to do. Now that I had a react-p5 proof of concept, I needed to know whether or could successfully send a p5 sketch to my backend as an image, persist it, and then be able to render it to my front end. ![]() The p5 code I ended up implementing for my react-p5 experiment ended up being very much based upon the Coding Train’s Kaleidescope Snowflake Challenge by the famous Dan Shiffman (who was a former professor of mine). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |