E-Commerce
Ruby for Makers: Designing Physical Products With Ruby

Summarized using AI

Ruby for Makers: Designing Physical Products With Ruby

Andy Glass • November 13, 2018 • Los Angeles, CA

In the talk titled "Ruby for Makers: Designing Physical Products With Ruby" presented at RubyConf 2018 by Andy Glass, the speaker explores the potential of Ruby for creating dynamic plans for physical products through laser cutting. The main theme revolves around leveraging Ruby, typically associated with digital product creation, for innovative physical product design.

Key Points discussed include:
- Community and Inspiration: Andy begins by highlighting the collaborative spirit within the Ruby community that inspires creativity and innovation. He reflects on personal experiences of unexpected achievements using Ruby, portraying it as a tool that enables limitless possibilities.
- Project Concept: Initially, Andy aimed to present at RailsConf but pivoted to propose a Ruby program to generate customizable laser-cut products. This shift set the stage for merging web applications with physical design.
- Research and Business Model: Before diving into coding, Andy emphasizes the importance of researching existing solutions and validating the business case for a customizable e-commerce platform reminiscent of Nike ID, aiming to facilitate user-driven design and fulfillment processes.
- Example Projects: He references projects like "Make a Box," a dynamic design tool for creating custom boxes, and businesses like "Printful," offering automated printing and fulfillment integrated with Ruby, which inspired his approach.
- Technical Implementation: The technical portion includes using the Prawn gem to create a Ruby application that can generate designs based on user inputs. This includes setting up templates for various products such as laptop sleeves and notebooks, as well as incorporating SVG graphics using external APIs like the Noun Project.
- Customization Techniques: Andy details several customization methods, including adding text, graphics, templated designs utilizing tweets with a Twitter API, creating random patterns of equilateral triangles, and building nested designs with shapes.
- Final Thoughts: He concludes with insights on the limitless creativity within such projects and how they offer opportunities for revenue generation while enjoying the design process. He encourages attendees to explore these concepts, leverages community resources, and shares his project on GitHub.

The key takeaway from the presentation is the call for Ruby developers to venture beyond digital confines, using their skills to innovate in the physical space, thereby creating products that reflect limitless creativity and potential.

Ruby for Makers: Designing Physical Products With Ruby
Andy Glass • November 13, 2018 • Los Angeles, CA

RubyConf 2018 - Ruby for Makers: Designing Physical Products With Ruby by Andy Glass

Rubyists are creators. While we’re traditionally tasked with building digital products, our skills can cross into the physical medium too. This talk demonstrates a non-typical way to use code to create products: building a Ruby program that generates dynamic plans for laser-cut physical products (e.g. laptop stands, picture frames, notebooks, etc). With size, fonts and patterns as variables, our app programs a system that allows a user, or a computer, to design an infinite number of variants. Attendees will leave inspired to explore new avenues to use their skills to do what we do best: create.

RubyConf 2018

