Exemplo n.º 1
0
		static Preserver.Image GeneratePseudoSVGImageAttributes()
		{
			var seed = new Random().Next(5, 50);
            var increment = new Random().Next(5, 50);

			var reset = seed;
   			
			var img = new Preserver.Image
			{
				OuterElementBackGroundColor = new Preserver.Color(LayoutBuilder.GetColor()),
				FillElementBackGroundColor = new Preserver.Color(LayoutBuilder.GetColor()),
				SeedX =seed,
 				IncrementX =increment,
				Source = nameof(SVGImage),
 
			};

            if (new Random().NextDouble() >= 0.5)
            {
                seed = reset;

            }
            else
            {
                seed = new Random().Next(5, 50);
                increment = new Random().Next(5, 50);
            }

			img.SeedY = seed;
			img.IncrementY = increment;

			return img;
		}
Exemplo n.º 2
0
		public static void GenerateImage(Layout layout, bool suppressBackGroundColor = true)
		{
			foreach (var child in layout.Children)
			{
				if (child is Layout currentLayout)
				{
					GenerateImage(currentLayout, suppressBackGroundColor);
				}

				var currentControl = (VisualElement)child;
				double height = DefaultWidth, width = DefaultHeight;

				switch (child)
				{
					case Image _:
					case SVGImage _:
						{
							var imageAttributtes = new Preserver.Image();
       
							FinalizeDimensions(child, out height, out width);

							if (child is Image img)
							{
								imageAttributtes.Source = GetPNGImage(true).Source;

							}
							if (child is SVGImage svgImage)
							{
								imageAttributtes = GetSVGImage();
                                
							}
							imageAttributtes.Height = height;
							imageAttributtes.Width = width;

							ComponentBuilder.PreserveUIAttributes.Image.Add(imageAttributtes);
							break;
						}
				}
			}

		}