Technologies
-
NodeJS
-
Express
-
Heroku
NodeJS
Express
Heroku
This is a Node Express application API deployed to Heroku. It allows users to generate randomized SVG Images based on a given seed value. This is an individual project. I submitted it as my final project for cs50x Introduction to Computer Science.
Try It Out View CodeI chose to generate SVG images because they are rescalable (vector), support transparency, and are composed of XML, which makes them easy to modify within the API.
Steps to Create Components:
The user can input any seed as a get request parameter. I used seedrandom, a seeded random number generator for JS, to choose SVG component parts based on the user's chosen seed.
pickAPart() takes a number 1-10 and a part type (mouth, eye or body) and returns the corresponding part version (eg. 'mouth2.svg'). The route '/creature/:seed' takes any seed value as a get request parameter. It then uses seedrandom to generate 3 numbers based on the given seed. pickAPart() is then called with each number and corresponding part type. The resulting parts are concatenated into one long string. This string is written to a temporary SVG file. Then the request responds, returning the SVG string to the user.