effectDescription.DrawDescriptionを短く書く
このページは映像エフェクトプラグイン作成入門の一部です。
/icons/-.icon
前回の最後に書いたコードを見てみましょう。
code:cs
public DrawDescription Update(EffectDescription effectDescription)
{
var opacity = 0.5;
var zoom = 1.2;
var rotationZ = 95;
return effectDescription.DrawDescription with
{
Opacity = opacity,
Zoom = effectDescription.DrawDescription.Zoom * (float)zoom,
Rotation = new(
effectDescription.DrawDescription.Rotation.X,
effectDescription.DrawDescription.Rotation.Y,
effectDescription.DrawDescription.Rotation.Z + rotationZ)
};
}
effectDescription.DrawDescriptionが多くて読みにくいですよね。
このコードは短く書くことができます。
code:cs
public DrawDescription Update(EffectDescription effectDescription)
{
var opacity = 0.5;
var zoom = 1.2;
var rotationZ = 95;
var drawDesc = effectDescription.DrawDescription;
return drawDesc with
{
Opacity = opacity,
Zoom = drawDesc.Zoom * (float)zoom,
Rotation = new(
drawDesc.Rotation.X,
drawDesc.Rotation.Y,
drawDesc.Rotation.Z + rotationZ)
};
}
このようにvar drawDesc = effectDescription.DrawDescription;とすれば以降のコードでdrawDescと書けます。
/icons/-.icon
次はこちら:まとめ(シンプルなエフェクトの作成)