public SerializableUnifiedRandomFLBuffer(string name, FLBufferModifiers modifiers, int size) : base( name, modifiers ) { Size = size; }
public override object Deserialize(PrimitiveValueWrapper s) { string name = ResolveId(s.ReadInt()); FLBufferModifiers bmod = new FLBufferModifiers(name, s.ReadArray <string>()); return(new SerializableRandomFLBuffer(name, bmod, bmod.IsArray ? s.ReadInt() : 0)); }
public SerializableFromBitmapFLBuffer(string name, Bitmap bmp, FLBufferModifiers modifiers, int size) : base( name, modifiers ) { Bitmap = bmp; Size = size; }
public SerializableFromFileFLBuffer(string name, string file, FLBufferModifiers modifiers, int size) : base( name, null, modifiers, size ) { File = file; }
public SerializableFromBinaryFLBuffer( string name, byte[] data, int width, int height, int depth, FLBufferModifiers modifiers) : base(name, modifiers) { Data = data; Width = width; Height = height; Depth = depth; }
public override SerializableFLBuffer CreateBuffer( string name, string[] args, FLBufferModifiers modifiers, int arraySize) { if (!modifiers.IsArray) { throw new InvalidOperationException("Can not load a csv file as a texture."); } byte[] csvData = ParseCSV(args[0].Replace("\"", "")); return(new SerializableFromBinaryFLBuffer(name, csvData, csvData.Length, 1, 1, modifiers)); }
public override SerializableFLBuffer CreateBuffer( string name, string[] args, FLBufferModifiers modifiers, int arraySize) { if (modifiers.IsArray && arraySize <= 0) { throw new InvalidOperationException( $"Random Array buffer \"{name}\" has to be initialized with a size as the first argument" ); } return(new SerializableRandomFLBuffer(name, modifiers, arraySize)); }
public SerializableFLBuffer Create( string key, string name, string[] arguments, FLBufferModifiers modifiers, int size) { for (int i = 0; i < bufferCreators.Count; i++) { if (bufferCreators[i].IsCorrectBuffer(key)) { return bufferCreators[i].CreateBuffer(name, arguments, modifiers, size); } } throw new FLBufferCreatorNotFoundException($"'{key}' is not a valid Buffer Creator Name"); }
public override object Deserialize(PrimitiveValueWrapper s) { string name = ResolveId(s.ReadInt()); string[] mods = s.ReadArray <string>(); FLBufferModifiers bmod = new FLBufferModifiers(name, mods); if (bmod.IsArray) { return(new SerializableEmptyFLBuffer(name, s.ReadInt(), bmod)); } return(new SerializableEmptyFLBuffer(name, bmod)); }
public override object Deserialize(PrimitiveValueWrapper s) { string name = ResolveId(s.ReadInt()); bool raw = s.ReadBool(); FLBufferModifiers bmod = new FLBufferModifiers(name, s.ReadArray <string>()); if (raw) { MemoryStream ms = new MemoryStream(s.ReadBytes()); Bitmap bmp = (Bitmap)Image.FromStream(ms); return(new SerializableFromBitmapFLBuffer(name, bmp, bmod, bmod.IsArray ? s.ReadInt() : 0)); } string file = s.ReadString(); return(new SerializableFromFileFLBuffer(name, file, bmod, bmod.IsArray ? s.ReadInt() : 0)); }
public override object Deserialize(PrimitiveValueWrapper s) { string name = ResolveId(s.ReadInt()); FLBufferModifiers bmod = new FLBufferModifiers(name, s.ReadArray <string>()); bool force = s.ReadBool(); int n = s.ReadInt(); int width = s.ReadInt(); int height = s.ReadInt(); int symmetry = s.ReadInt(); int ground = s.ReadInt(); int limit = s.ReadInt(); bool pIn = s.ReadBool(); bool pOut = s.ReadBool(); MemoryStream ms = new MemoryStream(s.ReadBytes()); Bitmap bmp = (Bitmap)Image.FromStream(ms); WFCParameterObject obj = new WFCParameterObject( new SerializableFromBitmapFLBuffer( "wfc-bin", bmp, bmod, bmod.IsArray ? s.ReadInt() : 0 ), n, width, height, symmetry, ground, limit, pIn, pOut, force ); return(new SerializableWaveFunctionCollapseFLBuffer(name, obj, bmod)); }
public LazyFromFileFLBuffer(string file, bool isArray, int size, FLBufferModifiers modifiers) : base( null, modifiers .InitializeOnStart ) { File = file; MemoryFlag flag = modifiers.IsReadOnly ? MemoryFlag.ReadOnly : MemoryFlag.ReadWrite; if (isArray) { Loader = root => { Bitmap bmp = new Bitmap(Image.FromStream(IOManager.GetStream(File))); FLBuffer buf = new FLBuffer(root.Instance, bmp, DefinedBufferName + ":" + File, flag); bmp.Dispose(); return(buf); }; } else { Loader = root => { if (File == "INPUT") { return(root.Input); } Bitmap bmp = new Bitmap( Image.FromStream(IOManager.GetStream(File)), root.Dimensions.x, root.Dimensions.y ); FLBuffer buf = new FLBuffer(root.Instance, bmp, DefinedBufferName + ":" + File, flag); bmp.Dispose(); return(buf); }; } }
public abstract SerializableFLBuffer CreateBuffer( string name, string[] args, FLBufferModifiers modifiers, int arraySize);
private List <SerializableFLBuffer> ParseDefinedBuffersTask( List <DefineStatement> defineStatements, int start, int count) { List <SerializableFLBuffer> definedBuffers = new List <SerializableFLBuffer>(); for (int i = start; i < start + count; i++) { FLBufferModifiers bmod = defineStatements[i].Modifiers as FLBufferModifiers; string name = defineStatements[i].Name; List <string> parameter = defineStatements[i].Parameter.ToList(); string bufferName = bmod.ElementName; if (bufferName == FLKeywords.InputBufferKey) { SerializableFLBuffer bi = new SerializableEmptyFLBuffer(FLKeywords.InputBufferKey, bmod); definedBuffers.Add(bi); continue; } string creatorKey = parameter.First(); parameter.RemoveAt(0); if (creatorKey.StartsWith("\"") && creatorKey.EndsWith("\"") ) //IOManager.FileExists(paramPart.Trim().Replace("\"", "")) { string path = creatorKey.Trim().Replace("\"", ""); SerializableFromFileFLBuffer bi = new SerializableFromFileFLBuffer(bufferName, path, bmod, 0); definedBuffers.Add(bi); } else { int size = -1; if (bmod.IsArray && parameter.Count != 0 && !int.TryParse( parameter[0], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out size )) { } SerializableFLBuffer buf = parser.BufferCreator.Create(creatorKey, bufferName, parameter.ToArray(), bmod, size); if (buf != null) { definedBuffers.Add(buf); } else { throw new Byt3Exception($"Can not Find BufferLoader for \"{defineStatements[i]}\""); } } } return(definedBuffers); }
protected SerializableFLBuffer(string name, FLBufferModifiers modifiers) : base(name) { Modifiers = modifiers; }
public override SerializableFLBuffer CreateBuffer( string name, string[] args, FLBufferModifiers modifiers, int arraySize) { return(new SerializableFromFileFLBuffer(name, args[0].Replace("\"", ""), modifiers, arraySize)); }
public override SerializableFLBuffer CreateBuffer( string name, string[] args, FLBufferModifiers modifiers, int arraySize) { return(WFCParameterObject.CreateBuffer(name, args, false, modifiers, arraySize)); }
public SerializableEmptyFLBuffer(string name, int size, FLBufferModifiers modifiers) : base(name, modifiers) { Size = size; }
public SerializableWaveFunctionCollapseFLBuffer( string name, WFCParameterObject parameter, FLBufferModifiers modifiers) : base(name, modifiers) { Parameter = parameter; }
public SerializableScriptBuffer( string name, FLBufferModifiers modifiers, FLBuffer buf) : base(name, modifiers) { buffer = buf; }
public static SerializableFLBuffer CreateBuffer( string name, string[] args, bool force, FLBufferModifiers modifiers, int size) { if (modifiers.IsArray) { throw new FLInvalidFunctionUseException( "wfc", "Invalid WFC Define statement. WFC can not be used on arrays" ); } if (args.Length < 9) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } if (!int.TryParse(args[1], out int n)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } if (!int.TryParse(args[2], out int widh)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } if (!int.TryParse(args[3], out int heigt)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } if (!bool.TryParse(args[4], out bool periodicInput)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } if (!bool.TryParse(args[5], out bool periodicOutput)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } if (!int.TryParse(args[6], out int symmetry)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } if (!int.TryParse(args[7], out int ground)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } if (!int.TryParse(args[8], out int limit)) { throw new FLInvalidFunctionUseException("wfc", "Invalid WFC Define statement"); } string fn = args[0].Trim().Replace("\"", ""); if (IOManager.FileExists(fn)) { SerializableFromFileFLBuffer input = new SerializableFromFileFLBuffer("WFCInputBuffer", fn, modifiers, size); WFCParameterObject wfcPO = new WFCParameterObject( input, n, widh, heigt, symmetry, ground, limit, periodicInput, periodicOutput, force ); return(new SerializableWaveFunctionCollapseFLBuffer(name, wfcPO, modifiers)); } throw new FLInvalidFunctionUseException( "wfc", "Invalid WFC Image statement", new InvalidFilePathException(fn) ); }
public SerializableEmptyFLBuffer(string name, FLBufferModifiers modifiers) : base(name, modifiers) { }