Exemple #1
0
        public NetworkGraphState(NetworkGraphData <T> data, NetworkGraphConfig cfg)
        {
            _cfg          = cfg;
            _data         = data;
            Positions     = new Vector2[data.Count];
            Displacements = new Vector2[data.Count];
            Inertia       = new float[data.Count];

            var r = new Random(cfg.LayoutSeed);

            // randomize the initial positions
            for (var i = 0; i < Positions.Length; i++)
            {
                var x = r.NextDouble() * 2.0 - 1.0;
                var y = r.NextDouble() * 2.0 - 1.0;
                Positions[i] = new Vector2((float)x * 1, (float)y * 1);
                Positions[i].Normalize();
                Positions[i] *= 5.0f;
                // more falloff for inertia.
                Inertia[i] = (float)r.NextDouble() * (float)r.NextDouble() * RandomInertiaFactor;
            }

            Camera = new DampenedCamera2D {
                VerticalSizeDampeningFactor = 0.5f,
                PositionDampeningFactor     = 0.1f
            };
            Camera.Target.VerticalSize  = 5;
            Camera.Current.VerticalSize = 5;
            Camera.Snap();
        }
Exemple #2
0
 public NetworkGraph([NotNull] NetworkGraphData <T> data, [CanBeNull] NetworkGraphConfig cfg = null)
 {
     cfg ??= NetworkGraphConfig.Default;
     cfg       = cfg.Copy();
     _cfg      = cfg;
     _data     = data;
     _state    = new NetworkGraphState <T>(data, cfg);
     _renderer = new NetworkGraphRenderer <T>(cfg);
 }
 public NetworkGraphRenderer(NetworkGraphConfig cfg)
 {
     _cfg = cfg;
 }