Beispiel #1
0
 public Indexer(IList <T> source, ClampMode addressing)
 {
     _source    = source;
     _width     = source.Count;
     _height    = 1;
     _adressing = addressing;
 }
Beispiel #2
0
 public Indexer(IList <T> source, int stride, ClampMode adressing)
 {
     _source    = source;
     _width     = stride;
     _height    = source.Count / _width;
     _adressing = adressing;
 }
    public int PlanImport(Nutrients nutrient, int requested, ClampMode mode)
    {
        int allowed;
        MetabolismOptions meOp;

        if (nutrient == Nutrients.AA)
        {
            allowed = Budget(ref importAA, requested, mode == ClampMode.Self);
            meOp    = MetabolismOptions.ImportAA;
        }
        else if (nutrient == Nutrients.C)
        {
            allowed = Budget(ref importC, requested, mode == ClampMode.Self);
            meOp    = MetabolismOptions.ImportC;
        }
        else
        {
            allowed = Budget(ref importN, requested, mode == ClampMode.Self);
            meOp    = MetabolismOptions.ImportN;
        }

        if (mode == ClampMode.Others)
        {
            ClampOthers(meOp);
        }
        return(allowed);
    }
Beispiel #4
0
        // -----------------
        public JoystickConfig() : base()
        {
            this.clampMode     = ClampMode.Square;
            this.angularMagnet = 0.5f;

            this.digitalLeaveThresh = 0.3f;
            this.digitalEnterThresh = 0.6f;
        }
    public int PlanMaintenance(int requested, ClampMode mode)
    {
        int allowed = Budget(ref maintenance, requested, mode == ClampMode.Self);

        if (mode == ClampMode.Others)
        {
            ClampOthers(MetabolismOptions.Maintenance);
        }
        return(allowed);
    }
    public int PlanExportWaste(int requested, ClampMode mode)
    {
        int allowed = Budget(ref export, requested, mode == ClampMode.Self);

        if (mode == ClampMode.Others)
        {
            ClampOthers(MetabolismOptions.ExportWaste);
        }
        return(allowed);
    }
Beispiel #7
0
        private void Localize(ref int x, ref int y, ClampMode mode)
        {
            switch (mode)
            {
            case ClampMode.Clamp:
                y = Math.Min(_height - 1, Math.Max(0, y));
                x = Math.Min(_width - 1, Math.Max(0, x));
                return;

            case ClampMode.Wrap:
                y += x / _width;
                x  = mod(x, _width);
                y  = mod(y, _height);
                return;

            case ClampMode.Repeat:
                x = mod(x, _width);
                y = mod(y, _height);
                return;
            }
        }
Beispiel #8
0
 public void Set(int x, int y, ClampMode mode, T value)
 {
     Localize(ref x, ref y, mode);
     _source[y * _width + x] = value;
 }
Beispiel #9
0
 public T Get(int x, int y, ClampMode mode)
 {
     Localize(ref x, ref y, mode);
     return(_source[y * _width + x]);
 }
Beispiel #10
0
    Color ClampToNearestColor(Color c, ClampMode clampMode)
    {
        if (JBirdPalette == null)
        {
            return(c);
        }
        float minDist = 1000f;
        Color closest = Color.white;

        switch (clampMode)
        {
        case ClampMode.NoClamp:
            return(c);

        case ClampMode.ClosestRGB:
            foreach (Color c2 in JBirdPalette.colorList)
            {
                float dist = ColorDistanceRGB(c, c2);
                if (dist < minDist)
                {
                    minDist = dist;
                    closest = c2;
                }
            }
            break;

        case ClampMode.HSVCylinder:
            foreach (Color c2 in JBirdPalette.colorList)
            {
                float dist = ColorDistanceHSVCylinder(c, c2);
                if (dist < minDist)
                {
                    minDist = dist;
                    closest = c2;
                }
            }
            break;

        case ClampMode.HSVCone:
            foreach (Color c2 in JBirdPalette.colorList)
            {
                float dist = ColorDistanceHSVCone(c, c2);
                if (dist < minDist)
                {
                    minDist = dist;
                    closest = c2;
                }
            }
            break;

        case ClampMode.ClosestLuma:
            foreach (Color c2 in JBirdPalette.colorList)
            {
                float dist = ColorDistanceLuma(c, c2);
                if (dist < minDist)
                {
                    minDist = dist;
                    closest = c2;
                }
            }
            break;
        }
        return(closest);
    }