### Start AviUtl2 Docs Development Server with Bun Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Installs dependencies and starts a local development server with hot-reloading for the AviUtl2 documentation project. The server runs on http://localhost:5173/. This command is essential for local development and testing changes. ```bash # Install dependencies bun install # Start development server with hot reload bun run dev # Server runs at http://localhost:5173/ ``` -------------------------------- ### Getting Values from Settings Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Retrieve specific values (e.g., brightness, contrast) at a given time from settings. ```APIDOC ## Getting Values from Settings ### Description Retrieve a specific setting value at a given time. ### Method `obj.getvalue(target, time, section)` ### Endpoint N/A (Lua script context) ### Parameters - **target** (string) - The name of the setting to retrieve (e.g., "bright"). - **time** (number) - The time at which to get the value (e.g., seconds into the timeline). - **section** (number) - The section or layer ID (often 0 for the main object). ### Request Example ```lua local brightness = obj.getvalue("bright", 1.5, 0) -- Get brightness at time 1.5s ``` ### Response - **val** (any) - The value of the requested setting at the specified time. ``` -------------------------------- ### Loading Media Resources Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Examples for loading different types of media resources like video, images, and figures. ```APIDOC ## Loading Media Resources ### Description Load various media resources into the object. ### Method `obj.load(type, ...)` ### Endpoint N/A (Lua script context) ### Parameters - **type** (string) - The type of resource to load ("movie", "image", "figure", "framebuffer"). - **filename** (string) - Path to the media file (for "movie", "image"). - **name** (string) - Name of the figure (for "figure"). - **color** (Color) - Color of the figure (for "figure"). - **size** (number) - Size of the figure (for "figure"). ### Request Example ```lua obj.load("movie", filename) -- Load video file obj.load("image", filename) -- Load image file obj.load("figure", name, color, size) -- Load figure shape obj.load("framebuffer") -- Load from framebuffer ``` ### Response N/A ``` -------------------------------- ### Getting Values from Settings in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Shows how to retrieve values from AviUtl2's settings at specific times using `obj.getvalue`. This is useful for dynamically adjusting parameters based on project settings or time. The function takes a target identifier, time, and section. ```lua -- Getting values from settings local val = obj.getvalue(target, time, section) local brightness = obj.getvalue("bright", 1.5, 0) -- Get brightness at time 1.5s ``` -------------------------------- ### Object Property Manipulation Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Examples of directly accessing and modifying object properties such as position, rotation, scale, and opacity. ```APIDOC ## Object Property Manipulation ### Description Directly access and modify properties of an object. ### Method Direct assignment ### Endpoint N/A (Lua script context) ### Parameters N/A ### Request Example ```lua obj.ox = 100 -- Set relative X coordinate obj.oy = 50 -- Set relative Y coordinate obj.rz = 45 -- Set Z-axis rotation (degrees) obj.zoom = 2.0 -- Set scale (2x size) obj.alpha = 0.5 -- Set opacity (50%) ``` ### Response N/A ``` -------------------------------- ### Reading and Writing Pixel Data in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Demonstrates low-level pixel manipulation in AviUtl2 Lua using `obj.getpixel` and `obj.putpixel`. These functions allow reading the color of a specific pixel or setting its color. The examples show retrieving color as a single value or as RGB components. ```lua -- Reading and writing pixels local col = obj.getpixel(x, y, "col") -- Get color at (x,y) local r, g, b = obj.getpixel(x, y, "rgb") -- Get RGB values obj.putpixel(x, y, col) -- Set pixel color obj.putpixel(x, y, r, g, b) -- Set pixel RGB ``` -------------------------------- ### Applying Filter Effects in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Illustrates how to apply built-in filter effects to objects using the `obj.effect` function in AviUtl2 Lua. This function accepts the effect name and its parameters. Examples show applying blur and color correction. Custom effects can also be applied if available. ```lua -- Applying filter effects obj.effect("filter_name", "param1", value1, "param2", value2, ...) obj.effect("ぼかし", "範囲", 10) -- Blur with range=10 obj.effect("色調補正", "明るさ", 150) -- Brightness to 150% ``` -------------------------------- ### Build AviUtl2 Docs for Production with Bun Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Builds the static HTML, JS, and CSS files for the AviUtl2 documentation website for production deployment. It also includes a command to preview the built site locally. The output is written to the .vitepress/dist/ directory. ```bash # Build static HTML/JS/CSS files bun run build # Output is written to .vitepress/dist/ # Preview the built site locally bun run preview ``` -------------------------------- ### Loading Media Resources in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Demonstrates the use of `obj.load` in AviUtl2 Lua for loading various media resources like video files, images, and custom shapes. It also shows how to load from a framebuffer. This is essential for incorporating external assets into your project. ```lua -- Loading media resources obj.load("movie", filename) -- Load video file obj.load("image", filename) -- Load image file obj.load("figure", name, color, size) -- Load figure shape obj.load("framebuffer") -- Load from framebuffer ``` -------------------------------- ### Shader Execution Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Execute pixel shaders with specified target, resources, and constants. ```APIDOC ## Shader Execution ### Description Execute a pixel shader on a specified target buffer with given resources and constants. ### Method `obj.pixelshader(shader_name, target_buffer, resources, constants, blend_mode)` ### Endpoint N/A (Lua script context) ### Parameters - **shader_name** (string) - The name of the pixel shader to execute. - **target_buffer** (string) - The name of the buffer to render the shader output to. - **resources** (table) - A list of resources (e.g., textures) required by the shader. Example: `{"tex", framebuffer_name}`. - **constants** (table) - A list of constant values to pass to the shader. Example: `{const1, const2, const3, const4}`. - **blend_mode** (string) - The blend mode to apply (e.g., "add"). ### Request Example ```lua obj.pixelshader( "shader_name", "obj", -- Target buffer {"tex", framebuffer_name}, -- Resources {const1, const2, const3, const4}, -- Constants "add" -- Blend mode ) ``` ### Response N/A ``` -------------------------------- ### Format AviUtl2 Documentation Code with Bun Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Manages code formatting for the AviUtl2 documentation project, including Markdown, Vue components, and AviUtl2's Lua dialect. It provides commands to check for formatting issues and automatically fix them. The formatting is handled by Prettier for Markdown/Vue and StyLua for Lua code. ```bash # Check if files need formatting (CI mode) bun run lint # Automatically format all files bun run lint:fix # The formatter handles: # - Markdown files with Prettier # - Vue components embedded in Markdown # - AviUtl2 Lua code blocks with StyLua ``` -------------------------------- ### Shader Execution in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Demonstrates how to execute custom pixel shaders in AviUtl2 using the `obj.pixelshader` function. This allows for advanced visual effects by leveraging GPU computation. It supports specifying shader name, target buffer, resources, constants, and blend mode. ```lua -- Shader execution obj.pixelshader( "shader_name", "obj", -- Target buffer {"tex", framebuffer_name}, -- Resources {const1, const2, const3, const4}, -- Constants "add" -- Blend mode ) ``` -------------------------------- ### Applying Filter Effects Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Shows how to apply various filter effects to an object with customizable parameters. ```APIDOC ## Applying Filter Effects ### Description Apply a filter effect to the object with specified parameters. ### Method `obj.effect(filter_name, param1, value1, ...)` ### Endpoint N/A (Lua script context) ### Parameters - **filter_name** (string) - The name of the filter effect (e.g., "ぼかし", "色調補正"). - **param1** (string) - The name of the first parameter. - **value1** (any) - The value for the first parameter. - ... additional parameters as needed. ### Request Example ```lua obj.effect("ぼかし", "範囲", 10) -- Blur with range=10 obj.effect("色調補正", "明るさ", 150) -- Brightness to 150% ``` ### Response N/A ``` -------------------------------- ### Text Rendering Configuration in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Explains how to render text within AviUtl2 using Lua scripting. The `obj.mes` function inserts text into text objects, while `obj.setfont` allows for detailed configuration of font properties including name, size, type, and colors. ```lua -- Text rendering obj.mes(text) -- Insert text (text objects only) obj.setfont(name, size, type, col1, col2) -- Configure font ``` -------------------------------- ### Drawing Objects Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Demonstrates how to draw an object multiple times with specified transformations. ```APIDOC ## Drawing Objects ### Description Draw the object multiple times with specified coordinates, zoom, alpha, and rotation. ### Method `obj.draw(x, y, z, zoom, alpha, rx, ry, rz)` ### Endpoint N/A (Lua script context) ### Parameters - **x** (number) - X coordinate - **y** (number) - Y coordinate - **z** (number) - Z coordinate - **zoom** (number) - Scale factor - **alpha** (number) - Opacity (0.0 to 1.0) - **rx** (number) - Rotation around X-axis - **ry** (number) - Rotation around Y-axis - **rz** (number) - Rotation around Z-axis ### Request Example ```lua obj.draw(100, 0, 0, 1.0, 1.0, 0, 0, 0) -- Draw copy at x=100 ``` ### Response N/A ``` -------------------------------- ### Color Space Conversion in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Illustrates color space conversions in AviUtl2 Lua using provided utility functions. `RGB` creates a color object from RGB values, while `HSV` creates one from HSV values, facilitating color manipulation and management. ```lua -- Color space conversion local col = RGB(255, 128, 0) -- Create color from RGB local col2 = HSV(180, 50, 100) -- Create color from HSV ``` -------------------------------- ### Audio Processing in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Explains how to process audio data within AviUtl2 using Lua. The `obj.getaudio` function can retrieve PCM samples or frequency spectrum data, enabling audio analysis and manipulation directly within the editor. ```lua -- Audio processing local buf = {} obj.getaudio(buf, "wav", "left", 1024) -- Get PCM samples obj.getaudio(buf, "wav", "spectrum", 256) -- Get frequency spectrum ``` -------------------------------- ### Format Markdown and Lua Code with TypeScript Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt The main formatting function takes a Markdown string, formats it using Prettier, extracts and formats embedded HTML/Vue components, and then formats Lua code blocks using StyLua. It handles special cases like incomplete if statements and escaping '@' symbols. ```typescript // scripts/format.ts import { glob, readFile, writeFile } from "node:fs/promises"; import { styleText } from "node:util"; import { format as prettier } from "prettier"; import { fromMarkdown } from "mdast-util-from-markdown"; import { createPatch } from "diff"; import * as tempy from "tempy"; // Main formatter entry point async function formatMarkdown(source: string): Promise { // Step 1: Format entire markdown with Prettier const baseFormatted = await prettier(source, { parser: "markdown", }); // Step 2: Parse AST to extract HTML and Lua nodes const ast = fromMarkdown(baseFormatted); // Step 3: Format HTML/Vue components separately let replaced = baseFormatted; replaced = await formatHtmlNodes(ast, replaced); // Step 4: Format Lua code blocks with StyLua replaced = await formatLuaNodes(ast, replaced); return replaced; } // Format Vue/HTML components embedded in Markdown async function formatVueLike(segment: string): Promise { if (segment === "" || segment === "") { return segment; } if (segment.trimStart().startsWith(", format, then unwrap const trimLinePattern = /^\n+|\n+$/g; const base = await prettier(``, { parser: "vue", }); return dedent( base .replace(trimLinePattern, "") .slice("".length) .replace(trimLinePattern, "") ).trim(); } } // Format Lua code blocks using StyLua CLI async function formatLuaNodes(ast: AstRoot, baseFormatted: string) { const codeNodes = findNodes( ast as Node, (node): node is CodeNode => !!( node.type === "code" && "lang" in node && typeof node.lang === "string" && node.lang && node.lang.toLowerCase() === "aulua" && // Support noformat meta tag to skip formatting !( "meta" in node && typeof node.meta === "string" && node.meta.includes("noformat") ) ), ); if (codeNodes.length === 0) { return baseFormatted; } return await tempy.temporaryDirectoryTask( async (dir) => { let replaced = baseFormatted; const codeBlocks = []; for (const [i, node] of codeNodes.entries()) { const nodeContent = replaced.slice( node.position.start.offset, node.position.end.offset, ); // Extract indentation and code const indent = nodeContent.match(/(?<=\n)[^\n]*(?=```$)/)?.[0]; const leading = nodeContent.match(/^[^\S\n]*/)?.[0] ?? ""; let cleanedNodeContent = nodeContent .replace(new RegExp(`^${RegExp.escape(indent)}`, "gm"), "") .replace(/^\s*```aulua\s*/, "") .replace(/\s*```\s*$/, "") .replace(/^@/gm, "-- AU2DM_AT_SYMBOL "); // Escape @ symbols // Handle incomplete if statements let isIfEndedCode = false; if (cleanedNodeContent.trim().endsWith("then")) { cleanedNodeContent += "\nend"; isIfEndedCode = true; } // Write to temp file for StyLua const tempFilePath = `${dir}/codeblock-${i}.lua`; await writeFile(tempFilePath, cleanedNodeContent, "utf8"); codeBlocks.push({ original: cleanedNodeContent, path: tempFilePath, node, indent, leading, ifEnded: isIfEndedCode, }); } // Run StyLua on all temp files const stylua = Bun.spawn(["stylua", ...codeBlocks.map((b) => b.path)]); if ((await stylua.exited) !== 0) { const stderr = await new Response(stylua.stderr).text(); throw new Error(`stylua failed: ${stderr}`); } // Read formatted results and reinsert into markdown for (const codeBlock of codeBlocks) { let formattedNode = await readFile(codeBlock.path, "utf8"); let formattedNodeOutput = formattedNode .trim() .replace(/^-- AU2DM_AT_SYMBOL /gm, "@"); // Unescape @ symbols if (codeBlock.ifEnded) { formattedNodeOutput = formattedNodeOutput.replace(/\nend\s*$/, ""); } replaced = replaced.slice(0, codeBlock.node.position.start.offset) + "```aulua\n" + codeBlock.leading + formattedNodeOutput.replace(/^/gm, codeBlock.indent) + "\n" + codeBlock.indent + "```" + replaced.slice(codeBlock.node.position.end.offset); } return replaced; }, { prefix: "au2dm-format-", }, ); } // CLI usage async function main() { let changedCount = 0; ``` -------------------------------- ### Bulk Pixel Operations in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Covers bulk operations for pixel data in AviUtl2 Lua using `obj.getpixeldata` and `obj.putpixeldata`. These functions are efficient for transferring entire image buffers, allowing for complex image processing or manipulation. ```lua -- Bulk pixel operations local data = obj.getpixeldata("obj", "RGBA") -- Get all pixel data obj.putpixeldata("obj", data, width, height, "RGBA") ``` -------------------------------- ### Text Rendering Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Functions for inserting and configuring text properties within objects. ```APIDOC ## Text Rendering ### Description Insert text into text objects and configure font properties. ### Method `obj.mes(text)` and `obj.setfont(...)` ### Endpoint N/A (Lua script context) ### Parameters - **mes**: - **text** (string) - The text content to insert. - **setfont**: - **name** (string) - Font name. - **size** (number) - Font size. - **type** (number) - Font type (specific to AviUtl). - **col1** (Color) - Primary text color. - **col2** (Color) - Secondary text color (e.g., for outlines). ### Request Example ```lua obj.mes("Hello, AviUtl!") obj.setfont("Arial", 32, 1, RGB(255, 255, 255), RGB(0, 0, 0)) ``` ### Response N/A ``` -------------------------------- ### Bulk Pixel Operations Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Functions for retrieving and setting all pixel data for an object efficiently. ```APIDOC ## Bulk Pixel Operations ### Description Retrieve all pixel data from an object or set all pixel data for an object. ### Method `obj.getpixeldata(...)` and `obj.putpixeldata(...)` ### Endpoint N/A (Lua script context) ### Parameters - **getpixeldata**: - **target** (string) - The object to get data from (e.g., "obj"). - **format** (string) - The pixel format (e.g., "RGBA"). - **putpixeldata**: - **target** (string) - The object to set data for. - **data** (userdata) - The pixel data buffer. - **width** (number) - The width of the pixel data. - **height** (number) - The height of the pixel data. - **format** (string) - The pixel format (e.g., "RGBA"). ### Request Example ```lua local data = obj.getpixeldata("obj", "RGBA") -- Get all pixel data obj.putpixeldata("obj", data, width, height, "RGBA") ``` ### Response - **getpixeldata** (returns): - **data** (userdata) - The buffer containing pixel data. ``` -------------------------------- ### Object Property Manipulation in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Demonstrates how to set common properties of objects in AviUtl2 using Lua scripting. This includes controlling position (ox, oy), rotation (rz), zoom level, and alpha transparency. These properties directly affect the visual representation and transformation of objects. ```lua -- Object property manipulation obj.ox = 100 -- Set relative X coordinate obj.oy = 50 -- Set relative Y coordinate obj.rz = 45 -- Set Z-axis rotation (degrees) obj.zoom = 2.0 -- Set scale (2x size) obj.alpha = 0.5 -- Set opacity (50%) ``` -------------------------------- ### Color Space Conversion Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Utility functions for creating color objects from different color models like RGB and HSV. ```APIDOC ## Color Space Conversion ### Description Create color objects from RGB or HSV color values. ### Method `RGB(r, g, b)` and `HSV(h, s, v)` ### Endpoint N/A (Lua script context) ### Parameters - **RGB**: - **r** (number) - Red component (0-255). - **g** (number) - Green component (0-255). - **b** (number) - Blue component (0-255). - **HSV**: - **h** (number) - Hue component (0-360). - **s** (number) - Saturation component (0-100). - **v** (number) - Value (Brightness) component (0-100). ### Request Example ```lua local col = RGB(255, 128, 0) -- Create color from RGB local col2 = HSV(180, 50, 100) -- Create color from HSV ``` ### Response - **col**, **col2** (Color) - A color object representing the specified color. ``` -------------------------------- ### Debug Output in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Shows how to output debug messages during script execution in AviUtl2 Lua using `debug_print`. This function is invaluable for troubleshooting and understanding script behavior by logging variable values or execution flow. ```lua -- Debug output debug_print("Debug message: " .. tostring(value)) ``` -------------------------------- ### Debug Output Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt A simple function for printing debug messages to the console. ```APIDOC ## Debug Output ### Description Print a debug message to the console. ### Method `debug_print(message)` ### Endpoint N/A (Lua script context) ### Parameters - **message** (string) - The message to print. ### Request Example ```lua debug_print("Debug message: " .. tostring(value)) ``` ### Response N/A ``` -------------------------------- ### Drawing Objects Multiple Times in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Shows how to draw an object multiple times with different transformations using the `obj.draw` function in AviUtl2 Lua. This allows for creating complex scenes by duplicating and positioning objects. The function takes parameters for position, zoom, alpha, and rotation. ```lua -- Drawing objects multiple times obj.draw(x, y, z, zoom, alpha, rx, ry, rz) obj.draw(100, 0, 0, 1.0, 1.0, 0, 0, 0) -- Draw copy at x=100 ``` -------------------------------- ### Audio Processing Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Functions for retrieving audio samples or frequency spectrum data. ```APIDOC ## Audio Processing ### Description Retrieve audio data, such as PCM samples or frequency spectrum, for processing. ### Method `obj.getaudio(buffer, format, channel, size)` ### Endpoint N/A (Lua script context) ### Parameters - **buffer** (table) - A Lua table to store the audio samples. - **format** (string) - The audio format (e.g., "wav"). - **channel** (string) - The audio channel or type ("left", "spectrum"). - **size** (number) - The number of samples or spectrum bins to retrieve. ### Request Example ```lua local buf = {} obj.getaudio(buf, "wav", "left", 1024) -- Get PCM samples obj.getaudio(buf, "wav", "spectrum", 256) -- Get frequency spectrum ``` ### Response N/A (Audio data is populated into the provided `buffer` table). ``` -------------------------------- ### Pixel Manipulation Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Functions for reading and writing individual pixel data from/to objects. ```APIDOC ## Pixel Manipulation ### Description Read the color of a pixel at a specific coordinate or set a pixel's color. ### Method `obj.getpixel(...)` and `obj.putpixel(...)` ### Endpoint N/A (Lua script context) ### Parameters - **getpixel**: - **x** (number) - The X coordinate. - **y** (number) - The Y coordinate. - **format** (string) - The desired output format ("col" for a color value, "rgb" for separate R, G, B values). - **putpixel**: - **x** (number) - The X coordinate. - **y** (number) - The Y coordinate. - **col** (Color) - The color value to set (if format is "col"). - **r**, **g**, **b** (number) - The R, G, B values to set (if format is "rgb"). ### Request Example ```lua local col = obj.getpixel(x, y, "col") -- Get color at (x,y) local r, g, b = obj.getpixel(x, y, "rgb") -- Get RGB values obj.putpixel(x, y, col) -- Set pixel color obj.putpixel(x, y, r, g, b) -- Set pixel RGB ``` ### Response - **getpixel** (returns): - **col** (Color) - The color value at the specified coordinate. - **r**, **g**, **b** (number) - The Red, Green, and Blue components of the pixel color. ``` -------------------------------- ### Coordinate Transformation in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Demonstrates coordinate transformation, specifically rotation, using the `rotation` function in AviUtl2 Lua. This function can rotate a 2D point around a specified origin by a given angle, which is useful for geometric calculations and animations. ```lua -- Coordinate transformation local x2, y2 = rotation(x, y, 0, 0, 1.0, 45) -- Rotate point by 45 degrees ``` -------------------------------- ### Handle Japanese Asterisk Markup as Custom Inline Elements Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt This TypeScript code extends the Markdown renderer to handle the Japanese asterisk (※) as a custom inline element. It replaces the default text rule to properly terminate text before the asterisk and introduces a new rule to identify and wrap asterisk-marked text in styled spans. The extension ensures these spans are closed at line breaks and block ends to maintain correct rendering. ```typescript // .vitepress/extensions/asterisk.ts import { MarkdownRenderer } from "vitepress"; import { StateInline } from "markdown-it/index.js"; import { RenderRuleRecord } from "markdown-it/lib/renderer.mjs"; const asteriskMark = "※"; // Custom text rule that treats ※ as a terminator function text(state: StateInline, silent: boolean) { const terminators = "\n!#$%&*+-:<=>@[\]^_`{}~" + asteriskMark; let pos = state.pos; while (pos < state.posMax && !terminators.includes(state.src[pos])) { pos++; } if (pos === state.pos) { return false; } if (!silent) { state.pending += state.src.slice(state.pos, pos); } state.pos = pos; return true; } export function asterisk(md: MarkdownRenderer) { // Replace default text rule md.inline.ruler.at("text", text); // Add asterisk inline rule md.inline.ruler.after("text", "asterisk", (state) => { if (state.src[state.pos] !== asteriskMark) { return false; } state.push("asterisk", "span", 1); state.pos += 1; return true; }); // Render asterisk as styled span md.renderer.rules.asterisk = (_tokens, _idx, _options, env, _self) => { const myEnv = env as { asteriskOpen?: number }; myEnv.asteriskOpen ??= 0; myEnv.asteriskOpen += 1; return ""; }; // Close asterisk spans at line breaks and block ends eolHook(md, "hardbreak"); eolHook(md, "softbreak"); eolHook(md, "paragraph_close"); eolHook(md, "td_close"); } // Hook to close asterisk spans at appropriate boundaries function eolHook(md: MarkdownRenderer, ruleName: keyof RenderRuleRecord) { const original = md.renderer.rules[ruleName]; md.renderer.rules[ruleName] = (tokens, idx, options, env, self) => { const myEnv = env as { asteriskOpen?: number }; let prepend = ""; while ((myEnv.asteriskOpen ?? 0) > 0) { prepend += ""; myEnv.asteriskOpen! -= 1; } return ( prepend + (original?.(tokens, idx, options, env, self) ?? md.renderer.renderToken(tokens, idx, options)) ); }; } ``` -------------------------------- ### Coordinate Transformation Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Functions for performing coordinate transformations like rotation. ```APIDOC ## Coordinate Transformation ### Description Transform coordinates, for example, by rotating them around a pivot point. ### Method `rotation(x, y, px, py, angle, zoom)` ### Endpoint N/A (Lua script context) ### Parameters - **x** (number) - The original X coordinate. - **y** (number) - The original Y coordinate. - **px** (number) - The X coordinate of the pivot point. - **py** (number) - The Y coordinate of the pivot point. - **angle** (number) - The rotation angle in degrees. - **zoom** (number) - The zoom factor. ### Request Example ```lua local x2, y2 = rotation(x, y, 0, 0, 1.0, 45) -- Rotate point by 45 degrees around origin with zoom 1.0 ``` ### Response - **x2** (number) - The transformed X coordinate. - **y2** (number) - The transformed Y coordinate. ``` -------------------------------- ### Generating Deterministic Random Numbers in AviUtl2 Lua Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Shows how to generate deterministic random numbers using `obj.rand` in AviUtl2 Lua. By providing a seed and frame number, the sequence of random numbers becomes predictable, which is useful for reproducible effects. The function takes minimum and maximum values. ```lua -- Random numbers (deterministic) obj.rand(min, max, seed, frame) local r = obj.rand(0, 100, 0) -- Random 0-100 with seed=0 ``` -------------------------------- ### Deterministic Random Numbers Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt Generate pseudo-random numbers with a specified seed and frame for reproducible results. ```APIDOC ## Deterministic Random Numbers ### Description Generate deterministic pseudo-random numbers within a given range. ### Method `obj.rand(min, max, seed, frame)` ### Endpoint N/A (Lua script context) ### Parameters - **min** (number) - The minimum value of the random number. - **max** (number) - The maximum value of the random number. - **seed** (number) - The seed for the random number generator. - **frame** (number) - The current frame number (influences the generated number). ### Request Example ```lua local r = obj.rand(0, 100, 0) -- Random 0-100 with seed=0 ``` ### Response - **r** (number) - The generated pseudo-random number. ``` -------------------------------- ### Map Code Fence Language Identifiers to Display Names Source: https://context7.com/sevenc-nanashi/aviutl2_modern_docs/llms.txt This TypeScript code provides a custom Markdown renderer rule to map specific language identifiers used in code fences to more descriptive display names. It modifies the default fence rendering to replace the language class name with a user-defined label, enhancing the readability of code blocks. This is particularly useful for distinguishing different types of code within a project, such as custom scripting languages. ```typescript // .vitepress/extensions/customFence.ts import { MarkdownRenderer } from "vitepress"; import type { RenderRule } from "markdown-it/lib/renderer.mjs"; export function customFence(options: { languageLabels: Record; }) { return (md: MarkdownRenderer) => { const fence: RenderRule = md.renderer.rules.fence!.bind(md.renderer.rules); md.renderer.rules.fence = (...args) => { // Replace language label in rendered HTML return fence(...args).replace( /(?<=class="lang">)([^<]*)/, (_, p1) => options.languageLabels[p1] ?? p1, ); }; }; } // Usage in config.mts: // md.use(customFence({ // languageLabels: { // aulua: "AviUtl2 Lua", // autxt: "AviUtl2 Text", // }, // })); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.