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


C# RGBA_Bytes.GetAsRGBA_Floats方法代码示例

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


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

示例1: Render

 public override void Render(IVertexSource vertexSource, int pathIndexToRender, RGBA_Bytes colorBytes)
 {
     rasterizer.reset();
     Affine transform = GetTransform();
     if (!transform.is_identity())
     {
         vertexSource = new VertexSourceApplyTransform(vertexSource, transform);
     }
     rasterizer.add_path(vertexSource, pathIndexToRender);
     if (destImageByte != null)
     {
         scanlineRenderer.render_scanlines_aa_solid(destImageByte, rasterizer, m_ScanlineCache, colorBytes);
         DestImage.MarkImageChanged();
     }
     else
     {
         scanlineRenderer.RenderSolid(destImageFloat, rasterizer, m_ScanlineCache, colorBytes.GetAsRGBA_Floats());
         destImageFloat.MarkImageChanged();
     }
 }
开发者ID:jeske,项目名称:agg-sharp,代码行数:20,代码来源:ImageGraphics2D.cs

示例2: gradient

		public RGBA_Bytes gradient(RGBA_Bytes c_8, double k)
		{
			RGBA_Floats c = c_8.GetAsRGBA_Floats();
			RGBA_Floats ret;
			ret.red = (float)(red + (c.red - red) * k);
			ret.green = (float)(green + (c.green - green) * k);
			ret.blue = (float)(blue + (c.blue - blue) * k);
			ret.alpha = (float)(alpha + (c.alpha - alpha) * k);
			return ret.GetAsRGBA_Bytes();
		}
开发者ID:CNCBrasil,项目名称:agg-sharp,代码行数:10,代码来源:agg_color_rgba.cs

示例3: AddTestMesh

		private void AddTestMesh(List<MeshGroup> meshGroups)
		{
			if (meshGroups != null)
			{
				AxisAlignedBoundingBox totalMeshBounds = GetAxisAlignedBoundingBox(meshGroups);
				loadedMeshGroups = meshGroups;
				Vector3 meshCenter = totalMeshBounds.Center;
				foreach (MeshGroup meshGroup in meshGroups)
				{
					meshGroup.Translate(-meshCenter);
				}

				ScaleMeshToView(loadedMeshGroups);

				RGBA_Bytes partColor = new RGBA_Bytes(0, 130, 153);
				partColor = RGBA_Bytes.White;
				IPrimitive bvhCollection = MeshToBVH.Convert(loadedMeshGroups, new SolidMaterial(partColor.GetAsRGBA_Floats(), .01, 0.0, 2.0));

				renderCollection.Add(bvhCollection);
			}
		}
开发者ID:CodeMangler,项目名称:MatterControl,代码行数:21,代码来源:ThumbnailTracer.cs

示例4: DrawTo

		public void DrawTo(Graphics2D graphics2D, Mesh meshToDraw, RGBA_Bytes partColorIn, double minZ, double maxZ)
		{
			RGBA_Floats partColor = partColorIn.GetAsRGBA_Floats();
			graphics2D.Rasterizer.gamma(new gamma_power(.3));
			RenderPoint[] points = new RenderPoint[3] { new RenderPoint(), new RenderPoint(), new RenderPoint() };

			foreach (Face face in meshToDraw.Faces)
			{
				int i = 0;
				Vector3 normal = Vector3.TransformVector(face.normal, trackballTumbleWidget.ModelviewMatrix).GetNormal();
				if (normal.z > 0)
				{
					foreach (FaceEdge faceEdge in face.FaceEdges())
					{
						points[i].position = trackballTumbleWidget.GetScreenPosition(faceEdge.firstVertex.Position);

						Vector3 transformedPosition = Vector3.TransformPosition(faceEdge.firstVertex.Position, trackballTumbleWidget.ModelviewMatrix);
						points[i].z = transformedPosition.z;
						i++;
					}

					RGBA_Floats polyDrawColor = new RGBA_Floats();
					double L = Vector3.Dot(lightNormal, normal);
					if (L > 0.0f)
					{
						polyDrawColor = partColor * lightIllumination * L;
					}

					polyDrawColor = RGBA_Floats.ComponentMax(polyDrawColor, partColor * ambiantIllumination);
					for (i = 0; i < 3; i++)
					{
						double ratio = (points[i].z - minZ) / (maxZ - minZ);
						int ratioInt16 = (int)(ratio * 65536);
						points[i].color = new RGBA_Bytes(polyDrawColor.Red0To255, ratioInt16 >> 8, ratioInt16 & 0xFF);
					}


#if true
					scanline_unpacked_8 sl = new scanline_unpacked_8();
					ScanlineRasterizer ras = new ScanlineRasterizer();
					render_gouraud(graphics2D.DestImage, sl, ras, points);
#else
					IRecieveBlenderByte oldBlender = graphics2D.DestImage.GetRecieveBlender();
					graphics2D.DestImage.SetRecieveBlender(new BlenderZBuffer());
					graphics2D.Render(polygonProjected, renderColor);
					graphics2D.DestImage.SetRecieveBlender(oldBlender);
#endif

					byte[] buffer = graphics2D.DestImage.GetBuffer();
					int pixels = graphics2D.DestImage.Width * graphics2D.DestImage.Height;
					for (int pixelIndex = 0; pixelIndex < pixels; pixelIndex++)
					{
						buffer[pixelIndex * 4 + ImageBuffer.OrderR] = buffer[pixelIndex * 4 + ImageBuffer.OrderR];
						buffer[pixelIndex * 4 + ImageBuffer.OrderG] = buffer[pixelIndex * 4 + ImageBuffer.OrderR];
						buffer[pixelIndex * 4 + ImageBuffer.OrderB] = buffer[pixelIndex * 4 + ImageBuffer.OrderR];
					}
				}
			}
		}
