### Install Dependencies and Serve Lutgen Wiki Locally with Jekyll Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/README.md This snippet shows how to navigate to the docs directory, install project dependencies using Bundler, and then serve the Jekyll site locally for preview. It requires `jekyll` and `bundler` to be installed globally. ```bash cd docs/ # install deps bundle install # preview the site locally bundle exec jekyll serve # build the site bundle exec jekyll build ``` -------------------------------- ### Setup Shell Auto-Completions Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/examples.md Provides instructions for setting up shell auto-completions for lutgen in Zsh. While often handled by package managers, manual setup is possible by redirecting the completion script to the appropriate system directory. ```bash lutgen --bpaf-complete-style-zsh > _lutgen sudo mv _lutgen /usr/local/share/zsh/site-functions/ ``` -------------------------------- ### Manage Color Palettes Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/examples.md Provides commands to list, view, and search for available color palettes. It supports previewing palettes directly in the terminal using ANSI colors and integrating with tools like fzf for interactive searching. ```bash lutgen palette all lutgen palette catppuccin-mocha lutgen palette names | fzf --preview 'lutgen palette --ansi {}' lutgen palette names | grep 'gruvbox' ``` -------------------------------- ### Apply Color Schemes to Images Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/examples.md Applies a specified color palette to an image. It allows for basic application and advanced tweaking of parameters like luminance and preservation of existing colors. Dependencies include the lutgen binary and the image file. ```bash lutgen apply --palette catppuccin-mocha my-image.png lutgen apply --preserve catppuccin-mocha --lum 0.5 --preserve my-image.png lutgen a -p catppuccin-mocha -PL0.5 my-image.png ``` -------------------------------- ### Create and Use Custom Color Palettes Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/examples.md Enables the creation and use of custom color palettes. Palettes can be copied from existing ones for modification or defined directly in a file with whitespace-separated hex color codes. These custom palettes can then be used with the `generate` command. ```bash # Copy a palette to the custom palette dir for modifying and overriding lutgen palette carburetor > ~/.config/lutgen/carburetor # Custom palette file with whitespace separated hex colors (linux example shown) echo "fff 555 000 abcdef deadbe" > ~/.config/lutgen/my-palette-name lutgen generate -p my-palette-name ``` -------------------------------- ### Patch Text Files with Color Palettes Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/examples.md Allows patching text files, such as CSS files, with color schemes. It can generate a patch file or apply changes directly to the files without creating a separate patch. Supports glob patterns for selecting files. ```bash lutgen patch ./**/*.css --palette catppuccin > catppuccin.patch lutgen patch -wn ./**/*.css -p catppuccin ``` -------------------------------- ### Generate and Extract Raw LUTs Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/examples.md Generates raw HALD CLUTs from built-in or custom color definitions, and extracts LUTs from existing images. These raw LUTs can be used in other software or reapplied using lutgen. Supports single or multiple source images for extraction. ```bash # Generate from a builtin palette lutgen generate -p catppuccin-mocha # Generate from custom colors lutgen generate -o custom.png -- "#ABCDEF" ffffff 000000 # Extract a lut from an existing image lutgen extract -o custom-hald-clut.png my-image.png # Extract a lut using multiple source images lutgen extract -o polaroid-669-hald-clut.png polaroid-669-samples/*.png ``` -------------------------------- ### Apply LUTs to Images Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/examples.md Applies a generated or extracted HALD CLUT to another image. This is useful for applying consistent color grading or effects across multiple images. Requires the HALD CLUT file and the target image. ```bash lutgen apply --hald-clut polaroid-669-clut.png another-image.png ``` -------------------------------- ### Apply LUT to Images using lutgen CLI Source: https://context7.com/ozwaldorf/lutgen-rs/llms.txt Command-line interface commands for applying LUTs to images using lutgen. Supports applying with built-in palettes (on-the-fly generation), pre-generated LUT files, multiple images, and caching for performance. ```bash # Apply using a built-in palette (generates LUT on-the-fly) lutgen apply -p catppuccin-mocha wallpaper.png # Apply using a pre-generated LUT file lutgen apply --hald-clut mocha_lut.png wallpaper.png # Apply to multiple images with output directory lutgen apply -p gruvbox-dark -o ./output/ image1.png image2.jpg image3.webp # Apply with caching (faster for multiple images) lutgen apply -p nord -c wallpaper1.png wallpaper2.png # Apply with Gaussian sampling method lutgen apply -G -p catppuccin-latte input.png ``` -------------------------------- ### Manage Palettes using lutgen CLI Source: https://context7.com/ozwaldorf/lutgen-rs/llms.txt Command-line interface commands for managing color palettes within lutgen. Includes listing available palette names, searching for specific palettes, displaying palette colors, and exporting palettes to files. ```bash # List all available palette names lutgen palette names # Search for specific palettes lutgen palette names | grep catppuccin # Display palette colors lutgen palette catppuccin-mocha catppuccin-latte # Display all palettes with colors lutgen palette all # Export palette to file lutgen palette gruvbox-dark > my_palette.txt ``` -------------------------------- ### Advanced LUT Generation Options using lutgen CLI Source: https://context7.com/ozwaldorf/lutgen-rs/llms.txt Command-line interface commands for advanced Hald CLUT generation with lutgen. Covers options like adjusting CLUT level, nearest neighbor count, Gaussian sampling parameters, and forcing nearest neighbor interpolation. ```bash # Adjust Hald CLUT level (2-16, higher = more precise but larger) lutgen generate -p catppuccin-mocha -l 12 -o high_precision_lut.png # Adjust nearest neighbor count (0 = use all colors) lutgen generate -p nord -n 8 -o fast_lut.png # Gaussian sampling with custom parameters lutgen generate -G -m 0.0 -s 25.0 -i 256 -S 12345 -p dracula -o sampled_lut.png # Nearest neighbor only (no interpolation) lutgen generate -N -p catppuccin-mocha -o sharp_lut.png ``` -------------------------------- ### Patch Text Files (Color Replacement) using lutgen CLI Source: https://context7.com/ozwaldorf/lutgen-rs/llms.txt Command-line interface commands for patching text files (e.g., configuration files, CSS) with color replacements using lutgen. Supports applying palettes to files and writing changes directly. ```bash # Generate a patch showing color replacements lutgen patch -p catppuccin-mocha config.yaml # Write changes directly to file lutgen patch -p gruvbox-dark -w theme.css # Patch multiple files lutgen patch -p nord -w config1.toml config2.json styles.css ``` -------------------------------- ### lutgen palette all Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/cli.md Prints all available palette names along with their corresponding color codes. ```APIDOC ## lutgen palette all ### Description Prints all available palette names and their associated color codes. This provides a comprehensive view of all colors within each palette. ### Usage `lutgen palette all` ### Parameters No specific parameters for this command, it operates on the available palettes. ### Options - **`-h`, `--help`** (boolean) - Optional - Prints help information. ### Request Example ```bash lutgen palette all ``` ### Response #### Success Response (200) - **palette_name** (string) - The name of the palette. - **color_code** (string) - The color code associated with the palette (e.g., hex, ANSI). ``` -------------------------------- ### Generate LUT with GaussianSamplingRemapper in Rust Source: https://context7.com/ozwaldorf/lutgen-rs/llms.txt Shows how to create a Hald CLUT using GaussianSamplingRemapper, which uses Gaussian noise sampling for stochastic interpolation. This method can produce unique results and is slower than other methods. Parameters include mean, standard deviation, iterations, luminosity factor, a seed for the random number generator, and luminosity preservation. ```rust use lutgen::interpolation::GaussianSamplingRemapper; use lutgen::GenerateLut; let palette: Vec<[u8; 3]> = vec![ [30, 30, 46], [166, 227, 161], [243, 139, 168], ]; let remapper = GaussianSamplingRemapper::new( &palette, 0.0, 20.0, 512, 1.0, 42080085, false, ); let hald_clut = remapper.generate_lut(10); hald_clut.save("gaussian_sample_lut.png").expect("Failed to save LUT"); ``` -------------------------------- ### Extract Colors and Generate LUT using lutgen CLI Source: https://context7.com/ozwaldorf/lutgen-rs/llms.txt Command-line interface commands for extracting color palettes from images and generating LUTs with lutgen. Supports extracting from a single reference image or multiple images to combine palettes. ```bash # Extract palette from image and generate LUT lutgen extract reference_image.jpg -o extracted_lut.png # Extract with custom color count lutgen extract --color-count 64 film_still.png -o film_emulation.png # Extract from multiple images lutgen extract photo1.jpg photo2.jpg -o combined_palette_lut.png ``` -------------------------------- ### lutgen palette names Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/cli.md Prints all available palette names. This is useful for scripting and searching for specific palettes. ```APIDOC ## lutgen palette names ### Description Prints all available palette names. This command is particularly useful for scripting purposes or when you need to search for specific palette names. ### Usage `lutgen palette names` ### Parameters No specific parameters for this command, it operates on the available palettes. ### Options - **`-h`, `--help`** (boolean) - Optional - Prints help information. ### Request Example ```bash lutgen palette names ``` ### Response #### Success Response (200) - **palette_name** (string) - The name of an available palette. ``` -------------------------------- ### Generate Hald CLUT using lutgen CLI Source: https://context7.com/ozwaldorf/lutgen-rs/llms.txt Command-line interface commands for generating Hald CLUTs with lutgen. Supports using built-in palettes, custom colors, and various generation parameters like shape, Shepard's method, and luminosity preservation. ```bash # Generate LUT using a built-in palette lutgen generate -p catppuccin-mocha -o mocha_lut.png # Generate with custom shape parameter (more/less blending) lutgen generate -p gruvbox-dark -s 96.0 -o gruvbox_lut.png # Generate with Shepard's method lutgen generate -S -p nord -o nord_lut.png # Generate with custom colors lutgen generate -o custom_lut.png -- "#1e1e2e" "#a6e3a1" "#f38ba8" # Combine palette with custom colors lutgen generate -p catppuccin-mocha -o combined_lut.png -- "#ff0000" "#00ff00" # Generate with luminosity preservation lutgen generate -p dracula -P -L 1.2 -o dracula_lut.png ``` -------------------------------- ### Generate LUT with ShepardRemapper in Rust Source: https://context7.com/ozwaldorf/lutgen-rs/llms.txt Illustrates generating a Hald CLUT using ShepardRemapper, which employs inverse distance weighting for interpolation. Key parameters include the power of the weighting, number of nearest neighbors, luminosity factor, and whether to preserve luminosity. Lower power results in longer gradients, while higher power leads to sharper transitions. ```rust use lutgen::interpolation::ShepardRemapper; use lutgen::GenerateLut; let palette: Vec<[u8; 3]> = vec![ [30, 30, 46], [166, 227, 161], [243, 139, 168], ]; // Create Shepard remapper with power parameter // Lower power = longer gradients but more washed out // Higher power = sharper transitions let remapper = ShepardRemapper::new( &palette, 4.0, 16, 1.0, false, ); let hald_clut = remapper.generate_lut(10); hald_clut.save("shepard_lut.png").expect("Failed to save LUT"); ``` -------------------------------- ### lutgen palette Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/cli.md Prints palette names and colors. Supports specifying individual palettes or using commands like 'all' or 'names'. ```APIDOC ## lutgen palette ### Description Prints palette names and colors. You can specify individual palettes, use the 'all' command to print all palettes and their colors, or use the 'names' command to print only the palette names. ### Usage `lutgen palette [--ansi] [COMMAND | PALETTE ...]` ### Parameters #### Positional Items - **`PALETTE`** (string) - Optional - Builtin or custom palette to use. Custom palettes can be placed in `$LUTGEN_DIR` or `/lutgen`. #### Options - **`--ansi`** (boolean) - Optional - Force printing ANSI colors. - **`-h`, `--help`** (boolean) - Optional - Prints help information. #### Commands - **`names`** - Print all palette names. Useful for scripting and searching. - **`all`** - Print all palette names and colors. ### Request Example ```bash lutgen palette all lutgen palette oxocarbon-dark oxocarbon-light lutgen palette names ``` ### Response #### Success Response (200) Output varies based on the command used. 'names' returns a list of palette names, while 'all' returns names and their corresponding color codes. ``` -------------------------------- ### Apply LUT to Image using Rust Source: https://context7.com/ozwaldorf/lutgen-rs/llms.txt Applies a generated LUT to an input image using the lutgen crate. It loads an image, applies the LUT correction, and saves the output. Requires the 'image' and 'lutgen' crates. ```rust use lutgen::interpolation::GaussianRemapper; use lutgen::GenerateLut; use image::open; let palette: Vec<[u8; 3]> = vec![ [30, 30, 46], [166, 227, 161], [243, 139, 168], [137, 180, 250], ]; // Generate the LUT let remapper = GaussianRemapper::new(&palette, 128.0, 16, 1.0, false); let hald_clut = remapper.generate_lut(10); // Load and apply to an image let mut image = open("input.png").expect("Failed to open image").to_rgba8(); // Apply the LUT correction to the image lutgen::apply_lut(&mut image, &hald_clut); // Save the corrected image image.save("output.png").expect("Failed to save image"); ``` -------------------------------- ### Generate LUT with NearestNeighborRemapper in Rust Source: https://context7.com/ozwaldorf/lutgen-rs/llms.txt Demonstrates the use of NearestNeighborRemapper for generating a Hald CLUT. This remapper performs simple nearest-neighbor matching without any interpolation, providing the most basic color mapping. It takes the target palette, a luminosity factor, and a flag for luminosity preservation as input. ```rust use lutgen::interpolation::NearestNeighborRemapper; use lutgen::GenerateLut; let palette: Vec<[u8; 3]> = vec![ [30, 30, 46], [166, 227, 161], [243, 139, 168], ]; let remapper = NearestNeighborRemapper::new( &palette, 1.0, false, ); let hald_clut = remapper.generate_lut(10); hald_clut.save("nearest_neighbor_lut.png").expect("Failed to save LUT"); ``` -------------------------------- ### CSS for Loading Animation Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/crates/studio/index.html This CSS code defines a dual-ring loading animation, commonly used to indicate that content is being loaded. It includes styles for the animation container and the animation itself, which spins infinitely. The animation is sourced from loading.io. ```css /* Loading animation from https://loading.io/css/ */ .lds-dual-ring { display: inline-block; width: 24px; height: 24px; } .lds-dual-ring:after { content: " "; display: block; width: 24px; height: 24px; margin: 0px; border-radius: 50%; border: 3px solid #fff; border-color: #fff transparent #fff transparent; animation: lds-dual-ring 1.2s linear infinite; } @keyframes lds-dual-ring { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } ``` -------------------------------- ### Implement Custom Radial Basis Function (RBF) in Rust Source: https://context7.com/ozwaldorf/lutgen-rs/llms.txt Demonstrates how to implement a custom Radial Basis Function (RBF) using the `RadialBasisFn` trait from the lutgen crate. This allows for custom interpolation logic in LUT generation. Requires the 'lutgen' crate. ```rust use lutgen::interpolation::{RBFRemapper, RadialBasisFn}; use lutgen::GenerateLut; // Define a custom RBF struct CustomRBF { scale: f64, } impl std::marker::Sync for CustomRBF {} impl RadialBasisFn for CustomRBF { fn radial_basis(&self, distance: f64) -> f64 { // Custom interpolation function 1.0 / (1.0 + self.scale * distance) } } let palette: Vec<[u8; 3]> = vec![ [30, 30, 46], [166, 227, 161], ]; let custom_rbf = CustomRBF { scale: 0.01 }; let remapper = RBFRemapper::with_function( &palette, custom_rbf, 16, // nearest neighbors 1.0, // luminosity factor false, // preserve luminosity ); let hald_clut = remapper.generate_lut(10); ``` -------------------------------- ### Generate LUT with GaussianRemapper in Rust Source: https://context7.com/ozwaldorf/lutgen-rs/llms.txt Demonstrates how to use GaussianRemapper to generate a Hald CLUT. This remapper uses a Gaussian radial basis function for smooth color interpolation. It requires a palette of target colors and allows configuration of shape, nearest neighbors, luminosity factor, and luminosity preservation. ```rust use lutgen::interpolation::GaussianRemapper; use lutgen::GenerateLut; // Create a palette of target colors (RGB format) let palette: Vec<[u8; 3]> = vec![ [30, 30, 46], [166, 227, 161], [243, 139, 168], [137, 180, 250], ]; // Create the remapper with parameters: // - palette: target colors // - shape: 128.0 (higher = less blending, default: 128.0) // - nearest: 16 (number of nearest colors to consider, 0 = all) // - lum_factor: 1.0 (luminosity weighting factor) // - preserve_lum: false (whether to preserve original luminosity) let remapper = GaussianRemapper::new( &palette, 128.0, 16, 1.0, false, ); // Generate a Hald CLUT at level 10 (default) let hald_clut = remapper.generate_lut(10); // Save the generated LUT hald_clut.save("output_lut.png").expect("Failed to save LUT"); ``` -------------------------------- ### Apply LUT with Luminosity Factor Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/tips.md Control the color saturation of the generated LUT using the --lum flag. Values below 1.0 increase color saturation, making the image more colorful. Values above 1.0 decrease color saturation, resulting in a more monochromatic output. This is useful for fine-tuning the color balance of the LUT. ```bash lutgen apply --lum 0.5 my-image.jpg lutgen apply --lum 1.5 my-image.jpg ``` -------------------------------- ### HTML and CSS for Lutgen Studio Layout and Styling Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/crates/studio/index.html These CSS rules define the overall layout and styling for the Lutgen Studio application. They handle touch event behavior, background colors for light and dark modes, and ensure the canvas element fills the entire viewport. The styles also include a centered text class for displaying messages. ```css html { /* Remove touch delay: */ touch-action: manipulation; } body { /* Light mode background color for what is not covered by the egui canvas, or where the egui canvas is translucent. */ background: #909090; } @media (prefers-color-scheme: dark) { body { /* Dark mode background color for what is not covered by the egui canvas, or where the egui canvas is translucent. */ background: #404040; } } /* Allow canvas to fill entire web page: */ html, body { overflow: hidden; margin: 0 !important; padding: 0 !important; height: 100%; width: 100%; } /* Make canvas fill entire document: */ canvas { margin-right: auto; margin-left: auto; display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .centered { margin-right: auto; margin-left: auto; display: block; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #f0f0f0; font-size: 24px; font-family: Ubuntu-Light, Helvetica, sans-serif; text-align: center; } ``` -------------------------------- ### Apply LUT with Preserve Flag Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/tips.md Use the --preserve flag to maintain the original image's luminosity and contrast when applying the LUT. This flag is often used in conjunction with the --lum flag to ensure that color adjustments do not negatively impact the image's overall contrast and gradients. ```bash lutgen apply --preserve my-image.jpg lutgen apply --preserve --lum 0.5 my-image.jpg ``` -------------------------------- ### Apply LUT with Gaussian RBF Shape Parameter Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/docs/pages/tips.md Adjust the blending between colors in the LUT using the --shape parameter. Larger values result in less blending, while smaller values create smoother, more blended colors. This is useful for controlling the overall appearance of the generated LUT. ```bash lutgen apply --shape 256 lutgen apply --shape 64 ``` -------------------------------- ### JavaScript for Service Worker Registration Source: https://github.com/ozwaldorf/lutgen-rs/blob/main/crates/studio/index.html This JavaScript code snippet registers a service worker ('sw.js') when the page loads. It checks if the browser supports service workers and avoids registration if the URL hash is '#dev', which is useful for disabling caching during development. This enables features like offline support and faster loading times. ```javascript // We disable caching during development so that we always view the latest version. if ('serviceWorker' in navigator && window.location.hash !== "#dev") { window.addEventListener('load', function () { navigator.serviceWorker.register('sw.js'); }); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.