public YAMLNode ExportYAML(IExportContainer container) { YAMLMappingNode node = new YAMLMappingNode(); GradientLayout layout = container.ExportLayout.Serialized.Gradient; node.AddSerializedVersion(layout.Version); if (layout.Version == 1) { node.Add(layout.Key0Name, Key0_32.ExportYAML(container)); node.Add(layout.Key1Name, Key1_32.ExportYAML(container)); node.Add(layout.Key2Name, Key2_32.ExportYAML(container)); node.Add(layout.Key3Name, Key3_32.ExportYAML(container)); node.Add(layout.Key4Name, Key4_32.ExportYAML(container)); node.Add(layout.Key5Name, Key5_32.ExportYAML(container)); node.Add(layout.Key6Name, Key6_32.ExportYAML(container)); node.Add(layout.Key7Name, Key7_32.ExportYAML(container)); } else { node.Add(layout.Key0Name, Key0.ExportYAML(container)); node.Add(layout.Key1Name, Key1.ExportYAML(container)); node.Add(layout.Key2Name, Key2.ExportYAML(container)); node.Add(layout.Key3Name, Key3.ExportYAML(container)); node.Add(layout.Key4Name, Key4.ExportYAML(container)); node.Add(layout.Key5Name, Key5.ExportYAML(container)); node.Add(layout.Key6Name, Key6.ExportYAML(container)); node.Add(layout.Key7Name, Key7.ExportYAML(container)); } node.Add(layout.Ctime0Name, Ctime0); node.Add(layout.Ctime1Name, Ctime1); node.Add(layout.Ctime2Name, Ctime2); node.Add(layout.Ctime3Name, Ctime3); node.Add(layout.Ctime4Name, Ctime4); node.Add(layout.Ctime5Name, Ctime5); node.Add(layout.Ctime6Name, Ctime6); node.Add(layout.Ctime7Name, Ctime7); node.Add(layout.Atime0Name, Atime0); node.Add(layout.Atime1Name, Atime1); node.Add(layout.Atime2Name, Atime2); node.Add(layout.Atime3Name, Atime3); node.Add(layout.Atime4Name, Atime4); node.Add(layout.Atime5Name, Atime5); node.Add(layout.Atime6Name, Atime6); node.Add(layout.Atime7Name, Atime7); if (layout.HasMode) { node.Add(layout.ModeName, (int)Mode); } node.Add(layout.NumColorKeysName, NumColorKeys); node.Add(layout.NumAlphaKeysName, NumAlphaKeys); return(node); }
public void Write(AssetWriter writer) { GradientLayout layout = writer.Layout.Serialized.Gradient; if (layout.Version == 1) { Key0_32.Write(writer); Key1_32.Write(writer); Key2_32.Write(writer); Key3_32.Write(writer); Key4_32.Write(writer); Key5_32.Write(writer); Key6_32.Write(writer); Key7_32.Write(writer); } else { Key0.Write(writer); Key1.Write(writer); Key2.Write(writer); Key3.Write(writer); Key4.Write(writer); Key5.Write(writer); Key6.Write(writer); Key7.Write(writer); } writer.Write(Ctime0); writer.Write(Ctime1); writer.Write(Ctime2); writer.Write(Ctime3); writer.Write(Ctime4); writer.Write(Ctime5); writer.Write(Ctime6); writer.Write(Ctime7); writer.Write(Atime0); writer.Write(Atime1); writer.Write(Atime2); writer.Write(Atime3); writer.Write(Atime4); writer.Write(Atime5); writer.Write(Atime6); writer.Write(Atime7); if (layout.HasMode) { writer.Write((int)Mode); } writer.Write(NumColorKeys); writer.Write(NumAlphaKeys); writer.AlignStream(); }
public void Read(AssetReader reader) { GradientLayout layout = reader.Layout.Serialized.Gradient; if (layout.Version == 1) { Key0_32 = reader.ReadAsset <ColorRGBA32>(); Key1_32 = reader.ReadAsset <ColorRGBA32>(); Key2_32 = reader.ReadAsset <ColorRGBA32>(); Key3_32 = reader.ReadAsset <ColorRGBA32>(); Key4_32 = reader.ReadAsset <ColorRGBA32>(); Key5_32 = reader.ReadAsset <ColorRGBA32>(); Key6_32 = reader.ReadAsset <ColorRGBA32>(); Key7_32 = reader.ReadAsset <ColorRGBA32>(); } else { Key0.Read(reader); Key1.Read(reader); Key2.Read(reader); Key3.Read(reader); Key4.Read(reader); Key5.Read(reader); Key6.Read(reader); Key7.Read(reader); } Ctime0 = reader.ReadUInt16(); Ctime1 = reader.ReadUInt16(); Ctime2 = reader.ReadUInt16(); Ctime3 = reader.ReadUInt16(); Ctime4 = reader.ReadUInt16(); Ctime5 = reader.ReadUInt16(); Ctime6 = reader.ReadUInt16(); Ctime7 = reader.ReadUInt16(); Atime0 = reader.ReadUInt16(); Atime1 = reader.ReadUInt16(); Atime2 = reader.ReadUInt16(); Atime3 = reader.ReadUInt16(); Atime4 = reader.ReadUInt16(); Atime5 = reader.ReadUInt16(); Atime6 = reader.ReadUInt16(); Atime7 = reader.ReadUInt16(); if (layout.HasMode) { Mode = (GradientMode)reader.ReadInt32(); } NumColorKeys = reader.ReadByte(); NumAlphaKeys = reader.ReadByte(); reader.AlignStream(); }
public override void Draw(CGRect rect) { base.Draw(rect); GradientLayout layout = (GradientLayout)this.Element; CGColor startColor = layout.StartColor.ToCGColor(); CGColor endColor = layout.EndColor.ToCGColor(); var gradient = new CAGradientLayer() { StartPoint = new CGPoint(0, 0.5), EndPoint = new CGPoint(1, 0.5) }; gradient.Frame = rect; gradient.Colors = new CGColor[] { startColor, endColor }; NativeView.Layer.InsertSublayer(gradient, 0); }
public SerializedLayoutCategory(LayoutInfo info) { AABB = new AABBLayout(info); AABBi = new AABBiLayout(info); AnimationCurveTpl = new AnimationCurveTplLayout(info); ColorRGBA32 = new ColorRGBA32Layout(info); ColorRGBAf = new ColorRGBAfLayout(info); Gradient = new GradientLayout(info); GUIStyle = new GUIStyleLayout(info); LayerMask = new LayerMaskLayout(info); Matrix4x4f = new Matrix4x4fLayout(info); Quaternionf = new QuaternionfLayout(info); Rectf = new RectfLayout(info); RectOffset = new RectOffsetLayout(info); Vector2f = new Vector2fLayout(info); Vector2i = new Vector2iLayout(info); Vector3f = new Vector3fLayout(info); Vector3i = new Vector3iLayout(info); Vector4f = new Vector4fLayout(info); }
public override void Draw(CGRect rect) { base.Draw(rect); GradientLayout layout = (GradientLayout)Element; CGColor[] colors = new CGColor[layout.Colors.Length]; for (int i = 0, l = colors.Length; i < l; i++) { colors[i] = layout.Colors[i].ToCGColor(); } var gradientLayer = new CAGradientLayer(); switch (layout.Mode) { default: case GradientColorStackMode.ToRight: gradientLayer.StartPoint = new CGPoint(0, 0.5); gradientLayer.EndPoint = new CGPoint(1, 0.5); break; case GradientColorStackMode.ToLeft: gradientLayer.StartPoint = new CGPoint(1, 0.5); gradientLayer.EndPoint = new CGPoint(0, 0.5); break; case GradientColorStackMode.ToTop: gradientLayer.StartPoint = new CGPoint(0.5, 0); gradientLayer.EndPoint = new CGPoint(0.5, 1); break; case GradientColorStackMode.ToBottom: gradientLayer.StartPoint = new CGPoint(0.5, 1); gradientLayer.EndPoint = new CGPoint(0.5, 0); break; case GradientColorStackMode.ToTopLeft: gradientLayer.StartPoint = new CGPoint(1, 0); gradientLayer.EndPoint = new CGPoint(0, 1); break; case GradientColorStackMode.ToTopRight: gradientLayer.StartPoint = new CGPoint(0, 1); gradientLayer.EndPoint = new CGPoint(1, 0); break; case GradientColorStackMode.ToBottomLeft: gradientLayer.StartPoint = new CGPoint(1, 1); gradientLayer.EndPoint = new CGPoint(0, 0); break; case GradientColorStackMode.ToBottomRight: gradientLayer.StartPoint = new CGPoint(0, 0); gradientLayer.EndPoint = new CGPoint(1, 1); break; } gradientLayer.Frame = rect; gradientLayer.Colors = colors; NativeView.Layer.InsertSublayer(gradientLayer, 0); }
protected override void DispatchDraw(global::Android.Graphics.Canvas canvas) { GradientLayout layout = (GradientLayout)this.Element; Color[] Colors = layout.Colors; GradientColorStackMode Mode = layout.Mode; int[] colors = new int[Colors.Length]; for (int i = 0, l = Colors.Length; i < l; i++) { colors[i] = Colors[i].ToAndroid().ToArgb(); } // temporary workaround for Android 9 PIE if (Android.OS.Build.VERSION.SdkInt > Android.OS.BuildVersionCodes.O) { GradientDrawable.Orientation orientation; switch (Mode) { default: case GradientColorStackMode.ToRight: orientation = GradientDrawable.Orientation.LeftRight; break; case GradientColorStackMode.ToTop: orientation = GradientDrawable.Orientation.BottomTop; break; case GradientColorStackMode.ToBottom: orientation = GradientDrawable.Orientation.TopBottom; break; case GradientColorStackMode.ToTopLeft: orientation = GradientDrawable.Orientation.BrTl; break; case GradientColorStackMode.ToTopRight: orientation = GradientDrawable.Orientation.BlTr; break; case GradientColorStackMode.ToBottomLeft: orientation = GradientDrawable.Orientation.TrBl; break; case GradientColorStackMode.ToBottomRight: orientation = GradientDrawable.Orientation.TlBr; break; } var gradient2 = new GradientDrawable(orientation, colors); ViewCompat.SetBackground(this, gradient2); base.DispatchDraw(canvas); return; } Android.Graphics.LinearGradient gradient; switch (Mode) { default: case GradientColorStackMode.ToRight: gradient = new Android.Graphics.LinearGradient(0, 0, Width, 0, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToLeft: gradient = new Android.Graphics.LinearGradient(Width, 0, 0, 0, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToTop: gradient = new Android.Graphics.LinearGradient(0, Height, 0, 0, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToBottom: gradient = new Android.Graphics.LinearGradient(0, 0, 0, Height, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToTopLeft: gradient = new Android.Graphics.LinearGradient(Width, Height, 0, 0, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToTopRight: gradient = new Android.Graphics.LinearGradient(0, Height, Width, 0, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToBottomLeft: gradient = new Android.Graphics.LinearGradient(Width, 0, 0, Height, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToBottomRight: gradient = new Android.Graphics.LinearGradient(0, 0, Width, Height, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; } var paint = new Android.Graphics.Paint() { Dither = true, }; paint.SetShader(gradient); canvas.DrawPaint(paint); base.DispatchDraw(canvas); }
private static void GenerateEngineStruct(TypeTreeContext context, SerializableType origin, string name) { switch (origin.Name) { case SerializableType.Vector2Name: Vector2fLayout.GenerateTypeTree(context, name); break; case SerializableType.Vector2IntName: Vector2iLayout.GenerateTypeTree(context, name); break; case SerializableType.Vector3Name: Vector3fLayout.GenerateTypeTree(context, name); break; case SerializableType.Vector3IntName: Vector3iLayout.GenerateTypeTree(context, name); break; case SerializableType.Vector4Name: Vector4fLayout.GenerateTypeTree(context, name); break; case SerializableType.RectName: RectfLayout.GenerateTypeTree(context, name); break; case SerializableType.BoundsName: AABBLayout.GenerateTypeTree(context, name); break; case SerializableType.BoundsIntName: AABBiLayout.GenerateTypeTree(context, name); break; case SerializableType.QuaternionName: QuaternionfLayout.GenerateTypeTree(context, name); break; case SerializableType.Matrix4x4Name: Matrix4x4fLayout.GenerateTypeTree(context, name); break; case SerializableType.ColorName: ColorRGBAfLayout.GenerateTypeTree(context, name); break; case SerializableType.Color32Name: ColorRGBA32Layout.GenerateTypeTree(context, name); break; case SerializableType.LayerMaskName: LayerMaskLayout.GenerateTypeTree(context, name); break; case SerializableType.AnimationCurveName: AnimationCurveTplLayout.GenerateTypeTree(context, name, SingleLayout.GenerateTypeTree); break; case SerializableType.GradientName: GradientLayout.GenerateTypeTree(context, name); break; case SerializableType.RectOffsetName: RectOffsetLayout.GenerateTypeTree(context, name); break; case SerializableType.GUIStyleName: GUIStyleLayout.GenerateTypeTree(context, name); break; case SerializableType.PropertyNameName: PropertyNameLayout.GenerateTypeTree(context, name); break; default: throw new Exception($"Unknown engine struct {origin.Name}"); } }