Vai al contenuto principale

#typescript

A small code snippet for a current shop admin task, to help me with preparing different print size options in both inches and centimete

Altro...

A small code snippet for a current shop admin task, to help me with preparing different print size options in both inches and centimeters, grouped by landscape, portrait or square format.

The script illustrates how to functionally iterate over all possible sizes in a min/max range, converting & formatting units and grouping sizes based on their aspect ratio. All mostly relies on https://thi.ng/transducers and https://thi.ng/units for different transformation/conversion steps.

I'm posting this since in a recent poll people had indicated that they'd like to see more code snippets for using my libraries — maybe someone finds it as an useful reference...

Full source code:
https://gist.github.com/postspectacular/a122ab9c1cd52934b8093461231c6044

Syntax colored TypeScript source code. Full version here: https://gist.github.com/postspectacular/a122ab9c1cd52934b8093461231c6044 Resulting text output of print sizes grouped by aspect ratio. Full source: https://gist.github.com/postspectacular/a122ab9c1cd52934b8093461231c6044

Excerpt:

square:
4 × 4 inch (10 × 10 cm)
5 × 5 inch (13 × 13 cm)
6 × 6 inch (15 × 15 cm)
...

landscape:
5 × 4 inch (13 × 10 cm)
6 × 4 inch (15 × 10 cm)
7 × 4 inch (18 × 10 cm)
...

portrait:
4 × 5 inch (10 × 13 cm)
4 × 6 inch (10 × 15 cm)
5 × 6 inch (13 × 15 cm)
...

#javascript #photography #thingumbrella #typescript #functionalprogramming #transducers #unitconversion

0

Caricamento...

0
0

Caricamento...