/// <summary>Convenience function. It also helps to cache the original property value and straight edit that.</summary> public void Set(string property, Texture value) { // Get the property: SurfaceProperty prop = GetProperty(property, true); // Get as tex: Values.TextureValue v = prop.Value as Values.TextureValue; // Set it: if (v == null) { prop.Value = new Values.TextureValue(value); } else { v.Value = value; if (v.Changed) { // No longer idling - changes detected. Changed = true; } } }
/// <summary>Builds a Loonim filter from the given set of one or more CSS functions.</summary> public static void BuildFilter(Css.Value value, RenderableData context, FilterEventDelegate fe) { if (value is Css.Functions.UrlFunction) { // - (A URL to an SVG filter) (not supported yet here) // - A URL to a Loonim filter (with a property called source0) // Load it now! DataPackage dp = new DataPackage(value.Text, context.Document.basepath); dp.onload = delegate(UIEvent e){ // Got the data! Load a filter now: SurfaceTexture st = null; // Create: st = new SurfaceTexture(); // Load it: st.Load(dp.responseBytes); // Run the callback: fe(context, st); }; // Send: dp.send(); } else { Loonim.TextureNode first = null; Loonim.TextureNode last = null; // - One or more filter functions if (value is Css.CssFunction) { // Just one first = last = value.ToLoonimNode(context); } else if (value is Css.ValueSet) { // Many for (int i = 0; i < value.Count; i++) { // Convert to a Loonim node: Loonim.TextureNode next = value[i].ToLoonimNode(context); if (next == null) { // Quit! first = null; last = null; break; } // Hook it on: if (first == null) { first = last = next; } else { // Add it to the chain: last.Sources[0] = next; last = next; } } } SurfaceTexture st = null; if (first != null) { // Create the texture: st = new SurfaceTexture(); st["source0"] = new Values.TextureValue(null); st.Root = first; first.Sources[0] = new Loonim.Property(st, "source0"); } // Run the callback now! fe(context, st); } }