Code Monkey home page Code Monkey logo

ambigramgenerator's Introduction

3D Ambigram Generator

In case you somehow got here when you meant to see the actual tool, here's the link: https://2catteam.github.io/AmbigramGenerator/

This is a fun tool I developed for developing 3D ambigrams from arbitrary words or phrases.

An ambigram is a calligraphic design that has several interpretations as written. In simpler terms, it's a design in which the meaning changes depending on perspective.

While traditionally ambigrams are 2D, I've always found that 3D ambigrams are just as awesome, if not moreso (And apparently lots of people agree with me). In addition, 3D ambigrams are incredibly easy to create, requiring nothing more than a simple series of intersect operations for the simplest models like that link shows.

This generator aims to add just one more layer of complexity to that idea. Rather than directly matching letters together in order, it instead splits the letters into parts, then randomly pairs each part up. The advantage of this over the one-to-one approach is twofold; first, I personally think it looks cooler. Second, and more importantly, it lets you create models where the two profiles don't match in length, which is something the one-to-one approach can't really do without adding other profiles. In my opinion, the result is really cool! Though, obviously, I am super biased, as the creator of the generator. Hopefully you agree! And hopefully you find this tool useful and cool!

Personally, I've found these make great gifts for friends. You can do their first and last name, or their name and a nice word, or for a couple, both of their names together... Just generate a file, send it to the printer, and your friend thinks you put, like, time and effort into making a custom gift just for them, when in reality, you just had extra time while you were waiting for your microwave burrito to finish. If you want to put slightly more effort into it, I've found that it looks great to spray-paint your models on one or both sides, so the two profiles stand apart from each other a little more. Just hold it at arm's length, and give it a light, light coat. I've also enjoyed putting them on rotating bases, so that you can see both words without having to move the model yourself.

Potential questions

What does the tool say some words are "too complex"?

Each character has a pre-programmed score, as shown in the table below:

Characters Score
Space 0
C, G, J, L, S, Z 1
A, D, F, H, I, K, M, O, P, Q, T, U, V, X, Y 2
B, E, N, R, W 3

So, the word "Default" has a score of 14. That means that the tool wants the word "Default" to be broken up into 14 different parts - 2 for the D, 3 for the E, 2 for the F, etc.

The tool will calculate the score of each of the words, then, if they don't match, it will reduce the score of the more complex word until they do. First, it will reduce the score of the 3-score letters by one. Then, it will reduce the score of all of the 2-score letters by one. If the letters still don't match, it will issue a warning, because reducing a face any further would make the resulting model look pretty lame on that face, IMO. It will then, if the user confirms it, reduce the score of the 3-score words by one again. If this was still not enough to make the word scores match, it will start duplicating letters, because at this point there is no other solution for matching the letters together. This should only be the case when the two words differ in length by a factor of 2 or 3.

Why do the letters not line up the same when I print the file I downloaded?

The tool uses an orthographic camera when displaying the files, rather than a perspective-based one. This means that, the further you are from your model, the closer your model will look to what the tool shows. In my experience, most models look fine from an arm's length away or more. This works fine if you put it on a shelf or something.

If you want to make your model easier to see from close-up, you can generate a file without a base, print the loose letters, and then glue them down on a flat sheet of wood or plastic or something, making adjustments as needed to make sure it shows up right from the distance you want it to.

What are the limitations of this software?

As noted above, it cannot generate a model for a particular perspective. It also currently only supports letters, numbers, and spaces. I currently have no plans to implement any more characters, since any characters beyond what is already supported would require a significant number of changes to the current algorithm. That said, feel free to submit any pull requests implementing new characters if you want.

Additionally, it has no way of identifying the ocassional instance where it matches letters such that there's small pieces left hovering, or other unnecessary little bits that are unsuitable for 3D printing. To fix this, you can re-roll the RNG on the model by adding unsupported characters to the input. So, if you're doing "Default" "Example", you can change it to "Default." ".Example" and get a different pairing of letters. If you need to keep re-rolling, just add more characters.

Why doesn't this tool support <feature>?

Primarily because I slapped this together in a weekend for fun. If you have something you want me to add, though, please let me know and I'll look into it (Unless that request is about additional characters - see above)! Better yet, if you want to add the feature yourself, I'm always open to pull requests!

There are probably more questions you may ask, but I can't think of any more right now, so as they get asked, I'll update this page with answers to them.

Libraries used

Generating and manipulating 3D geometry is a hard task at the best of times, and I couldn't have done it without the following libraries:

Three.js - The core library that the project is built on.

Three-CSGMesh - Super underappreciated library that implemented the intersect operations that made this tool possible.

JQuery - because everything needs JQuery

Gif.js - Lets me render the gifs for sharing

FileSaver.js - Allows for downloading the files

Seedrandom.js - Allows files to be generated consistently. This is important because, if you print each letter individually and don't have access to the original file, it can be pretty tricky trying to guess where the pieces go (I've had this happen to me multiple times when I used a similar generator I made in VBA for Autodesk Inventor).

ambigramgenerator's People

Contributors

2catteam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.