Let's start by breaking down how to make an image to later display. First, we start with a background to make the menu look a little nicer. I took inspiration from a Dungeons and Dragons-themed tea shop and created a custom background on the paper texture.
Then, I moved on to creating the foreground text using SVG. We frequently use SVG to create vector art on our websites, and it resembles HTML and lets us use React and CSS. For a single tea flavor in the menu, I created text elements for the tea name and description, as well as a line to separate them. I then wrapped it in an SVG group, like a div.
I wrote a small program in TypeScript to read the database with my tea, and then write SVG files using React. This SVG snippet has been turned into a React component, so you can translate a data object into a rendered image using text elements and SVG positioning. Then I can move each of these groups using transform-translate, like a CSS transformation or using position-absolute. By setting different x and y values, I can reuse the same text and line elements, but move them around the image.
With the top section nicely laid out, I can then wrap all these elements in a group and repeat the same process, running the component with a different translation for the bottom section. SVG is very flexible, so you can make your own customizations. You could switch out the font to CSS or display different number of items and show a menu for other things in your house. It's also easy to swap the background image around to anything you want. For an e-reader, I convert the SVG file into a png image, which you can do using free tools like Inkscape and Squoosh. Some e-readers let you just upload a custom lockscreen image, I can connect it to my computer, then drag this image onto its hard drive in a screensaver folder. But other e-readers do not have this feature. However, most of them will show the cover of whatever book you're reading when locked. We can abuse this by writing our own e-book, using the menu image as the cover of the book.
Now, when I say e-book, you probably think of a digital version of a big book like this with lots of characters. But our e-book is going to be more like a pamphlet. If you have at least one page, you can write an e-book. E-books are written in a format called EPUB. This is a standardized format used by all e-readers except Kindles, but Amazon lets you easily convert from EPUB into Kindle's custom format. EPUBs are actually just zip files that have their extension renamed. Just like websites, e-books need to be responsive since you can have different e-reader screen sizes. As a result, writing an e-book is very similar to writing a website. You use familiar HTML, CSS, and images to create each chapter of the book. In a website, each HTML file is a page on your site.
Comments