本文整理汇总了C#中Vector3.Clamp方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Clamp方法的具体用法?C# Vector3.Clamp怎么用?C# Vector3.Clamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3
的用法示例。
在下文中一共展示了Vector3.Clamp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AdjustContrast
/// <summary>
/// Adjusts the contrast of a pixel.
/// </summary>
/// <param name="argb">The ARGB pixel to adjust.</param>
/// <param name="scale">The value to scale the contrast by.</param>
/// <returns>The adjusted ARGB pixel.</returns>
public static int AdjustContrast(int argb, float scale)
{
int a = (argb >> 24) & 0xFF;
int r = (argb >> 16) & 0xFF;
int g = (argb >> 8) & 0xFF;
int b = (argb) & 0xFF;
Vector3 res = new Vector3(r, g, b);
res.Multiply(1 / 255.0f);
res.Subtract(0.5f);
res.Multiply(scale);
res.Add(0.5f);
res.Multiply(255.0f);
res.Clamp(0, 255);
r = (int)res.X;
g = (int)res.Y;
b = (int)res.Z;
return (a << 24) | (r << 16) | (g << 8) | b;
}
示例2: ClosestPoint
/// <summary>
/// Finds the closest point on a bounding box from another point
/// </summary>
/// <param name="box"></param>
/// <param name="point"></param>
/// <returns></returns>
public static Vector3 ClosestPoint(this BoundingBox box, Vector3 point)
{
return point.Clamp(box.Min, box.Max);
}