Giter Site home page Giter Site logo

drawlib2's Introduction

Drawlib

Drawlib is a simple CLI/TUI drawing library (renderer) made in python.

Author: Simon Kalmi Claesson

  • For version information see lib.json

Files:

  • ̲ ̲ init__.py: Contains the renderer wrapper class. (As well as functioning as the package root)
  • assets.py: Asset/TextureAsset rendering and handling functions.
  • coloring.py: Mostly internal but contains functions and palettes for handling colors and advanced formatting in drawlib.
  • consoletools.py: Contains some tools regarding console, for example sizeAssist. (Not to be confused with /libs/conUtils)
  • core.py: As the name implies contains the core of drawlib, the Exceptions/Classes and main functionality.
  • dtypes.py: Datatype classes for converting and handling data in drawlib.
  • fonts.py: Additional tools for font management, requires BeutifulSoup4 and matplotlib.
  • generators.py: Contains some character-generators for use with shapeObjects from objects.py (Not to be confused with shapes from /shapes.py)
  • imaging.py: Contains classes/wrappers for the imageRenderer functionality of drawlib.
  • legacy.py: Contains legacy/broken/deprecated code, no support will be given for anything in here.
  • linedraw.py: Contains functions for linedrawing, including some functions for some predefined shapes.
  • manip.py: Tools and functions for manipulating texture-data.
  • objects.py: Contains some premade shape-classes buidling on drawlibObj, support for character-generators.
  • pointGroupAlgorithms.py: Contains raster-algorithms for drawlibs included shapes/linedrawers.
  • shapes.py: Contains classes for some premade shapes, building on the linedraw.py implementations. (No support for character-generators)
  • terminal.py: The most basic core functionality of drawlib, its building-blocks live here. Some basic ANSI rendering functions.
  • tools.py: Contains some tools for internal use in drawlib aswell as use by the users.
  • tui.py: Contains functions for rending some TUI related things, in short data-visualisers.
  • version.py: Contains some tools regarding drawlib versioning and reading lib.json.

Difference between objects.py and shapes.py

As noted above objects.py and shapes.py are very similar, except classes from objects.py support character-generators.

The classes in objects.py are based of the datatypes, more specifically splitPixelGroup. Thus allowing for more use cases.

The classes in shapes.py are instead building directly of the linedrawer functions and exists more to halfly "object-orient" the linedrawer functions.

They are kept in their own file since merging with linedraw.py would make it even harder to understand the difference. (In my opinion)

Examples:

Buffered Outputs

# Importing from the definitions in __init__.py
from Drawlib2 import DrawlibOut # alias to core.DrawlibOut

# Creating a drawlib output object with a buffer
out = DrawlibOut(mode="Buffer")

# We use the put method to place an "X" character on the position 0,0.
out.put(0,0,"X")

# Draw draws our buffer to the screen
out.draw()

Console Outputs

# Importing from the definitions in __init__.py
from Drawlib2 import DrawlibOut # alias to core.DrawlibOut

# Creating a drawlib output object with a console-connector, thus we won't have to use the draw function just .put() when drawing.
out = DrawlibOut(mode="Console")

# We use the put method to place an "X" character on the position 0,0. (Since we are using console output, "putting" just places it on the screen)
out.put(0,0,"X")

Notes:

Fonts.py has some tools to check if a user has nerd-fonts installed, see www.nerdfonts.com. The function scrapes their download page to get a list of fonts, thus it can break at any time. The script won't download any fonts just check if the user has them installed, but best of al would be to download the font you need yourself and tell your users to do the same.

I am in no way a part/contributor/affilate with the amazing nerdfont team, so if anyone on the team has a problem with this just contact me and i will see what i can do.

But thank you nerdfont team for your work!

drawlib2's People

Contributors

sbamboo avatar

Watchers

 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.