{
  "Name": "Ramp",
  "_id": "93d2bd9d-d0fc-4af1-93a2-7e5ebeb60343",
  "Namespace": "lib.image.generate",
  "Description": "Creates a linear gradient texture between two points. \r\n\r\nTop left [-0.5 , -0.5]  \r\nBottom right [0.5 , 0.5]\r\n",
  "Inputs": [
    {
      "Name": "Code",
      "MetaInstanceID": "e447fa8e-a8df-4b08-a949-b399135b2ef8",
      "DefaultValue": {
        "Type": "Text",
        "Value": [
          "//>>> _common parameters\r",
          "float4x4 objectToWorldMatrix;",
          "float4x4 worldToCameraMatrix;",
          "float4x4 projMatrix;",
          "Texture2D txDiffuse;",
          "float2 RenderTargetSize;",
          "//<<< _common parameters\r",
          "\r",
          "//>>> _parameters\r",
          "float4 ColorA;",
          "float4 ColorB;",
          "float2 Center;",
          "float Angle;",
          "float Feather;",
          "//<<< _parameters\r",
          "\r",
          "//>>> _setup\r",
          "SamplerState samLinear",
          "{",
          "    Filter = MIN_MAG_MIP_LINEAR;",
          "    AddressU = Clamp;",
          "    AddressV = Clamp;",
          "};",
          "//<<< _setup\r",
          "\r",
          "//>>> _declarations\r",
          "struct VS_IN",
          "{",
          "    float4 pos : POSITION;",
          "    float2 texCoord : TEXCOORD;",
          "};",
          "",
          "struct PS_IN",
          "{",
          "    float4 pos : SV_POSITION;",
          "    float2 texCoord: TEXCOORD0;",
          "};",
          "//<<< _declarations\r",
          "\r",
          "//>>> _GS\r",
          "",
          "//<<< _GS\r",
          "\r",
          "//>>> _VS \r",
          "PS_IN VS( VS_IN input )",
          "{",
          "    PS_IN output = (PS_IN)0;",
          "",
          "    output.pos = mul(input.pos, worldToCameraMatrix);",
          "    output.pos = mul(output.pos, projMatrix);",
          "    output.texCoord = input.texCoord;",
          "",
          "    return output;",
          "}",
          "//<<< _VS\r",
          "\r",
          "//>>> PS\r",
          "float4 PS(PS_IN input) : SV_Target\r",
          "{\r",
          "    float aspectRatio = RenderTargetSize.x/RenderTargetSize.y;\r",
          "\r",
          "    \r",
          "    float2 p= input.pos/RenderTargetSize - float2(0.5,0.5);\r",
          "    \r",
          "    float2 From = Center;\r",
          "    float deg= Angle * 3.141578 / 180;\r",
          "    float2 To = Center + float2( sin(deg), cos(deg));\r",
          "    \r",
          "    float cx = To.x - From.x;\r",
          "    float cy = To.y - From.y;\r",
          "    float bx = -cy;\r",
          "    float by = cx;\r",
          "\r",
          "    float ex = p.x - From.x;\r",
          "    float ey = p.y - From.y;\r",
          "        \r",
          "    float d = (ex*by - ey*bx) / (sqrt(bx*bx + by*by));\r",
          "    \r",
          "    d /= length(From - To);    \r",
          "    \r",
          "    float4 c;\r",
          "    \r",
          "    float blend = clamp(d/Feather + 0.5 ,0,1);\r",
          "    c = lerp(ColorA,ColorB,blend);\r",
          "        \r",
          "    return c;\r",
          "    \r",
          "}\r",
          "//<<< PS\r",
          "\r",
          "//>>> _technique\r",
          "technique10 Render",
          "{",
          "    pass P0",
          "    {",
          "        SetGeometryShader( 0 );",
          "        SetVertexShader( CompileShader( vs_4_0, VS() ) );",
          "        SetPixelShader( CompileShader( ps_4_0, PS() ) );",
          "    }",
          "}",
          "//<<< _technique\r",
          ""
        ]
      },
      "MetaID": "c522a66e-3260-4692-b3e3-79fd0361fa3d",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "-100000",
      "Max": "100000",
      "Scale": "0.1",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "ColorA.R",
      "MetaInstanceID": "52f27bcd-2278-44f2-b644-5f48116a0dab",
      "DefaultValue": {
        "Type": "Float",
        "Value": "0"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "ColorA.G",
      "MetaInstanceID": "b5dd36fb-8162-4501-9bb0-cea697926c74",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "ColorA.B",
      "MetaInstanceID": "f230bfde-1525-4f9d-b22f-bc8c81303b7e",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "ColorA.A",
      "MetaInstanceID": "dd885289-c6ba-4981-977a-f1575f7a7c99",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "ColorB.R",
      "MetaInstanceID": "9724ce77-e9d2-444c-b6bb-b24442bda94e",
      "DefaultValue": {
        "Type": "Float",
        "Value": "0"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "ColorB.G",
      "MetaInstanceID": "477f48a2-7f56-4c3f-b79b-842dfa884b0d",
      "DefaultValue": {
        "Type": "Float",
        "Value": "0"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "ColorB.B",
      "MetaInstanceID": "9313c532-dc46-4b84-bea7-84e5afd892ce",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "ColorB.A",
      "MetaInstanceID": "f8a32b48-4cee-4b0f-b143-ad61e7ff436d",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "1",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "Center.X",
      "MetaInstanceID": "826f029c-6dad-4d95-89da-267f6a56d906",
      "DefaultValue": {
        "Type": "Float",
        "Value": "0"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "-10000",
      "Max": "10000",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "Center.Y",
      "MetaInstanceID": "51f3dd97-8cf5-4ffa-8771-18a90661b050",
      "DefaultValue": {
        "Type": "Float",
        "Value": "0"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "-10000",
      "Max": "10000",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "Angle",
      "MetaInstanceID": "b08290c4-008d-4d57-a61e-33426c925b0e",
      "DefaultValue": {
        "Type": "Float",
        "Value": "0"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "-100000",
      "Max": "100000",
      "Scale": "0.1",
      "ScaleType": "Linear",
      "EnumValues": []
    },
    {
      "Name": "Feather",
      "MetaInstanceID": "7e6b83bc-9421-4c8f-9e0d-83294ed63b43",
      "DefaultValue": {
        "Type": "Float",
        "Value": "1"
      },
      "MetaID": "3f76dee3-3897-44ac-82d6-25ce9f53a506",
      "IsMultiInput": "False",
      "Relevance": "Optional",
      "Description": "",
      "Min": "0",
      "Max": "100000",
      "Scale": "0.01",
      "ScaleType": "Linear",
      "EnumValues": []
    }
  ],
  "Outputs": [
    {
      "Name": "Image",
      "MetaInstanceID": "8869ee5c-c2dd-4827-b978-78492455bb48",
      "MetaID": "9848060d-fd84-45b0-b658-d0d531c61dab"
    }
  ],
  "OperatorParts": [
    {
      "MetaInstanceID": "db5951df-13fc-404f-a777-96ff0c12721e",
      "MetaID": "00b6b925-5651-4ca0-989f-cd3b0e7512b7",
      "Name": "RampFunc",
      "Version": "74441170-9432-4feb-86b8-4b82f3babc79",
      "Type": "Float",
      "IsMultiInput": "True",
      "Script": [
        "//>>> _using",
        "using System;",
        "using System.Collections.Generic;",
        "using System.Linq;",
        "using System.Text;",
        "using SharpDX;",
        "using SharpDX.Direct3D11;",
        "using SharpDX.Windows;",
        "//<<< _using",
        "",
        "namespace Framefield.Core.ID00b6b925_5651_4ca0_989f_cd3b0e7512b7",
        "{",
        "    public class Class_Ramp : FXImageFunction",
        "    {",
        "        //>>> _inputids",
        "        private enum InputId",
        "        {",
        "            Code = 0,",
        "            ColorAR = 1,",
        "            ColorAG = 2,",
        "            ColorAB = 3,",
        "            ColorAA = 4,",
        "            ColorBR = 5,",
        "            ColorBG = 6,",
        "            ColorBB = 7,",
        "            ColorBA = 8,",
        "            CenterX = 9,",
        "            CenterY = 10,",
        "            Angle = 11,",
        "            Feather = 12",
        "        }",
        "        //<<< _inputids",
        "",
        "        public override OperatorPartContext Eval(OperatorPartContext context, List<OperatorPart> inputs, int outputIdx) {",
        "            //>>> _params",
        "            var Code = inputs[(int)InputId.Code].Eval(context).Text;",
        "            var ColorAR = inputs[(int)InputId.ColorAR].Eval(context).Value;",
        "            var ColorAG = inputs[(int)InputId.ColorAG].Eval(context).Value;",
        "            var ColorAB = inputs[(int)InputId.ColorAB].Eval(context).Value;",
        "            var ColorAA = inputs[(int)InputId.ColorAA].Eval(context).Value;",
        "            var ColorA = new Color4(ColorAR, ColorAG, ColorAB, ColorAA);",
        "            var ColorBR = inputs[(int)InputId.ColorBR].Eval(context).Value;",
        "            var ColorBG = inputs[(int)InputId.ColorBG].Eval(context).Value;",
        "            var ColorBB = inputs[(int)InputId.ColorBB].Eval(context).Value;",
        "            var ColorBA = inputs[(int)InputId.ColorBA].Eval(context).Value;",
        "            var ColorB = new Color4(ColorBR, ColorBG, ColorBB, ColorBA);",
        "            var CenterX = inputs[(int)InputId.CenterX].Eval(context).Value;",
        "            var CenterY = inputs[(int)InputId.CenterY].Eval(context).Value;",
        "            var Center = new Vector2(CenterX, CenterY);",
        "            var Angle = inputs[(int)InputId.Angle].Eval(context).Value;",
        "            var Feather = inputs[(int)InputId.Feather].Eval(context).Value;",
        "            //<<< _params",
        "",
        "            return PrepareAndEvalOnChange(context, () => {",
        "                ClearRenderTarget(context, new SharpDX.Color4(0, 0, 0, 0));",
        "",
        "                //>>> _setup",
        "                {",
        "                    _effect.GetVariableByName(\"RenderTargetSize\").AsVector().Set(new Vector2(_usedViewport.Width, _usedViewport.Height));",
        "                    _effect.GetVariableByName(\"ColorA\").AsVector().Set(new Vector4(ColorAR, ColorAG, ColorAB, ColorAA));",
        "                    _effect.GetVariableByName(\"ColorB\").AsVector().Set(new Vector4(ColorBR, ColorBG, ColorBB, ColorBA));",
        "                    _effect.GetVariableByName(\"Center\").AsVector().Set(new Vector2(CenterX, CenterY));",
        "                    _effect.GetVariableByName(\"Angle\").AsScalar().Set(Angle);",
        "                    _effect.GetVariableByName(\"Feather\").AsScalar().Set(Feather);",
        "                //<<< _setup",
        "",
        "                Render(context);",
        "",
        "                //>>> _cleanup",
        "                }",
        "                //<<< _cleanup",
        "            });",
        "        }",
        "",
        "    }",
        "}",
        "",
        "",
        "",
        ""
      ],
      "AdditionalAssemblies": []
    }
  ],
  "Operators": [],
  "Connections": [
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "db5951df-13fc-404f-a777-96ff0c12721e",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "8869ee5c-c2dd-4827-b978-78492455bb48"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "e447fa8e-a8df-4b08-a949-b399135b2ef8",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "52f27bcd-2278-44f2-b644-5f48116a0dab",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "b5dd36fb-8162-4501-9bb0-cea697926c74",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "f230bfde-1525-4f9d-b22f-bc8c81303b7e",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "dd885289-c6ba-4981-977a-f1575f7a7c99",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "9724ce77-e9d2-444c-b6bb-b24442bda94e",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "477f48a2-7f56-4c3f-b79b-842dfa884b0d",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "9313c532-dc46-4b84-bea7-84e5afd892ce",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "f8a32b48-4cee-4b0f-b143-ad61e7ff436d",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "826f029c-6dad-4d95-89da-267f6a56d906",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "51f3dd97-8cf5-4ffa-8771-18a90661b050",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "b08290c4-008d-4d57-a61e-33426c925b0e",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    },
    {
      "SourceOp": "00000000-0000-0000-0000-000000000000",
      "SourceOpPart": "7e6b83bc-9421-4c8f-9e0d-83294ed63b43",
      "TargetOp": "00000000-0000-0000-0000-000000000000",
      "TargetOpPart": "db5951df-13fc-404f-a777-96ff0c12721e"
    }
  ]
}