We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I've made a basic drawing application using p5, that uses an ellipse as a brush which accumulates every frame because the background doesn't clear. Ideally, once the user's done, they press a submit button the image would POST to a json object in an mlab database (cloud mongoDB service). Is this even doable? If I understand, save() only downloads to the user's computer? I'm new to back end dev so go easy. Simplified code below.
function setup() {
let canvas = createCanvas(1200, 1200);
canvas.parent('js-sketch-holder');
background(0);
noStroke();
fill(255);
rect(100, 100, 1000, 1000);
brush = new Brush(50, defaultSwatch);
createPallet();
}
function draw() {
renderPallet();
//ellipse brush accumulates on canvas
brush.display(mouseX, mouseY);
}
Answers
Coding is easy :(|) You just need the proper documentation. If the documentation says you can do it, then it is matter of getting the right API calls. Unfortunately I am not familiar with this mlab database. I did a quick search and I have some hits, possibly relevant:
docs.mlab.com
https://stackoverflow.com/questions/4796914/store-images-in-a-mongodb-database
https://stackoverflow.com/questions/36229435/upload-data-into-mongolab-database-from-terminal
Now, it sounds you are running your script from the client side. Then, you might need to connect to the database and load the data. The search above might not help you. The search needs to be refined and repeated. However, I can atest you can do what you want to do with firebase.
Kf