private static void SpawnCursor() { var cur_size = 128; var pi = Math.Atan(1) * 4; var frames = 24; var a = from i in (from j in Enumerable.Range(0, (frames / 2) - 0) select j / frames * pi) //let x = Math.Cos(i) //let y = Math.Sin(i) select new XPosition { x = Math.Cos(i), y = Math.Sin(i) }; //a.ForEach(z => Console.WriteLine(z.ToString())); var moon_frames = frames * 1.3; var moon_range = (int)Math.Floor((moon_frames * 0.33)); var moon_max = (0 - (moon_range / 2)) / moon_frames * pi; var dualmoon = (from offset in (from j in Enumerable.Range(0, moon_range) select (j - (moon_range / 2)) / moon_frames * pi) select new XDualMoon { offset = offset, moon1 = new SpecialLayer(), moon2 = new SpecialLayer() }).ToArray(); dualmoon.ForEach( dual => { double op = 1 - (Math.Abs((double)(dual.offset / moon_max))); int size = (int)Math.Floor(4 * (op + 1)); dual.moon1.div.style.Opacity = 0.6; dual.moon2.div.style.Opacity = 0.6; dual.moon1.x = size; dual.moon1.y = size; dual.moon2.x = size; dual.moon2.y = size; dual.moon1.div.style.Opacity = op; dual.moon2.div.style.Opacity = op; dual.moon1.div.className = "moon1"; dual.moon2.div.className = "moon1"; dual.moon1.div.AttachToDocument(); } ); var b = a.Select( i => { var layer = new SpecialLayer { x = (int)System.Math.Floor(i.x * cur_size), y = (int)System.Math.Floor(i.y * cur_size) }; layer.div.style.Opacity = 0.4; layer.div.className = "effect1"; layer.div.AttachToDocument(); return layer; } ).ToArray(); var p = new Point(0, 0); dualmoon.ForEach( dual => { dual.moon2.div.AttachToDocument(); } ); System.Action moon_update = () => { var seed = IDate.Now.getTime() / 1000; dualmoon.ForEach( dual => { double rad = seed + dual.offset; var deg = (rad + pi / 2) % (2 * pi); if (deg > pi) { deg = (2 * pi) - deg; } deg /= pi; if (deg > 0.5) { dual.moon1.div.style.visibility = IStyle.VisibilityEnum.hidden; dual.moon2.div.style.visibility = IStyle.VisibilityEnum.visible; } else { dual.moon1.div.style.visibility = IStyle.VisibilityEnum.visible; dual.moon2.div.style.visibility = IStyle.VisibilityEnum.hidden; } new[] { dual.moon1 }.Concat(new[] { dual.moon2 }).ForEach( moon => { var cos = Math.Cos(rad) * cur_size; moon.SetCenteredLocation( (int)Math.Floor(p.X + cos), (int)Math.Floor(p.Y + -cos * 0.6) ); moon.zoom = 1 + deg; moon.UpdateSize(); } ); }); }; Native.Document.onmousemove += delegate(IEvent ev) { p = ev.CursorPosition; b.ForEach( layer => { layer.SetCenteredLocation(p.X, p.Y); layer.UpdateSize(); } ); moon_update(); }; new Timer( t => { moon_update(); } , 1, 150); }
private static void SpawnCursor() { var cur_size = 128; var pi = Math.Atan(1) * 4; var frames = 24; var a = from i in (from j in Enumerable.Range(0, (frames / 2) - 0) select j / frames * pi) //let x = Math.Cos(i) //let y = Math.Sin(i) select new XPosition { x = Math.Cos(i), y = Math.Sin(i) }; //a.ForEach(z => Console.WriteLine(z.ToString())); var moon_frames = frames * 1.3; var moon_range = (int)Math.Floor((moon_frames * 0.33)); var moon_max = (0 - (moon_range / 2)) / moon_frames * pi; var dualmoon = (from offset in (from j in Enumerable.Range(0, moon_range) select(j - (moon_range / 2)) / moon_frames * pi) select new XDualMoon { offset = offset, moon1 = new SpecialLayer(), moon2 = new SpecialLayer() }).ToArray(); dualmoon.ForEach( dual => { double op = 1 - (Math.Abs((double)(dual.offset / moon_max))); int size = (int)Math.Floor(4 * (op + 1)); dual.moon1.div.style.Opacity = 0.6; dual.moon2.div.style.Opacity = 0.6; dual.moon1.x = size; dual.moon1.y = size; dual.moon2.x = size; dual.moon2.y = size; dual.moon1.div.style.Opacity = op; dual.moon2.div.style.Opacity = op; dual.moon1.div.className = "moon1"; dual.moon2.div.className = "moon1"; dual.moon1.div.AttachToDocument(); } ); var b = a.Select( i => { var layer = new SpecialLayer { x = (int)System.Math.Floor(i.x * cur_size), y = (int)System.Math.Floor(i.y * cur_size) }; layer.div.style.Opacity = 0.4; layer.div.className = "effect1"; layer.div.AttachToDocument(); return(layer); } ).ToArray(); var p = new Point(0, 0); dualmoon.ForEach( dual => { dual.moon2.div.AttachToDocument(); } ); System.Action moon_update = () => { var seed = IDate.Now.getTime() / 1000; dualmoon.ForEach( dual => { double rad = seed + dual.offset; var deg = (rad + pi / 2) % (2 * pi); if (deg > pi) { deg = (2 * pi) - deg; } deg /= pi; if (deg > 0.5) { dual.moon1.div.style.visibility = IStyle.VisibilityEnum.hidden; dual.moon2.div.style.visibility = IStyle.VisibilityEnum.visible; } else { dual.moon1.div.style.visibility = IStyle.VisibilityEnum.visible; dual.moon2.div.style.visibility = IStyle.VisibilityEnum.hidden; } new[] { dual.moon1 }.Concat(new[] { dual.moon2 }).ForEach( moon => { var cos = Math.Cos(rad) * cur_size; moon.SetCenteredLocation( (int)Math.Floor(p.X + cos), (int)Math.Floor(p.Y + -cos * 0.6) ); moon.zoom = 1 + deg; moon.UpdateSize(); } ); }); }; Native.Document.onmousemove += delegate(IEvent ev) { p = ev.CursorPosition; b.ForEach( layer => { layer.SetCenteredLocation(p.X, p.Y); layer.UpdateSize(); } ); moon_update(); }; new Timer( t => { moon_update(); } , 1, 150); }