Giter Site home page Giter Site logo

piebro / factorio-blueprint-visualizer Goto Github PK

View Code? Open in Web Editor NEW
136.0 2.0 3.0 3.25 MB

A python library to artfully visualize Factorio Blueprints and an interactive web demo for using it.

Home Page: https://piebro.github.io/factorio-blueprint-visualizer/

License: MIT License

Python 27.06% HTML 2.45% Jupyter Notebook 70.49%
factorio visualization generative-art factorio-blueprints python pyodide

factorio-blueprint-visualizer's Introduction

Factorio Blueprint Visualizer

I love the game Factorio and I really like the look of factories after growing for many hours or blueprints after tweaking them for perfection. So I thought about visualizing the factories and blueprints.

All factorio buildings with their bounding boxes and belt, pipe, inserter, wire and electricity connections can be visualized. Everything is drawn in vector graphics (SVG) to be able to view it in any resolution.

The hardest part was writing the logic for connecting rails, belts and pipes. After many failed attempts with lots of bugs, I wrote a system that works pretty well. The next step was, to be able to be creative with drawing different connections and bounding boxes of buildings. Therefor, I created configurable drawing settings to experiment with and a random draw settings generator. After some tweaking, I got nice visualizations. To make the visualization tool easily accessible, I created an online demo that uses the original python code with pyodide in the browser (that's why the website might take some time to load) and an easy-to-use notebook.

Examples

The last three blueprints are by Josh Ventura and can be found here.

Usage

You can visualize your own blueprint with random drawing settings at: https://piebro.github.io/factorio-blueprint-visualizer (You can use the arrow keys for going through the visualization). You can use the notebook, if you want to create your own drawing settings or tinker some more. For an easy setup, you can open the example notebook in colab or binder. You can find many blueprints at: https://www.factorio.school. You can also use show factorio.school blueprints directly by adding ?source=factorio-school-blueprint-url to the URL (e.g. https://piebro.github.io/factorio-blueprint-visualizer?source=https://www.factorio.school/view/-Mh4rtNMEm3CnDkTRc69)

Open In Colab Binder

Drawing Settings

To visualize a blueprint you need drawing settings that define what is drawn, in which order and in what kind of style. Drawing settings are a list of option that are executed one after the other. You can decide which bounding box to draw with an allow or deny list of building names. You can also draw connected belt, underground-belts, pipes, underground-pipes, inserter, rail, electricity, red-circuits and green-circuits.

Furthermore, you can define the style of each drawing command or set a new default drawing style. You can use fill, stroke, stroke-width, stroke-linecap, stroke-opacity, fill-opacity, bbox-scale, bbox-rx and bbox-ry as properties and every SVG tag should also work.

Every visualization has the used drawing settings and blueprint saved with it, so you can check out the drawing settings of the examples blueprints inspiration.

Text to Image

I created a dataset with images generated using this tool to finetune SDXL (a text-to-image neural network). The model with examples can be found here: https://huggingface.co/piebro/factorio-blueprint-visualizations-sdxl-lora

Pen Plotting

I have a pen plotter, and one of my initial ideas was also to be able to plot my factories. You can create visualizations you can easily draw. I recommend using https://github.com/abey79/vpype for merging lines together before plotting. An example of a visualization for plotting is here:

verilog2factorio

It's possible to use https://github.com/redcrafter/verilog2factorio to create factorio verilog blueprints and visualize the buildings and wire connections like this.

Convert to PNGs

To easily convert all SVGs in a folder, you can use a terminal and Inkscape like this. mkdir pngs; for f in *.svg; do inkscape -w 1000 "$f" -e "pngs/${f::-3}png"; done

Contribute

Contributions to this project are welcome. Feel free to report bugs or post ideas.

To update the python code for the website, you have to update the python wheel in the website folder. To update it, just run: python setup.py bdist_wheel --universal --dist-dir=website

To update the installed version while developing you can use python setup.py bdist_wheel --universal --dist-dir=website && pip uninstall factorioBlueprintVisualizer -y && pip install website/factorioBlueprintVisualizer-1.1.0-py2.py3-none-any.whl

If you use an external api on localhost (e.g. for getting the blueprint from factorio.school) you need to disable CORS. To start Chrome on Ubuntu with CORS disable you can use google-chrome --disable-web-security --user-data-dir=temp http://0.0.0.0:8000/.

Statistics

There is lightweight tracking with Plausible for the website to get infos about how many people are visiting. Everyone who is interested can look at these stats here: https://plausible.io/piebro.github.io%2Ffactorio-blueprint-visualizer?period=all

factorio-blueprint-visualizer's People

Contributors

piebro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.