public override void InitializeResources(IUGContext context) { _linear = new UGLinearGradientBrush( context, new Vector2(0F, 0F), new Vector2(1F, 1F), new[] { new UGGradientStop(UGColor.FromHSL(0F / 3F, 1F, .5F), .25F), new UGGradientStop(UGColor.FromHSL(2F / 3F, 1F, .5F), .75F), }, UGEdgeBehavior.Clamp); _radial = new UGRadialGradientBrush( context, new Vector2(.2F, .2F), .75F, new[] { new UGGradientStop(UGColor.FromHSL(0F / 3F, 1F, .5F), 0F), new UGGradientStop(UGColor.FromHSL(.5F / 3F, 1F, .5F), .25F), new UGGradientStop(UGColor.FromHSL(1F / 3F, 1F, .5F), .5F), new UGGradientStop(UGColor.FromHSL(1.5F / 3F, 1F, .5F), .75F), new UGGradientStop(UGColor.FromHSL(2F / 3F, 1F, .5F), 1F), }, UGEdgeBehavior.Wrap); }
public void OnDraw(IUGContext context) { context.ClearColor(white); var pos = new Vector2(); var size = new UGSize(context.CanvasSize.Width / xStep, context.CanvasSize.Height / yStep); for (var h = 0; h < xStep; ++h) { pos.Y = 0F; for (var l = 0; l < yStep; ++l) { var color = UGColor.FromHSL((float)h / xStep, 1F, (float)l / yStep); context.FillRectangle(pos, size, color); pos.Y += size.Height; } pos.X += size.Width; } }
public void OnDraw(IUGContext context) { context.ClearColor(WHITE); var translate = new Vector2(); var center = new Vector2() { X = context.CanvasSize.Width / SPLIT_X / 2F, Y = context.CanvasSize.Height / SPLIT_Y / 2F }; var size = new UGSize(context.CanvasSize.Width / SPLIT_X, context.CanvasSize.Height / SPLIT_Y); for (var y = 0; y < SPLIT_Y; ++y, translate.Y += size.Height) { translate.X = 0F; for (var x = 0; x < SPLIT_X; ++x, translate.X += size.Width) { var d = SPLIT_Y * y + x; var color = UGColor.FromHSL((float)d / SPLIT_LENGTH, 1F, .5F); color.A = 128; using (context.CreateLayer()) { context.Translate(translate); using (context.CreateLayer()) { switch (d) { case 1: context.ScaleX(.5F); break; case 2: context.ScaleY(.5F); break; case 3: context.Scale(.25F, .5F); break; case 4: context.Rotate(25F); break; case 5: context.Rotate(45F); break; case 6: context.SkewX(20F); break; case 7: context.SkewY(40F); break; case 8: context.Skew(5F, 10F); break; case 9: context.TranslateX(10F); break; case 10: context.TranslateY(10F); break; case 11: context.Translate(5F, 10F); break; case 12: context.Rotate(20F, center); break; case 13: context.SkewX(20F, center); break; case 14: context.Scale(.25F, .5F, center); break; case 15: context.Transform(new Matrix3x2() { M11 = .25F, M12 = (float)Math.Tan(5.0 * Math.PI / 180.0), M21 = (float)Math.Tan(10.0 * Math.PI / 180.0), M22 = .75F, M31 = 10F, M32 = 20F, }); break; } FillRectangle(context, size, color); } DrawRectangle(context, size); string label = null; switch (d) { case 0: label = "Identity"; break; case 1: label = "ScaleX(0.5)"; break; case 2: label = "ScaleY(0.5)"; break; case 3: label = "Scale(0.25, 0.5)"; break; case 4: label = "Rotate(25°)"; break; case 5: label = "Rotate(45°)"; break; case 6: label = "SkewX(20°)"; break; case 7: label = "SkewY(40°)"; break; case 8: label = "Skew(5°, 10°)"; break; case 9: label = "TranslateX(10)"; break; case 10: label = "TranslateY(10)"; break; case 11: label = "Translate(5, 10)"; break; case 12: label = "Rotate(20°, C)"; break; case 13: label = "SkewX(20°, C)"; break; case 14: label = "Scale(0.25, 0.5, C)"; break; case 15: label = "Matrix"; break; } using (var layout = new UGTextLayout(context, label, FORMAT, new UGSize(size.Width - 2F * MARGIN, size.Height - 2F * MARGIN))) { layout.HorizontalAlignment = UGHorizontalAlignment.Center; layout.VerticalAlignment = UGVerticalAlignment.Center; DrawText(context, layout); } } } } }