Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

UGR Reader node.

  • Loading branch information...
commit a0b1ff415ca8e4904e468af60c4f5cc402ca56be 1 parent a7d0436
mrvux authored
36 vvvv45/addonpack/src/nodes/plugins/File/UGRReader/UGRReader/Properties/AssemblyInfo.cs
View
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("UGRReader")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("UGRReader")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("513ce2dd-331b-4366-8785-2acc38aaaa93")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
72 vvvv45/addonpack/src/nodes/plugins/File/UGRReader/UGRReader/UGRReader.csproj
View
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{46B04D42-C875-40C3-849B-CD025AF1F771}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>VVVV.Nodes</RootNamespace>
+ <AssemblyName>UGRReader</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.ComponentModel.Composition.Codeplex">
+ <HintPath>..\..\..\..\..\..\..\lib\core\System.ComponentModel.Composition.Codeplex.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Core" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="UGRReaderNode.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\..\..\core\PluginInterfaces\PluginInterfaces.csproj">
+ <Project>{837C740A-485C-424C-8C38-086ED3DC73CB}</Project>
+ <Name>PluginInterfaces</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\..\..\core\Utils3rdParty\Utils3rdParty.csproj">
+ <Project>{87863121-C124-4585-B3BB-7706F03ECC64}</Project>
+ <Name>Utils3rdParty</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\..\..\core\Utils\Utils.csproj">
+ <Project>{C3773330-81FA-4253-823E-1BDE1529AA99}</Project>
+ <Name>Utils</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
164 vvvv45/addonpack/src/nodes/plugins/File/UGRReader/UGRReader/UGRReaderNode.cs
View
@@ -0,0 +1,164 @@
+#region usings
+using System;
+using System.ComponentModel.Composition;
+using System.Collections.Generic;
+
+using VVVV.PluginInterfaces.V1;
+using VVVV.PluginInterfaces.V2;
+using VVVV.Utils.VColor;
+using VVVV.Utils.VMath;
+
+using System.IO;
+#endregion usings
+
+namespace VVVV.Nodes
+{
+ public class UGRColor
+ {
+ public int index;
+ public RGBAColor color;
+ }
+
+ #region PluginInfo
+ [PluginInfo(Name = "UGRReader", Category = "File", Help = "Reads Ultra Fractal Gradient file",Author="vux", Tags = "")]
+ #endregion PluginInfo
+ public class UGRReaderNode : IPluginEvaluate
+ {
+ #region fields & pins
+ [Input("Path", StringType = StringType.Filename)]
+ IDiffSpread<string> FPath;
+
+ [Input("Reload", IsBang = true)]
+ ISpread<bool> FReset;
+
+ [Input("Gradient Index")]
+ IDiffSpread<int> FEntry;
+
+ [Output("Output")]
+ ISpread<RGBAColor> FOutput;
+
+ [Output("Names")]
+ ISpread<string> FOutNames;
+ #endregion fields & pins
+
+ //private string ename;
+ private List<List<UGRColor>> g = new List<List<UGRColor>>();
+
+ //called when data for any output pin is requested
+ public void Evaluate(int SpreadMax)
+ {
+ bool reset = false;
+ if (FPath.IsChanged || FReset[0])
+ {
+ reset = true;
+ g.Clear();
+
+ if (File.Exists(FPath[0]))
+ {
+ string[] lines = File.ReadAllLines(FPath[0]);
+ bool name = false;
+
+
+
+ List<string> res = new List<string>();
+ List<UGRColor> colors = new List<UGRColor>();
+ UGRColor color = new UGRColor();
+
+ foreach (string s in lines)
+ {
+ string strim = s.Trim();
+ if (!name)
+ {
+ if (strim.Contains("{"))
+ {
+ string sub = s.Replace("{", "");
+ sub = sub.Replace(" ", "");
+ res.Add(sub);
+ name = true;
+ colors = new List<UGRColor>();
+ }
+ }
+ else
+ {
+ bool index = true;
+ bool done = false;
+
+ string[] elems = strim.Split(" ".ToCharArray());
+
+
+ //First line is gradient, ignore
+ if (!strim.StartsWith("gradient"))
+ {
+ foreach (string elem in elems)
+ {
+ if (elem.StartsWith("index="))
+ {
+ color = new UGRColor();
+ //FLogger.Log(LogType.Debug,elem);
+ string[] spl = elem.Split("=".ToCharArray());
+
+ color.index = Convert.ToInt32(spl[1]);
+ }
+ else
+ {
+ if (elem.StartsWith("color="))
+ {
+ //FLogger.Log(LogType.Debug,elem);
+ string[] spl = elem.Split("=".ToCharArray());
+ int colint = Convert.ToInt32(spl[1]);
+ color.color = System.Drawing.Color.FromArgb(colint);
+ color.color.A = 1;
+ colors.Add(color);
+ }
+ }
+
+ }
+ }
+
+ if (strim.Contains("}"))
+ {
+ name = false;
+ g.Add(colors);
+ }
+ }
+ }
+ this.FOutNames.AssignFrom(res);
+ }
+ }
+
+ //Now output
+ if (g.Count > 0 && (this.FEntry.IsChanged || reset))
+ {
+ int idx = this.FEntry[0] % g.Count;
+
+ List<RGBAColor> res = new List<RGBAColor>();
+ List<UGRColor> ucols = g[idx];
+
+ int colcount = ucols[ucols.Count - 1].index;
+
+ int ucolidx = 1;
+ UGRColor previous = ucols[0];
+ bool first = true;
+
+ res.Add(previous.color);
+
+ for (int i = 1; i < colcount; i++)
+ {
+ if (i == ucols[ucolidx].index)
+ {
+ //Increment and move to next color
+ ucolidx++;
+ previous = ucols[ucolidx];
+ }
+ res.Add(previous.color);
+ }
+
+ this.FOutput.SliceCount = res.Count;
+ for (int i = 0; i < res.Count; i++)
+ {
+ this.FOutput[i] = res[i];
+ }
+ }
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.