Esempio n. 1
0
        public override void Execute(SharedObjects shared)
        {
            int argc = CountRemainingArgs(shared);

            // Handle the var args that might be passed in, or give defaults if fewer args:
            bool   wiping = (argc >= 9) ? Convert.ToBoolean(PopValueAssert(shared)) : true;
            bool   pointy = (argc >= 8) ? Convert.ToBoolean(PopValueAssert(shared)) : true;
            double width  = (argc >= 7) ? GetDouble(PopValueAssert(shared))         : 0.2;
            bool   show   = (argc >= 6) ? Convert.ToBoolean(PopValueAssert(shared)) : false;
            double scale  = (argc >= 5) ? GetDouble(PopValueAssert(shared))         : 1.0;
            string str    = (argc >= 4) ? PopValueAssert(shared).ToString()         : "";

            // Pop the arguments or use the default if omitted
            object argRgba  = (argc >= 3) ? PopValueAssert(shared) : GetDefaultColor();
            object argVec   = (argc >= 2) ? PopValueAssert(shared) : GetDefaultVector();
            object argStart = (argc >= 1) ? PopValueAssert(shared) : GetDefaultStart();

            // Assign the arguments of type delegate or null otherwise
            KOSDelegate colorUpdater = argRgba  as KOSDelegate;
            KOSDelegate vecUpdater   = argVec   as KOSDelegate;
            KOSDelegate startUpdater = argStart as KOSDelegate;

            // Get the values or use the default if its a delegate
            RgbaColor rgba  = (colorUpdater == null) ? GetRgba(argRgba)    : GetDefaultColor();
            Vector    vec   = (vecUpdater == null)   ? GetVector(argVec)   : GetDefaultVector();
            Vector    start = (startUpdater == null) ? GetVector(argStart) : GetDefaultStart();

            AssertArgBottomAndConsume(shared);
            DoExecuteWork(shared, start, vec, rgba, str, scale, show, width, pointy, wiping, colorUpdater, vecUpdater, startUpdater);
        }
Esempio n. 2
0
        public void DoExecuteWork(
            SharedObjects shared,
            Vector start,
            Vector vec,
            RgbaColor rgba,
            string str,
            double scale,
            bool show,
            double width,
            bool pointy,
            bool wiping,
            KOSDelegate colorUpdater,
            KOSDelegate vecUpdater,
            KOSDelegate startUpdater)
        {
            var vRend = new VectorRenderer(shared.UpdateHandler, shared)
            {
                Vector = vec,
                Start  = start,
                Color  = rgba,
                Scale  = scale,
                Width  = width,
                Pointy = pointy,
                Wiping = wiping
            };

            vRend.SetLabel(str);
            vRend.SetShow(show);

            if (colorUpdater != null)
            {
                vRend.SetSuffix("COLORUPDATER", colorUpdater);
            }

            if (vecUpdater != null)
            {
                vRend.SetSuffix("VECUPDATER", vecUpdater);
            }

            if (startUpdater != null)
            {
                vRend.SetSuffix("STARTUPDATER", startUpdater);
            }

            ReturnValue = vRend;
        }