Guest User

Untitled

a guest
Jan 21st, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace TI3ParserLib
  7. {
  8. public sealed class Filter
  9. {
  10. public Shape Appearance { get; private set; }
  11. public string Name { get; private set; }
  12. public List<Property> Properties { get; private set; }
  13. public string Category { get; private set; }
  14. public Connection Connections { get; private set; }
  15.  
  16. public Filter(string name, string cat, Connection connections, Shape look = Shape.Square, params Property[] props)
  17. {
  18. this.Name = name;
  19. this.Category = cat;
  20. this.Appearance = look;
  21. this.Properties = new List<Property>(props);
  22. this.Connections = connections;
  23. }
  24. }
  25.  
  26. public sealed class Property
  27. {
  28. public Type T { get; private set; } // string, double, int or enum
  29. public string Name { get; private set; }
  30. public object Value { get; set; }
  31.  
  32. public Property(string name, Type t, object val)
  33. {
  34. this.Name = name;
  35. this.T = t;
  36. this.Value = val;
  37. }
  38.  
  39. public static Property Make<T>(string name, T value)
  40. {
  41. return new Property(name, typeof(T), value);
  42. }
  43. }
  44.  
  45. public enum Shape
  46. {
  47. Square, Circle, Diamond, Pentagon, PentagonInv, Parallelogram
  48. }
  49.  
  50. public static class Plugins
  51. {
  52. public static List<Filter> GetFilters()
  53. {
  54. List<Filter> f = new List<Filter>();
  55.  
  56. // global meta-filters
  57. f.Add(new Filter("Filetype", "Global", Connection.None, Shape.Square, Property.Make("Output type", Filetype._3DL2)));
  58. f.Add(new Filter("Parameters", "Global", Connection.None, Shape.Square, Property.Make("Parameters string", "")));
  59. f.Add(new Filter("Compression", "Global", Connection.None, Shape.Square, Property.Make("Method", CompressionMethod.LZO)));
  60.  
  61. // value properties
  62. f.Add(new Filter("Input range", "Global", Connection.None, Shape.Square, Property.Make("Range", Range.Limited)));
  63. f.Add(new Filter("Output range", "Global", Connection.None, Shape.Square, Property.Make("Range", Range.Limited)));
  64. f.Add(new Filter("Input depth", "Global", Connection.None, Shape.Square, Property.Make("Channel A", 8), Property.Make("Channel B", 8), Property.Make("Channel C", 8)));
  65. f.Add(new Filter("Output depth", "Global", Connection.None, Shape.Square, Property.Make("Output depth", OutDepth._16)));
  66.  
  67. // simple functions
  68. f.Add(new Filter("Invert", "Simple", Connection.Top | Connection.Bottom, Shape.Square));
  69. f.Add(new Filter("Constant (1)", "Simple", Connection.Top | Connection.Bottom, Shape.Square, Property.Make("Value", 0d)));
  70. f.Add(new Filter("Scale", "Simple", Connection.Top | Connection.Bottom, Shape.Square, Property.Make("Lower multiplier", 0d), Property.Make("Upper multiplier", 1d)));
  71. f.Add(new Filter("Clamp", "Simple", Connection.Top | Connection.Bottom, Shape.Square, Property.Make("Lower bound", 0d), Property.Make("Upper bound", 1d)));
  72. f.Add(new Filter("Gamma (PPC)", "Simple", Connection.Top | Connection.Bottom, Shape.Square, Property.Make("Gamma value", 2.2d), Property.Make("Invert", true)));
  73.  
  74. // colorimetric functions
  75. f.Add(new Filter("Constant (3)", "Color", Connection.Top | Connection.Bottom, Shape.Square, Property.Make("Channel A", 0d), Property.Make("Channel B", 0d), Property.Make("Channel C", 0d)));
  76. f.Add(new Filter("Grayscale", "Color", Connection.Top | Connection.Bottom, Shape.Square, Property.Make("Primaries", Recommendation.BT709)));
  77. f.Add(new Filter("CalFile", "Color", Connection.Top | Connection.Bottom, Shape.Square, Property.Make("File path", "")));
  78. f.Add(new Filter("LutFile", "Color", Connection.Top | Connection.Bottom, Shape.Square, Property.Make("File path", "")));
  79. f.Add(new Filter("ICC (Single)", "Color", Connection.Top | Connection.Bottom, Shape.Square, Property.Make("File path", ""), Property.Make("Rendering intent", RenderingIntent.Absolute)));
  80. f.Add(new Filter("ICC (Link)", "Color", Connection.Top | Connection.Bottom, Shape.Square, Property.Make("Source profile", ""), Property.Make("Destination profile", ""), Property.Make("Rendering intent", RenderingIntent.Absolute)));
  81.  
  82. // XYZ
  83. f.Add(new Filter("RGB -> XYZ", "Color", Connection.Top | Connection.Bottom, Shape.Square,
  84. Property.Make("Red Primary X", ColorSpace.BT709.RedX), Property.Make("Red Primary Y", ColorSpace.BT709.RedY),
  85. Property.Make("Green Primary X", ColorSpace.BT709.GreenX), Property.Make("Green Primary Y", ColorSpace.BT709.GreenY),
  86. Property.Make("Blue Primary X", ColorSpace.BT709.BlueX), Property.Make("Blue Primary Y", ColorSpace.BT709.BlueY),
  87. Property.Make("White Primary X", ColorSpace.BT709.WhiteX), Property.Make("White Primary Y", ColorSpace.BT709.WhiteY)));
  88.  
  89. f.Add(new Filter("XYZ -> RGB", "Color", Connection.Top | Connection.Bottom, Shape.Square,
  90. Property.Make("Red Primary X", ColorSpace.BT709.RedX), Property.Make("Red Primary Y", ColorSpace.BT709.RedY),
  91. Property.Make("Green Primary X", ColorSpace.BT709.GreenX), Property.Make("Green Primary Y", ColorSpace.BT709.GreenY),
  92. Property.Make("Blue Primary X", ColorSpace.BT709.BlueX), Property.Make("Blue Primary Y", ColorSpace.BT709.BlueY),
  93. Property.Make("White Primary X", ColorSpace.BT709.WhiteX), Property.Make("White Primary Y", ColorSpace.BT709.WhiteY)));
  94.  
  95. // multiplexer
  96. f.Add(new Filter("Multiplex", "Channel", Connection.Top | Connection.Left | Connection.Right | Connection.Bottom, Shape.Square));
  97. f.Add(new Filter("Combine", "Channel", Connection.Top | Connection.Left | Connection.Right | Connection.Bottom, Shape.Square));
  98. f.Add(new Filter("Swap", "Channel", Connection.Top | Connection.Bottom, Shape.Square, Property.Make("Swap mode", SwapMode.AB)));
  99.  
  100. return f;
  101. }
  102.  
  103. /*
  104. private sealed class Plugin
  105. {
  106. public string filename;
  107. }*/
  108. }
  109.  
  110. public enum Filetype
  111. {
  112. _3DLUT, _3DL2
  113. }
  114.  
  115. public enum OutDepth
  116. {
  117. _8, _16, _32, _64
  118. }
  119.  
  120. [Flags]
  121. public enum Connection : int
  122. {
  123. None = 0x00,
  124. Top = 0x01,
  125. Bottom = 0x02,
  126. Left = 0x04,
  127. Right = 0x08
  128. }
  129. }
Add Comment
Please, Sign In to add comment