<jupyter_start><jupyter_text>Setup<jupyter_code>!pip install git+https://github.com/piebro/factorio-blueprint-visualizer

# installing newest local wheel if code changed locally
# !pip uninstall factorioBlueprintVisualizer -y
# !pip install website/factorioBlueprintVisualizer-1.0.0-py2.py3-none-any.whl
from IPython.display import SVG, display
import factorioBlueprintVisualizer as bv
blueprint_cache = bv.get_blueprint_cache(bv.EXAMPLE_BLUEPRINT)
settings = bv.EXAMPLE_SETTINGS
svg_str = bv.draw_blueprint(blueprint_cache, settings, svg_max_size_in_mm=200)
display(SVG(data=svg_str))
bv.save_svg("svgs", "blueprint", svg_str)
# Every SVG has the drawing settings and blueprint saved with it. Check out the examples for inspiration.
# blueprint_cache = bv.get_blueprint_cache(bv.get_blueprint_from_svg('path/to/file.svg'))
# settings = bv.get_settings_from_svg('path/to/file.svg')

bv.pretty_print_settings(settings)
# customize the drawing settings
settings = [
  ['meta', {'background': '#a2aebb'}],
  ['svg', {'stroke': '#3f88c5', 'stroke-linecap': 'round', 'stroke-width': 0.25}],
  ['belts', {}],
  ['underground-belts', {'stroke-opacity': 0.6}],
  ['pipes', {}],
  ['underground-pipes', {'stroke-opacity': 0.6}],
  ['bbox', {'allow': ['drills'], 'fill': '#ffba08', 'stroke': 'none'}],
  ['bbox', {'allow': ['producing-machines'], 'fill': '#d00000', 'stroke': 'none'}],
  ['bbox', {'allow': ['furnaces', 'electricity-generators', 'boiler'], 'fill': '#1c3144', 'stroke': 'none'}],
  ['bbox', {'allow': ['lab'], 'fill': '#1c3144', 'stroke': 'none'}],
  ['bbox', {'deny': ['transportation', 'electricity', 'inserters'], 'fill': 'none'}],
]
svg_str = bv.draw_blueprint(blueprint_cache, settings, svg_max_size_in_mm=250, aspect_ratio=(1.5, 1))
display(SVG(data=svg_str))
# draw custom blueprint
encoded_blueprint = "<KEY>
# if you want to view or edit the traditional blueprint without opening factorio, you can use: https://fbe.teoxoy.com/
blueprint_cache = bv.get_blueprint_cache(encoded_blueprint)
svg_str = bv.draw_blueprint(blueprint_cache, settings, svg_max_size_in_mm=200)
display(SVG(data=svg_str))
# there are some building abbreviations which define a set of buildings (e.g. 'chests' => ['wooden-chest', 'iron-chest', ...])
# all abbreviations are defined in 'BUILDING_GENERIC_TERMS'
print(list(bv.BUILDING_GENERIC_TERMS.keys()))
print(bv.BUILDING_GENERIC_TERMS['chests'])
# use settings_change_colors to randomly change the colors
settings = bv.settings_change_colors(settings)
svg_str = bv.draw_blueprint(blueprint_cache, settings, svg_max_size_in_mm=200)
display(SVG(data=svg_str))
# get random drawing settings for the blueprint
settings = bv.get_random_settings()
svg_str = bv.draw_blueprint(blueprint_cache, settings, svg_max_size_in_mm=200)
display(SVG(data=svg_str))
# use custom building settings for new building_generic_terms or to add building for mod support
new_building_generic_terms = {
    "fast": ["fast-transport-belt", "fast-inserter", "fast-underground-belt"],
}
building_settings = bv.get_custom_building_settings(new_building_generic_terms=new_building_generic_terms)
blueprint_cache = bv.get_blueprint_cache(encoded_blueprint, building_settings=building_settings)

settings = [
  ['meta', {'background': '#000001'}],
  ['svg', {'bbox-scale': 0.7, 'stroke': '#000002', 'stroke-linecap': 'round', 'stroke-width': 0.25}],
  ['bbox', {'allow': ['producing-machines'], 'fill': '#000003', 'stroke': 'none'}],
  ['bbox', {'allow': ['fast'], 'fill': '#000004', 'stroke': 'none'}],
]
settings = bv.settings_change_colors(settings)
svg_str = bv.draw_blueprint(blueprint_cache, settings, svg_max_size_in_mm=200)
display(SVG(data=svg_str))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16495124593716143, 'fraction_numerical': 0.02275189599133261, 'mean_word_length': 7.568445475638051, 'pattern_counts': {'":': 1, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '381810', 'license': 'MIT', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1299, 'n_words': 266, 'path': 'notebook.ipynb', 'repo_name': 'piebro/factorio-blueprint-visualizer', 'size': '6517'}