00:00:15.410 Cool! I think we are good to go at two o'clock.
00:00:19.470 All right, let’s get after it! How are we doing, everybody? Day one of RubyConf LA. Thank you guys very much for sharing your conference time with me.
00:00:22.859 My name is Andy. Thank you for your energy and thank you for being a member of this community that I love. We’re going to talk about designing physical products with Ruby. But first, I want to kick it off with a question: who in this room has been taken unexpectedly to an unexpected place with Ruby? Raise your hands!
00:00:35.700 Started something you didn’t know you could finish? Learned something you didn’t know you would learn? Accomplished something you didn’t think you could accomplish? Keep your hands up if that experience left you feeling limitless, like you can do anything. That is beautiful! I love it.
00:00:57.239 I’ve shared that experience, and that’s probably the biggest reason why I love what we do as Rubyists. It’s a beautiful journey to make software. It’s fun, it’s amazing, and I want to talk about being limitless.
00:01:08.580 I want to share with you the journey that led me here. It actually started last January at a café in Culver City, LA. When I initially applied to give this talk at RailsConf, I wanted to combine my passion for making things with a laser with my passion for making web apps. It was unfortunately rejected. I think I did what any enterprising individual would do: I crossed out Rails and put in Ruby, then applied to RubyConf and it was approved!
00:01:30.390 My first reaction was elation! I get to go back to LA from New York in the winter and work on this fun project. But my second reaction was worry—that this was going to be a case of CDD: conference-driven development. I had not done this yet. Can this work? Can I merge these things? Will there actually be a benefit to using Ruby to design these physical products?
00:01:54.400 And would Ruby even be the best tool for this? So, I panicked a little bit. I was freaking out. But then I thought about LA. I reflected on my craft as a Rubyist. To me, being a Rubyist means standing on the shoulders of our amazing community and creating with limitless possibilities. So, I got inspired again and said, 'Let’s build some software that is going to design physical items with limitless possibilities and variants!' So, let’s set off the objective.
00:02:28.030 Let’s say we want to build a Ruby program that will let a user design infinite variants of a physical product to laser-cut and etch. But first, like always, we need to develop all of our business community. We always ask, 'What’s the business case?'
00:02:48.230 The business case is that we want to open up an e-commerce store. We want to sell custom laser-etched products. We want to have the mass customizable by the user. So, let’s build a Nike ID of something and automate the fulfillment process as much as possible. Let’s make it easy to run this as a business.
00:03:14.170 Before writing any lines of code, we did some research. That’s the smart thing to do that we often forget to do. I wanted to see who out there is doing something similar with Ruby or otherwise.
00:03:18.329 The first thing I came upon was Make a Box, which was awesome because I had actually used it in the past. It was built by a San Francisco-based Rubyist, Kingster, on GitHub. It’s a website that allows any user to make a custom box with any dimensions. This is a dynamic design system built in Ruby. The underlying code is actually open-sourced and included in this laser cutter, which you can check out.
00:03:55.980 Here’s the output of that: we put in some dimensions, and we get a vector PDF design of a box. This is what I’m talking about. This is what I want to do!
00:04:06.290 There are also some businesses that I found operating on similar principles of user-driven design systems. One is called The Night Sky, which lets you design a poster of the stars at any location and date. They’re selling them for 60 bucks a pop on their website.
00:04:40.630 Another is Mapiful, which creates beautiful posters of maps that any user can customize. This is a map of LA. I tried to color it with traffic, but that option wasn’t available. That’s 55 bucks on their website.
00:05:03.320 Also, I really love Printful. I’ve been following them for a while. It’s an automated printing and fulfillment service with maybe a hundred products—from pillows to tote bags to socks, shirts, and mugs. They have integrations with Ruby and Shopify.
00:05:28.920 You can send them a design via an API, and they will handle fulfilling and printing a custom product, which I think is pretty cool. I was scared before, but now I’m running the numbers, getting excited! I see dollar signs on this thing. I think we can use these principles to create software that can generate revenue and potentially build a business.
00:06:01.950 But let’s focus back on the laser. Let’s start off by making something via the normal process. I got into this craft because I want to take the joy I experience in making digital products as a Rubyist and transfer it into making things that I can touch and feel.
00:06:37.350 So, let’s go through it. I got this vector of the 2018 RubyConf logo emailed to me by B. Phoenix. She said it’s okay if you need it for your slides. I don’t know if this is exactly what she meant, but it worked. I popped open Illustrator and made a large sheet of them.
00:07:08.340 One thing to note about designing is that if we use black with the laser cutter, it will etch, while if we use a point-01 point red line, it will cut. So those are just different settings on the laser cutter. Here’s some common materials I’ve used in the past when laser cutting: acrylic, metal, wood, cork, leather, and paper. I wanted to use wood, and that’s what I had in the shop.
00:07:48.150 We’re going to pop open our handy Trotec Speedy 400. Next, we’re going to focus the laser. This little metal tool ensures that the laser is the proper distance from the material. It can be really dangerous if you don’t do this step, so it’s a very important one.
00:08:12.970 Then we’re going to set some settings while we print. First off, we’re going to set the material. This gives us some predefined settings, and I’ll set the size of what we’re going to cut, including the width and height in inches. Next, we set the cut and etch power and velocity. Black is for etching, as we talked about, and red is for cutting.
00:08:56.020 Two important things here are the power, which is the intensity of the beam, and the speed, which controls how fast the laser will move. If it’s slower, it means it’ll be on the material longer, which increases its intensity. What’s important to note is that while we’re doing this for red and black right now, you can design any design with different settings per color.
00:09:40.289 We’re also going to use an awesome Windows program called Trotec Job Control. After preparing everything, we cut some designs. I think it took about six minutes to make six of these, but the speed is dependent on how you design it. More etching time can definitely be optimized.
00:10:18.129 My favorite part is the cutout, which you’ll see in a second.
00:10:43.870 [Visual satisfaction as the cutout finishes] Yes! Very satisfying! I've got some rubies here that I brought with me. I have them up here; please do come up and take some of these as a little souvenir of our time together today. They look pretty rad, I think.
00:11:12.880 Now that we have made a ruby, let’s make more with Ruby! First, we want to source some products for our e-commerce store. We will do a little research.
00:11:30.490 We’re going to start sourcing three products. One is a notebook from Muji, which will come out to 70 cents a unit. From Alibaba, I found a felt laptop sleeve that we can etch into, and a phone case for $1.64 and $2.40 respectively.
00:11:53.950 To make these designs, I’m going to use my all-time favorite Rails gem: Prawn. Who's used Prawn before? Great, it’s super popular! I really never appreciated how powerful it was until this project, so it was exciting to revisit a tool that I'd struggled with in the past.
00:12:17.270 We’re going to make a little app set up with two basic models. We’ll create a template and an item. A template will have just two attributes right now: a name and a size. We’ll make a template for each of our product types. You’ll notice that we're using this .in method, which converts inches to points.
00:12:43.460 This is actually an extension on Prawn called Measurement Extensions, as Prawn usually works in points. Now, for the item: the first thing to note is it’s an inherited class from Prawn Document. It didn’t need to be done this way, but I thought it was clean.
00:13:09.020 For this application, the sample app will just initialize these items. We provide it with a template name, and it loads that template. Then, we set the Prawn document page size based on that template. The margins will be zero, so we can work on that document without any margins.
00:13:38.251 Next, we register the fonts that are usable and select which font we want to use based on the options the user provides. We draw the design, which is where the magic happens. Finally, we render the file in Illustrator format; it could be a PDF. Illustrator can open both.
00:14:16.390 Next, we draw the design. We have five methods here, and I probably could have put them in their own classes, but for this case, it doesn’t really matter. I’ll go through each of the five cases, each of which will be a different system that we create to customize these products.
00:14:51.600 The first thing is simply putting text. We’re going to say, 'Okay, let’s put some text on each item in a specified font.' Then we’ll call the Prawn text method and pass it the copy. We also set a few things: the size, alignment, and color. An important note is that the mode is set to 'fill clip,' which renders the font as a vector and not as text—this is crucial for the laser cutter to read it properly.
00:15:31.950 If I run something like 'item.new' for a laptop sleeve and take a random font, I can make myself a little laptop sleeve, which is rad! I can also make a laptop sleeve for every RubyConf speaker that is here by looping through a bunch of names and putting them in.
00:15:54.720 The next thing I want to do is add some kind of graphic. So, I decided to get an SVG graphic onto one of the items. To do this in a flexible way, I wanted to use an API.
00:16:15.960 I found the Noun Project API, which is excellent for finding icons for web apps. I found a Ruby gem created by Taylor Brands, a website that generates logos. They recently published this API in Ruby.
00:16:46.500 I made a simple Noun Project client where you can pass it a term, and it will return an icon. Then, let’s look back at our item and view the 'draw icon' method.
00:17:05.520 This method will pull the icon from Noun Project and render it onto the document. Here, we position it at the center of the page vertically and horizontally, setting its width to 40% of the page.
00:17:21.990 One interesting point about Prawn is this SVG call; it’s not native to Prawn. It was created by GitHub user Beau Guest, who made Prawn SVG. This functionality allows us to place SVG files within our PDF.
00:17:54.250 If I want to make an iPhone case with a Ruby symbol, here we go! It’s pretty straightforward; just use 'item.new,' specify the template, and pass it an icon. If I want to make a bunch of iPhone cases using a random list of strings related to Los Angeles, I can also do that.
00:18:26.420 Next is the third case: creating a templated product. I wanted to create something that follows a more rigid format while allowing the user to determine what to fill it in with. I figured that let’s make something with tweets.
00:19:02.250 I used the Twitter gem from SF Eric to create a simple client to search for tweets. By passing in a term, I can find a bunch of tweets. In our 'draw tweet' method, we take a Twitter icon that I had downloaded previously, and we use the SVG method to place it in the top corner of the page.
00:19:26.770 Then, we use the font Cardo and put the tweet text in the center of the page, followed by the user’s screen name and the date. By using our Twitter client, we can find every tweet with the hashtag #RubyConf.
00:19:51.050 We can create numerous Ruby-themed designs on this laptop sleeve! This is really neat because who wouldn’t want to memorialize people desperately trying to get RubyConf tickets this week?
00:20:16.080 Let’s change it up a bit and try to make a full bleed pattern on the page, something that covers the entire item we’re going to etch into. Let’s start with a sheet of equilateral triangles. To do this, I'll introduce some variables that will allow us to create more variants.
00:20:54.250 The first thing we’ll do is set a size factor, which is just a percentage that determines the width of each triangle. If the size factor is 0.2, each triangle will have a width of 20% of the entire page. Then, we’ll calculate the triangle’s width and height using some trigonometry.
00:21:25.550 We can determine how many rows and columns we need based on the height and width, and then we set the starting position on our Prawn document to (0, 0), the bottom left corner of the page. By looping over the columns and rows, we can easily generate rows of triangles.
00:21:52.920 Instead of creating a static pattern, we’ll introduce some randomness. The fill factor will determine the chance of a triangle being filled versus outlined. The omission factor will dictate the chance not to render a triangle, providing a more random-feeling pattern.
00:22:18.540 The punch factor will determine the percentage chance to outline a triangle in a red stroke. This code uses the logic to decide randomly whether to fill or leave out triangles to create a visually unique design.
00:22:45.080 Now, if we want to write a script using all the variables we’ve already created, we can set two type options—square and triangle—and then set ranges for the size factor, fill factor, omission factor, and punch factor. Over some time, we can generate multiple phone cases with random patterns easily.
00:23:12.700 This will allow us to create varied output! Ultimately, for the final case, we will design nested patterns—a design consisting of other patterns—using six cubes I whipped up in Illustrator.
00:23:38.250 We’ll use an array of our cubes with variable size and random order. After declaring this, we can loop through and generate a creative pattern of cube arrays.
00:24:42.750 I’ve included all these examples on my GitHub if you want to check it out. The project is called Layers, in homage to Prawn.
00:25:01.930 Thank you in advance for your stars on GitHub! I also wanted to go over some other resources I found interesting while working on this talk.
00:25:23.430 One thing was a tool called Geo Pattern, created by a Rubyist named Jason Long, which generates unique geometric patterns based on a string.
00:25:50.180 These patterns vary in shades and gradients, offering interesting visuals. Another tool worth mentioning is Processing. Processing is an object-oriented language for coding visual designs, and it allows SVG exports.
00:26:11.540 I considered using Processing for this entire project, but I chose to stick with classic Ruby tools. However, there is a Ruby port of Processing named JRuby Art that’s worth checking out.
00:26:28.530 I thought a lot about automating the laser, and although there are ways to do it according to various resources, I didn’t see a practical benefit given my access to the Trotec model.
00:26:46.030 Just practically speaking, there are opportunities to create a business using the limitless creativity we have in this space, producing custom items while enjoying this process.
00:27:05.200 That is pretty much it! Thank you all for your time! I really do appreciate it. I love speaking about things I’m passionate about, and I appreciate you lending me your time.
00:27:29.150 I would love any feedback you can provide. I want to hear what I could improve on. A shameless plug: I run a software development agency based in Brooklyn, New York, called Bang Equals.
00:27:50.480 I rock the Bang Equals hat. Chance the Rapper made six million dollars selling his hats last year! My mom has this in three colors. Get in touch if you're looking to work together or if you know a company looking to hire an agency!
00:28:07.830 Thank you for listening! It’s a joy to be a Rubyist, and I hope you all feel that same joy. Keep these explorations in mind as you experience RubyConf this week!
00:28:36.150 Please feel free to come up and chat with me afterward! Here’s my email. Please take one of these laser-cut rubies! I would really appreciate your questions.
Explore all talks recorded at RubyConf 2018
+86