slideruleimages
Python package to produce Slide Rule SVG images
A typical example might be:
from slideruleimages import Rule
# xvalue is where the C scale index is placed over the D value
# right is True if the mid scale is moved to the right
# right is False if the mid scale is moved to the left
# hairline is where the hairline cursor is placed over the D value,
# or zero if no hairline is used
rl = Rule(xvalue = 2.0, right = True, hairline=6.0,
topruleheight = 0, # No top rule
midruleheight = 120, # middle slider 120px high
btmruleheight = 120) # bottom rule 120 px high
# Add a C scale
rl.addCscale(midrule=20) # indicates this scale is put on the middle rule
# 20 pixels down from the top of the middle rule
# Add a D scale
rl.addDscale(btmrule=0) # indicates this scale is put on the bottom rule
# 0 pixels down from the top of the bottom rule
filename = "twoxthree.svg"
rl.write(filename)
print(f'{filename} created')
This would produce:
Each scale is 100px high, so in the example a midruleheight of 120 is set, with the C scale set onto the midrule, with a 20px space at the top of the rule, and the actual scale sitting against the bottom of the rule.
This package is intended to produce images useful for documents or web sites which illustrate logarithms or Slide Rules. One such web site is available at:
https://bernie-skipole.github.io/sliderule/
The package has one class, Rule, which has arguments, and defaults:
xvalue:float = 1.0,
right:bool = True
hairline:float=0.0
topruleheight:int = 120
midruleheight:int = 200
btmruleheight:int = 120
col:str = "#f9fc69"
The col string is an SVG color, by default a pale yellow, this can be set to a string such as "white" if a black and white printable rule is required.
The Rule class has methods:
write(filename)
addAscale(btmrule=-1, midrule=-1, toprule=-1)
addBscale(btmrule=-1, midrule=-1, toprule=-1)
addCscale(btmrule=-1, midrule=-1, toprule=-1)
addCFscale(btmrule=-1, midrule=-1, toprule=-1)
addCIscale(btmrule=-1, midrule=-1, toprule=-1)
addDscale(btmrule=-1, midrule=-1, toprule=-1)
addDFscale(btmrule=-1, midrule=-1, toprule=-1)
addDIscale(btmrule=-1, midrule=-1, toprule=-1)
addKscale(btmrule=-1, midrule=-1, toprule=-1)
addLscale(btmrule=-1, midrule=-1, toprule=-1)
addLL00scale(btmrule=-1, midrule=-1, toprule=-1)
addLL01scale(btmrule=-1, midrule=-1, toprule=-1)
addLL02scale(btmrule=-1, midrule=-1, toprule=-1)
addLL03scale(btmrule=-1, midrule=-1, toprule=-1)
addLL0scale(btmrule=-1, midrule=-1, toprule=-1)
addLL1scale(btmrule=-1, midrule=-1, toprule=-1)
addLL2scale(btmrule=-1, midrule=-1, toprule=-1)
addLL3scale(btmrule=-1, midrule=-1, toprule=-1)
addPSscale(btmrule=-1, midrule=-1, toprule=-1)
addPTscale(btmrule=-1, midrule=-1, toprule=-1)
addSscale(btmrule=-1, midrule=-1, toprule=-1)
addSTscale(btmrule=-1, midrule=-1, toprule=-1)
addTscale(btmrule=-1, midrule=-1, toprule=-1)
The write method saves the image file.
When adding a scale, only one of the arguments btmrule, midrule or toprule should be given a non -1 argument which indicates which rule the scale should appear on, and the integer number of pixels down from the top of that rule.
Scales are normally orientated with numeric characters above the scale, as shown on the C scale above, but if the value of zero is used, with the scale set to the top of a rule, then the characters are set below the scale, as shown on the D scale above.
The package is available on Pypi at:
Release files for slideruleimages 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| slideruleimages-0.0.9.tar.gz | 12.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| slideruleimages-0.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.1 kB
Release files / slideruleimages-0.0.9.tar.gz
| Download URL | slideruleimages-0.0.9.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0241e3300e7aa7f146101a09dcae5bd8f8c36f5b5aac536ef79b64ac0bac5886
|
|
BLAKE2b-256 checksum How to use checksums |
b1787dcbb0cfa79102b9fdf93ec79dce90b6e0845215b210ad208f47cf2ff5c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.5
|
Release files / slideruleimages-0.0.9-py3-none-any.whl
| Download URL | slideruleimages-0.0.9-py3-none-any.whl |
|---|---|
| Size | 28.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9fb80db1deed13686a6c87fc9ab53e2a482d52aa4d74cf4f8ee78dff3ea2b53a
|
|
BLAKE2b-256 checksum How to use checksums |
c60108be2df4b35f648f55610f46afcb261059bec105b83a1d548f006480765c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.5
|