예제 #1
0
        private void Update(EvaluationContext context)
        {
            var v   = Value.GetValue(context);
            var min = Min.GetValue(context);
            var max = Max.GetValue(context);

            Result.Value = MathUtil.Clamp(v, min, max);
        }
예제 #2
0
        private void Update(EvaluationContext context)
        {
            var min   = Min.GetValue(context);
            var max   = Max.GetValue(context);
            var input = this.Input.GetValue(context);

            Result.Value = (max - min) * input + min;
        }
        public override Color?GetBackgroundColor(decimal value, ConditionalFormatting conditionalFormatting)
        {
            var minValue = conditionalFormatting.GetMinValue();
            var maxValue = conditionalFormatting.GetMaxValue();
            var avgValue = Avg.GetValue(minValue, maxValue);

            var newMinValue = Min.GetValue(minValue, maxValue);

            if (newMinValue <= avgValue)
            {
                minValue = newMinValue;
            }

            var newMaxValue = Max.GetValue(minValue, maxValue);

            if (newMaxValue >= avgValue)
            {
                maxValue = newMaxValue;
            }

            if (maxValue == minValue)
            {
                if (value <= newMinValue && Min.Type == ConditionalFormattingVOType.Num)
                {
                    return(ColorMin);
                }

                if (value >= newMaxValue && Max.Type == ConditionalFormattingVOType.Num)
                {
                    return(ColorMax);
                }

                return(value < 0 ? ColorMin : ColorMax);
            }

            if (value <= minValue)
            {
                return(ColorMin);
            }

            if (value >= maxValue)
            {
                return(ColorMax);
            }

            if (value == avgValue)
            {
                return(ColorAvg);
            }

            if (value < avgValue)
            {
                return(MergeColors(value, minValue ?? 0, avgValue, ColorMin, ColorAvg));
            }

            return(MergeColors(value, avgValue, maxValue ?? 0, ColorAvg, ColorMax));
        }
예제 #4
0
        public void MaxTest(double a, double b)
        {
            var source0 = new Constant {
                ConstantValue = a
            };
            var source1 = new Constant {
                ConstantValue = b
            };
            var module = new Max {
                Source0 = source0, Source1 = source1
            };

            Assert.Equal(Math.Max(a, b), module.GetValue(0, 0, 0));
        }
예제 #5
0
        public void MaxTest()
        {
            var min = 0D;
            var max = 1D;

            var source0 = new Constant()
            {
                ConstantValue = min
            };
            var source1 = new Constant()
            {
                ConstantValue = max
            };
            var module = new Max()
            {
                Source0 = source0, Source1 = source1
            };

            Assert.AreEqual(max, module.GetValue(0, 0, 0));
        }
예제 #6
0
    private static void GenerateTrees()
    {
        Terrain     t  = Terrain.activeTerrain;
        TerrainData td = t.terrainData;

        TreePrototype[] treeprototypes = new TreePrototype[] { new TreePrototype()
                                                               {
                                                                   prefab = (GameObject)Resources.Load("BigTree")
                                                               }, new TreePrototype()
                                                               {
                                                                   prefab = (GameObject)Resources.Load("Tree")
                                                               } };

        td.treePrototypes = treeprototypes;

        //float[, ,] splatmaps = td.GetAlphamaps(0, 0, td.alphamapWidth, td.alphamapHeight);
        td.treeInstances = new TreeInstance[0];

        List <Vector3> treePos = new List <Vector3>();

        float[,] noisemap = new float[td.alphamapWidth, td.alphamapHeight];
        Generator noise_tree = new Max(
            new PinkNoise((int)UnityEngine.Random.Range(0, int.MaxValue))
        {
            Frequency = 0.01f, OctaveCount = 6, Persistence = 0.66f, Lacunarity = 0.1f
        },
            new PinkNoise((int)UnityEngine.Random.Range(0, int.MaxValue))
        {
            Frequency = 0.015f, OctaveCount = 2, Persistence = 0.66f, Lacunarity = 0.2f
        });

        for (int ny = 0; ny < noisemap.GetLength(1); ny++)
        {
            for (int nx = 0; nx < noisemap.GetLength(0); nx++)
            {
                noisemap[nx, ny] = noise_tree.GetValue(nx, ny, 0);
            }
        }
        if (maxSteepness == 0)
        {
            maxSteepness = 70.0f;
        }
        if (waterLevel == 0)
        {
            waterLevel = 0.0f;
        }
        float x = 0.0f;

        while (x < td.alphamapWidth)
        {
            float y = 0.0f;
            while (y < td.alphamapHeight)
            {
                float height       = td.GetHeight((int)x, (int)y);
                float heightScaled = height / td.size.y;
                float xScaled      = (x + Random.Range(-1f, 1f)) / td.alphamapWidth;
                float yScaled      = (y + Random.Range(-1f, 1f)) / td.alphamapHeight;
                float steepness    = td.GetSteepness(xScaled, yScaled);

                if (Random.Range(0f, 1f) > 1f - noisemap[(int)x, (int)y] * 2f && steepness <maxSteepness && height> waterLevel)
                {
                    treePos.Add(new Vector3(xScaled, heightScaled, yScaled));
                }

                y++;
            }
            x++;
        }

        TreeInstance[] treeInstances = new TreeInstance[treePos.Count];

        for (int ii = 0; ii < treeInstances.Length; ii++)
        {
            treeInstances[ii].position       = treePos[ii];
            treeInstances[ii].prototypeIndex = Random.Range(0, treeprototypes.Length);
            treeInstances[ii].color          = Color.white;//new Color(Random.Range(200, 255), Random.Range(200, 255), Random.Range(200, 255));
            treeInstances[ii].lightmapColor  = Color.white;
            treeInstances[ii].heightScale    = 1.0f + Random.Range(-0.25f, 0.5f);
            treeInstances[ii].widthScale     = 1.0f + Random.Range(-0.5f, 0.25f);
        }
        td.treeInstances = treeInstances;
    }
예제 #7
0
파일: Random.cs 프로젝트: still-scene/t3
        private void Update(EvaluationContext context)
        {
            var random         = new System.Random(Seed.GetValue(context));
            var firstIsGarbage = (float)random.NextDouble();

            Result.Value = (float)MathUtils.Remap((float)random.NextDouble(), 0f, 1f, Min.GetValue(context), Max.GetValue(context));
        }
예제 #8
0
파일: QBetween.cs 프로젝트: radtek/datawf
 public object MaxValue()
 {
     return(Max.GetValue());
 }