モジュール
std::shaders::mix
安定性: 暫定 — ミックスです。W3C のブレンドモード、加算合成、すりガラスを含みます。
Entity::mix のためのミックスシェーダーです。どの関数も Mix、つまりエンティティを下に描かれたものへ合成する方法を返します。None は通常のソースオーバー合成です。
ブレンドモードは W3C Compositing and Blending Level 1(CSS の mix-blend-mode の値)に従います。両方がある場所ではエンティティの色と下の色をモードで混ぜ、その結果をソースオーバーで合成します。計算はリニア光で、レンダラーが合成する色に対して行います。
use std::shaders::mix::{frosted_glass, multiply};use std::screen::rgba;
screen.entity(SHADOW).mix().change(Some(multiply())).apply_animation(instant());screen.entity(PANEL).mix().change(Some(frosted_glass(8.0, rgba(255, 255, 255, 40)))).apply_animation(instant());概要
| アイテム | 種類 | 概要 |
|---|---|---|
MULTIPLY … ADD | 定数 | 16 個のブレンドモードのシェーダー |
multiply() … add() | 関数 | Mix 値としてのブレンドモード |
FrostedGlass、FROSTED_GLASS、frosted_glass | 構造体、定数、関数 | すりガラス |
定数:ブレンドモードのシェーダー
pub const MULTIPLY: MixShader<()> = asset("shaders/mix/multiply.wgsl");pub const SCREEN: MixShader<()> = asset("shaders/mix/screen.wgsl");pub const OVERLAY: MixShader<()> = asset("shaders/mix/overlay.wgsl");pub const DARKEN: MixShader<()> = asset("shaders/mix/darken.wgsl");pub const LIGHTEN: MixShader<()> = asset("shaders/mix/lighten.wgsl");pub const COLOR_DODGE: MixShader<()> = asset("shaders/mix/color_dodge.wgsl");pub const COLOR_BURN: MixShader<()> = asset("shaders/mix/color_burn.wgsl");pub const HARD_LIGHT: MixShader<()> = asset("shaders/mix/hard_light.wgsl");pub const SOFT_LIGHT: MixShader<()> = asset("shaders/mix/soft_light.wgsl");pub const DIFFERENCE: MixShader<()> = asset("shaders/mix/difference.wgsl");pub const EXCLUSION: MixShader<()> = asset("shaders/mix/exclusion.wgsl");pub const HUE: MixShader<()> = asset("shaders/mix/hue.wgsl");pub const SATURATION: MixShader<()> = asset("shaders/mix/saturation.wgsl");pub const COLOR: MixShader<()> = asset("shaders/mix/color.wgsl");pub const LUMINOSITY: MixShader<()> = asset("shaders/mix/luminosity.wgsl");pub const ADD: MixShader<()> = asset("shaders/mix/add.wgsl");W3C のブレンドモード multiply から luminosity まで、および加算合成のシェーダーです。引数は受け取りません。
関数:ブレンドモード
pub const fn multiply() -> Mixpub const fn screen() -> Mixpub const fn overlay() -> Mixpub const fn darken() -> Mixpub const fn lighten() -> Mixpub const fn color_dodge() -> Mixpub const fn color_burn() -> Mixpub const fn hard_light() -> Mixpub const fn soft_light() -> Mixpub const fn difference() -> Mixpub const fn exclusion() -> Mixpub const fn hue() -> Mixpub const fn saturation() -> Mixpub const fn color() -> Mixpub const fn luminosity() -> Mixpub const fn add() -> Mix| 関数 | W3C のモード | 効果 |
|---|---|---|
multiply() | multiply | 色を掛け合わせる。必ず暗くなる |
screen() | screen | 反転した色を掛け合わせる。必ず明るくなる |
overlay() | overlay | 下の色に応じて multiply か screen |
darken() | darken | チャンネルごとに 2 色のうち暗いほう |
lighten() | lighten | チャンネルごとに 2 色のうち明るいほう |
color_dodge() | color-dodge | エンティティを反映して下の色を明るくする |
color_burn() | color-burn | エンティティを反映して下の色を暗くする |
hard_light() | hard-light | エンティティの色に応じて multiply か screen |
soft_light() | soft-light | 柔らかい hard_light |
difference() | difference | 色の差の絶対値 |
exclusion() | exclusion | difference に似ているが、コントラストが低い |
hue() | hue | エンティティの色相と、下の彩度と輝度 |
saturation() | saturation | エンティティの彩度と、下の色相と輝度 |
color() | color | エンティティの色相と彩度と、下の輝度 |
luminosity() | luminosity | エンティティの輝度と、下の色相と彩度 |
add() | — | エンティティの光を下に加える。アルファはソースオーバーで合成する |
種別:const fn · ビルトイン:いいえ。
構造体:FrostedGlass
#[shader_arg]pub struct FrostedGlass { pub radius: Decimal, pub tint: Color,}FROSTED_GLASS の引数です。radius はぼかしのピクセル単位の標準偏差、tint はぼかした背景に重ねるガラスの色です。
定数:FROSTED_GLASS
pub const FROSTED_GLASS: MixShader<FrostedGlass> = asset("shaders/mix/frosted_glass.wgsl");すりガラスです(TyranoScript の [position_filter])。
関数:frosted_glass(radius, tint)
pub const fn frosted_glass(radius: Decimal, tint: Color) -> Mix- 戻り値:エンティティに内容がある場所で、下にあるものを
radiusピクセルぼかしてtintを重ね、その上にエンティティを描くミックス。エンティティが透明な場所では、背景がそのまま見えます。 - 種別:
const fn· ビルトイン:いいえ。
半透明の塗りと frosted_glass を持つテキストパネルは、背後の場面をぼかします。
最終更新日 2026年10月29日