开发者ID:CodeMangler,项目名称:MatterControl,代码行数:59,代码来源:ThumbnailTracer.cs

示例5: DrawTo

		public void DrawTo(Graphics2D graphics2D, Mesh meshToDraw, RGBA_Bytes partColorIn, double minZ, double maxZ)
		{
			RGBA_Floats partColor = partColorIn.GetAsRGBA_Floats();
			graphics2D.Rasterizer.gamma(new gamma_power(.3));
			PathStorage polygonProjected = new PathStorage();

			foreach (Face face in meshToDraw.Faces)
			{
				double averageZ = 0;
				Vector3 normal = Vector3.TransformVector(face.normal, trackballTumbleWidget.ModelviewMatrix).GetNormal();
				if (normal.z > 0)
				{
					polygonProjected.remove_all();
					bool first = true;
					foreach (FaceEdge faceEdge in face.FaceEdges())
					{
						Vector2 screenPosition = trackballTumbleWidget.GetScreenPosition(faceEdge.firstVertex.Position);
						if (first)
						{
							polygonProjected.MoveTo(screenPosition.x, screenPosition.y);
							first = false;
						}
						else
						{
							polygonProjected.LineTo(screenPosition.x, screenPosition.y);
						}

						Vector3 transsformedPosition = Vector3.TransformPosition(faceEdge.firstVertex.Position, trackballTumbleWidget.ModelviewMatrix);
						averageZ += transsformedPosition.z;
					}

					averageZ /= 3;

					RGBA_Floats polyDrawColor = new RGBA_Floats();
					double L = Vector3.Dot(lightNormal, normal);
					if (L > 0.0f)
					{
						polyDrawColor = partColor * lightIllumination * L;
					}

					polyDrawColor = RGBA_Floats.ComponentMax(polyDrawColor, partColor * ambiantIllumination);
					double ratio = (averageZ - minZ) / (maxZ - minZ);
					int ratioInt16 = (int)(ratio * 65536);

					//RGBA_Bytes renderColor = new RGBA_Bytes(polyDrawColor.Red0To255, ratioInt16 >> 8, ratioInt16 & 256);
					RGBA_Bytes renderColor = new RGBA_Bytes(ratioInt16 >> 8, ratioInt16 >> 8, ratioInt16 >> 8);

					//IRecieveBlenderByte oldBlender = graphics2D.DestImage.GetRecieveBlender();
					//graphics2D.DestImage.SetRecieveBlender(new BlenderZBuffer());
					graphics2D.Render(polygonProjected, renderColor);
					//graphics2D.DestImage.SetRecieveBlender(oldBlender);

					byte[] buffer = graphics2D.DestImage.GetBuffer();
					int pixels = graphics2D.DestImage.Width * graphics2D.DestImage.Height;
					for (int i = 0; i < pixels; i++)
					{
						//buffer[i * 4 + 0] = buffer[i * 4 + 2];
						//buffer[i * 4 + 1] = buffer[i * 4 + 2];
					}
				}
			}
		}
开发者ID:fuding,项目名称:MatterControl,代码行数:62,代码来源:ThumbnailTracer.cs


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