tulio-a-cardinal / slide-rule-scales

Python library for creating completely customisable slide rule scales.
MIT License
5 stars 2 forks source link
slide-rules sliderule

slide-rule-scales

This is a Python library for creating completely customisable slide rule scales.

Visual Example

visual preview A set of front and back circular slide rule scales created using the outputs from VisualExample.py.

Required Python libraries

NumPy pip install numpy
pandas pip install pandas
svgwrite pip install svgwrite

Folder structure

SlideRuleScales/
├─__init__.py <--------------
├─SlideRuleScale.py <--------
├─scale.py
└─scale_dir/
  ├─scale_specs_dir/
  │ ├─draw_specs.csv
  │ └─scale/ <---------------
  │   ├─Core.csv <-----------
  │   ├─x-y.csv
  │   ├─y-z.csv
  │   └─one-offs.csv <-------
  └─scale.svg

"<---" Indicates fixed names. All other names may be changed, together with their references. x, y and z are numbers. More details below.

Scale specs files structures

Draw specs file structure

Standard scale.py file structure

Header

from SlideRuleScale import SlideRuleScale
import os
os.chdir("./scale_dir/")

Object manipulations:

                 Initialization - Scale = SlideRuleScale("./scale_specs_dir/scale/")
             Scale type setting - Scale.set_scale_type(scale_type, invert_scale=0, positioning_factor=1, log_base=10)
                                  scale_type: scale types (Mannheim based). Such as A, B, C, D, K, ST, S, T, P, L.
                       (optional) invert_scale: whether the scale should be inverted or not, such as in the CI scale.
                       (optional) positioning_factor: adjusts the position of the scale. Usually a multiple of log_base.
                       (optional) log_base: the base of the logarithm. Base 10 for the decimal number system.
Exporting svg of straight scale - Scale.draw_straight("./scale.svg", "./scale_specs_dir/draw_specs.csv")
Exporting svg of circular scale - Scale.draw_circular("./scale.svg", "./scale_specs_dir/draw_specs.csv")