Giter Club home page Giter Club logo

lego-python-mosaic's Introduction

lego+python=mosaic

Program LePyMo was developed to simplify creating mosaic from images using Lego-like bricks.

LePyMo - main window

The idea

I was thinking about a birthday gift for my fiancée, and I came with this concept - to create a mosaic using our pictures and Lego bricks.

How does it work ?

Firstly this program transforms selected image to a palette of certain colors. After that LePyMo creates a PDF containing building instructions for this new image.

How to run LePyMo ?

There are 3 ways to run this program:

Using LePyMo.exe created by myself

This is the easiest one - just download .exe from here.

Running script

Using Makefile - Linux only

Clone this repository to your hard drive with:

git clone https://github.com/kjuraszek/lego-python-mosaic

Set virtual environment and install dependecies:

make venv && make reqs

Run program:

make run

Create executable:

make reqs-dev && make dist

Windows

It's a good idea to create and activate a virtual environment first using e.g. virtualnenv.

Clone this repository to your hard drive with:

git clone https://github.com/kjuraszek/lego-python-mosaic

Install packages in project directory using e.g. pip and requirements.txt file.

pip3 install -r requirements.txt

Run program:

python3 lepymo.py

Creating .exe on your own

This is a similar way to the previous one. Instead of running .py script - you build an executable file (.exe). You can use pyinstaller:

pyinstaller --onefile --windowed --icon=app.ico --version-file=version.txt lepymo.py

How to use it ?

First you have to prepare your desired image - its dimensions (in pixels) must be equal to the size (in bricks) of mosaic you are planning to create. E.g. when your plate is 50 by 50 bricks, your image dimensions must be 50px by 50px.

The next step is to add colors to your palette. Keep in mind that some colors aren't used in brick production - you are limited to less than 300 colors. At this stage it is better to keep Don't generate PDF option turned on to test selected color palette. The process of creating desired image can take even up to a few minutes - it depends on amount of colors in your palette and dimensions of image.

You also can add colors to the palette using .csv file - look at example-colors.csv file. Each row represents one color, and each column - red (R), green (G) or blue (B) part of color (in that order). You can use HEX instead of RGB format of the colors - insert a full color respresentation (with # symbol) in the first column. Each column must be separated with semicolon ; and each row with a newline.

When you are satisfied with output image you can turn off Don't generate PDF option. This process also can take up to a few minutes - it depends on amount of colors in your palette and dimensions of image. The PDF consists of total bricks amount of each color and building instructions divided in steps - each step is one row.

You can stop current action using Abort button - all files created in current run will be removed. You can clear inputs (source image, color palette, No PDF checkbox) using Clear button.

Have fun!

Brick colors in real life

Here are some links which might be useful to determine your color palette (based on bricks used in real sets):

Disclaimer

LEGO® is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this project.

Examples

Build instructions:

LePyMo - Building instructions main page LePyMo - Building instructions step 11 LePyMo - Building instructions Sandro

Final effect:

LePyMo - final effect LePyMo - final effect

Mosaic timelapse:

(click to watch it on Youtube) Lego Mosaic Timelapse Video

lego-python-mosaic's People

Contributors

kjuraszek avatar

Stargazers

 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.