当前位置: 首页>>代码示例>>C#>>正文


C# Color.Scale方法代码示例

本文整理汇总了C#中Color.Scale方法的典型用法代码示例。如果您正苦于以下问题:C# Color.Scale方法的具体用法?C# Color.Scale怎么用?C# Color.Scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Color的用法示例。


在下文中一共展示了Color.Scale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Write

 /**
  * Write
  *
  * @param brightness
  * @param x
  * @param y
  * @param color
  */
 public void Write(double brightness, int x, int y, Color color)
 {
     color.Scale(brightness);
     double max = color.FindMax();
     if(max > 1.0f)
     {
         color.Scale(1.0f / max);
     }
     SetRed(x, y, color.GetRed() * 255);
     SetGreen(x, y, color.GetGreen() * 255);
     SetBlue(x, y, color.GetBlue() * 255);
     //System.out.println( "Set "+x+","+y+"="+Pixels[y * GetWidth() + x] );
 }
开发者ID:rafxbpontes,项目名称:benchmarker,代码行数:21,代码来源:Canvas.cs

示例2: Shade

	/**
	 * Shade
	 *
	 * @param tree
	 * @param eyeRay
	 * @param color
	 * @param factor
	 * @param level
	 * @param originID
	 */
	private void Shade(OctNode tree, Ray eyeRay, Color color, double factor, int level, int originID)
	{
		Color lightColor = new Color(0.0f, 0.0f, 0.0f);
		Color reflectColor = new Color(0.0f, 0.0f, 0.0f);
		Color refractColor = new Color(0.0f, 0.0f, 0.0f);
		IntersectPt intersect = new IntersectPt();
		OctNode baseoctn = new OctNode();
		Vector normal = new Vector();
		Ray reflect = new Ray();
		Ray refract = new Ray();
		double mu;
		int current;

		if(intersect.FindNearestIsect(tree, eyeRay, originID, level, baseoctn))
		{
			intersect.GetIntersectObj().FindNormal(intersect.GetIntersection(), normal);
			GetLightColor(baseoctn, intersect.GetIntersection(), normal, intersect.GetIntersectObj(), lightColor);
			if(level < MaxLevel)
			{
				double check = factor * (1.0f - intersect.GetIntersectObj().GetMaterial().GetKTran()) * intersect.GetIntersectObj().GetMaterial().GetShininess();
				if(check > MinFactor)
				{
					reflect.SetOrigin(intersect.GetIntersection());
					reflect.GetDirection().Combine(eyeRay.GetDirection(), normal, 1.0f, -2.0f * normal.Dot(eyeRay.GetDirection()));
					reflect.SetID(RayID);
					this.RayID = this.RayID + 1;
					Shade(baseoctn, reflect, reflectColor, check, level + 1, originID);
					reflectColor.Scale((1.0f - intersect.GetIntersectObj().GetMaterial().GetKTran()) * intersect.GetIntersectObj().GetMaterial().GetShininess(),
						intersect.GetIntersectObj().GetMaterial().GetSpecColor());
				}
				check = factor * intersect.GetIntersectObj().GetMaterial().GetKTran();
				if(check > MinFactor)
				{
					if(intersect.GetEnter())
					{
						mu = 1.0f / intersect.GetIntersectObj().GetMaterial().GetRefIndex();
						current = intersect.GetIntersectObj().GetObjID();
					}
					else
					{
						mu = intersect.GetIntersectObj().GetMaterial().GetRefIndex();
						normal.Negate();
						current = 0;
					}
					double IdotN = normal.Dot(eyeRay.GetDirection());
					double TotIntReflect = 1.0f - mu * mu * (1.0f - IdotN * IdotN);
					if(TotIntReflect >= 0.0)
					{
						double gamma = -mu * IdotN - (double)Math.Sqrt(TotIntReflect);
						refract.SetOrigin(intersect.GetIntersection());
						refract.GetDirection().Combine(eyeRay.GetDirection(), normal, mu, gamma);
						refract.SetID(RayID);
						this.RayID = RayID + 1;
						Shade(baseoctn, refract, refractColor, check, level + 1, current);
						refractColor.Scale(intersect.GetIntersectObj().GetMaterial().GetKTran(), intersect.GetIntersectObj().GetMaterial().GetSpecColor());
					}
				}
			}
			color.Combine(intersect.GetIntersectObj().GetMaterial().GetEmissColor(), intersect.GetIntersectObj().GetMaterial().GetAmbColor(),
				AmbLightIntensity, lightColor, reflectColor, refractColor);
		}
	}
开发者ID:lewurm,项目名称:benchmarker,代码行数:72,代码来源:Scene.cs


注:本文中的Color.Scale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。