Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-develop

Source of release 0.1.0

0.1.0 / tools / parameters.py

#!/usr/bin/env python3
"""Write src/parameters.lucb: every develop parameter's name, label, Properties
section, range, default and decimals, and the Parameter enum Base code reads
them by. Edit the list here, then run tools/parameters.py."""
from pathlib import Path
# (name, label, section, low, high, default, decimals)
P=[]
def add(n,l,s,lo,hi,d=0.0,dec=0): P.append((n,l,s,lo,hi,d,dec))
add("temperature","Temperature","White Balance",0,50000,0,0)
add("tint","Tint","White Balance",-150,150)
add("exposure","Exposure","Exposure",-6,6,0,2)
add("exposure_time","Shutter","Exposure",0,3600,0,3)
for n in ["contrast","highlights","shadows","whites","blacks"]: add(n,n.capitalize(),"Tone",-100,100)
add("film_stock","Stock","Film",0,31,3,0)
add("film_format","Format","Film",0,5,0,0)
add("film_filter","Balance","Filter",0,5,0,0)
add("film_color_filter","Color Filter","Filter",0,8,0,0)
add("develop_process","Process","Develop",0,31,0,0)
add("develop_time","Time","Develop",0,30,0,2)
add("develop_temperature","Temperature","Develop",0,50,0,1)
add("develop_silver","Bleach Bypass","Develop",0,100)
add("develop_agitation","Agitation","Develop",0,3,0,0)
add("film_interimage","Interimage","Film",0,200,100)
add("film_grain","Grain","Film",0,200,100)
add("film_halation","Halation","Film",0,300,100)
add("film_backing","Backing","Film",0,1,0,0)
add("film_flash","Flashing","Film",0,50,0,1)
add("film_warmth","Warmth","Scan",-100,100)
add("film_tint","Tint","Scan",-100,100)
add("film_contrast","Contrast","Scan",-100,100)
add("film_black","Black","Scan",0,100,50)
add("scan_calibration","Calibration","Scan",0,1,0,0)
add("levels_black","Input Black","Levels",0,1,0,3)
add("levels_white","Input White","Levels",0,1,1,3)
add("levels_gamma","Gamma","Levels",0.1,10,1,2)
add("levels_out_black","Output Black","Levels",0,1,0,3)
add("levels_out_white","Output White","Levels",0,1,1,3)
add("vibrance","Vibrance","Color",-100,100)
add("saturation","Saturation","Color",-100,100)
bands=["red","orange","yellow","green","aqua","blue","purple","magenta"]
for b in bands:
    add(b+"_hue",b.capitalize()+" Hue","Color Mixer",-100,100)
    add(b+"_saturation",b.capitalize()+" Saturation","Color Mixer",-100,100)
    add(b+"_luminance",b.capitalize()+" Luminance","Color Mixer",-100,100)
for r in ["shadows","midtones","highlights","global"]:
    add("grade_"+r+"_hue",r.capitalize()+" Hue","Color Grading",0,360,0,0)
    add("grade_"+r+"_saturation",r.capitalize()+" Saturation","Color Grading",0,100)
    add("grade_"+r+"_luminance",r.capitalize(),"Color Grading",-100,100)
add("grade_balance","Balance","Color Grading",-100,100)
add("grade_blending","Blending","Color Grading",0,100,50)
add("bw","Black & White","Black & White",0,1)
defaults={"red":40,"orange":30,"yellow":20,"green":-10,"aqua":-20,"blue":-30,"purple":-10,"magenta":20}
for b in bands: add("bw_"+b,b.capitalize(),"Black & White",-200,300,defaults[b])
add("bw_tint_hue","Tint Hue","Black & White",0,360)
add("bw_tint_amount","Tint Amount","Black & White",0,100)
add("lens_vignetting","Vignetting","Lens",0,100)
add("lens_midpoint","Midpoint","Lens",0,100,50)
add("lens_coating","Coating","Lens",0,2,0,0)
add("lens_diffusion","Diffusion","Lens",0,6,0,0)
add("vignette_amount","Amount","Vignette",-100,100)
add("vignette_midpoint","Midpoint","Vignette",0,100,50)
add("vignette_roundness","Roundness","Vignette",-100,100)
add("vignette_feather","Feather","Vignette",0,100,50)
add("geometry_rotate","Rotate","Geometry",-45,45,0,1)
add("geometry_vertical","Vertical","Geometry",-100,100)
add("geometry_horizontal","Horizontal","Geometry",-100,100)
add("geometry_aspect","Aspect","Geometry",-100,100)
add("geometry_scale","Scale","Geometry",50,150,100)
add("geometry_autocrop","Crop to Fit","Geometry",0,1,1)
for n,d in [("left",0),("top",0),("right",1),("bottom",1)]:
    add("crop_"+n,"Crop "+n.capitalize(),"Crop",0,1,d,4)
for n in ["red","green","blue"]: add("print_"+n,n.capitalize(),"Print",-24,24,0,0)
add("print_silver","Silver (IR)","Print",0.6,2.4,0.6,2)
add("print_material","Print Film","Print",0,1,0,0)
add("print_generations","Generations","Print",0,4,0,0)
add("print_optical","Optical Step","Print",0,1,0,0)
add("paper_stock","Paper","Paper",0,5,0,0)
add("paper_grade","Grade","Paper",-1,5,2,1)
add("paper_enlarger","Enlarger","Paper",0,2,0,0)
add("paper_exposure","Exposure","Paper",-3,3,0,2)
add("paper_surface","Surface","Paper",0,2,0,0)
for n in ["yellow","magenta","cyan"]: add("paper_"+n,n.capitalize(),"Paper",0,200,0,0)
add("view","View","View",0,4,0,0)
# Quarter turns clockwise (0–3), before the geometry: the photo turned on its side.
add("geometry_turn","Turn","Crop",0,3,0,0)
# The scanner's samples across the frame, by film.scan_widths (0: an HD telecine).
add("scan_resolution","Resolution","Scan",0,4,0,0)
enum="\n".join(f"    {p[0]} = {i}" for i,p in enumerate(P))
def num(v): return repr(float(v))
table=",\n".join(f'    ParameterSpec("{p[0]}", "{p[1]}", "{p[2]}", {num(p[3])}, {num(p[4])}, {num(p[5])}, {p[6]})' for p in P)
(Path(__file__).resolve().parents[1] / "src/parameters.lucb").write_text(f"""## Generated by tools/parameters.py; do not edit. Every develop parameter, its
## name in the text form, its label and Properties section, range, default and
## decimals. settings.lucb says what each does.

## One parameter's description.
pub struct ParameterSpec:
    pub let name: str
    pub let label: str
    pub let section: str
    pub let low: f64
    pub let high: f64
    pub let default: f64
    pub let decimals: i64

## Every develop parameter, in text-form order.
pub enum Parameter as u8:
{enum}

## How many parameters there are.
pub let parameter_count: usize = {len(P)}

pub let parameters: ParameterSpec[{len(P)}] = [
{table}]
""")