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


C# Layer.AddObject方法代码示例

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


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

示例1: DistressMethod1

		private static void DistressMethod1()
		{
			VectorDesign design = VectorDesign.Load(@"DistressDesign.PV", VectorDesignFileTypes.Pv);
			design.Render(@"DistressDesign-Method1-Original.PNG", RenderFormats.Png, 96, design.ColourContext, new RGBColour(1.0, 1.0, 1.0), 1.0);

			// Adding distress to a design is simply the following:
			// 1. Create a distress pattern. This can be a bitmap or vector design. 
			//    It is simply white "random" objects on a transparent background.
			// 2. Merge the distress pattern into your existing design.
			//    Some scaling of the distress pattern may be necessary to make it look good.
			// 3. Rendering the merged design.
			//
			// Assumption: the distress pattern is white. This assumes that it will be placed on a white background.
			// If this is not the case, then you should colourize the distress to match the background or use a different distress
			// pattern.

			var designBounds = design.GetBounds();

			{
				VectorDesign distress = VectorDesign.Load(@"DistressPattern.PV", VectorDesignFileTypes.Pv);
				var distressBounds = distress.GetBounds();

				// Move the distress so it's center is at the same location as the design's center
				var translate = Matrix3x2.Translate(designBounds.Center.X - distressBounds.Center.X, designBounds.Center.Y - distressBounds.Center.Y);
				distress.ApplyTransform(translate);

				// Depending on the distress, you may need to scale it.
				// Calculate an appropriate scaling factor based on your use case.
				//var scale = Matrix3x2.Scale(...);
				//distress.ApplyTransform(scale);

				var distressFirstPage = distress.Pages.First();
				var distressFirstLayer = distressFirstPage.Layers.First();

				// Create a new group object for the distress pattern so we can clip it
				GroupObject distressGroup = new GroupObject();

				foreach (var obj in distressFirstLayer.Objects)
				{
					distressGroup.AddObject(obj);
				}

				// Optional: Clip the distress to the bounding box of the design
				ClipObjectTo(distressGroup, designBounds);

				// Create a new layer for the distress and add the group object to it.
				// Finally, add that new layer to the first page of our design.
				Layer distressLayer = new Layer()
				{
					Name = "Distress" // Not required
				};
				distressLayer.AddObject(distressGroup);
				design.Pages.First().AddLayer(distressLayer);
			}

			// Render on a white background
			design.Render(@"DistressDesign-Method1-Final.PNG", RenderFormats.Png, 96, design.ColourContext, new RGBColour(1.0, 1.0, 1.0), 1.0);
		}
开发者ID:pulsemicro,项目名称:VectorEngine.Samples,代码行数:58,代码来源:Program.cs


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