当前位置: 首页>>代码示例>>C#>>正文


C# Constant.GetValue方法代码示例

本文整理汇总了C#中Constant.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Constant.GetValue方法的具体用法?C# Constant.GetValue怎么用?C# Constant.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Constant的用法示例。


在下文中一共展示了Constant.GetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitConstant

 public virtual void VisitConstant(Constant c)
 {
     if (!c.IsValid)
     {
         writer.Write("<invalid>");
         return;
     }
     PrimitiveType t = c.DataType as PrimitiveType;
     if (t != null)
     {
         if (t.Domain == Domain.Boolean)
         {
             writer.Write(Convert.ToBoolean(c.GetValue()) ? "true" : "false");
         }
         else
         {
             object v = c.GetValue();
             writer.Write(FormatString(t, v), v);
         }
         return;
     }
     StringConstant s = c as StringConstant;
     if (s != null)
     {
         writer.Write("{0}{1}{0}", '"', s.GetValue());
     }
 }
开发者ID:gitter-badger,项目名称:reko,代码行数:27,代码来源:CodeFormatter.cs

示例2: button1_Click


//.........这里部分代码省略.........
                    slowPlanetFinal.EdgeFalloff = 0.5;

                    module = slowPlanetFinal;
                    break;
                case "Fast Planet":
                    mapToSphere = true;

                    FastNoise fastPlanetContinents = new FastNoise(seed);
                    fastPlanetContinents.Frequency = 1.5;

                    FastBillow fastPlanetLowlands = new FastBillow();
                    fastPlanetLowlands.Frequency = 4;
                    LibNoise.Modifiers.ScaleBiasOutput fastPlanetLowlandsScaled = new ScaleBiasOutput(fastPlanetLowlands);
                    fastPlanetLowlandsScaled.Scale = 0.2;
                    fastPlanetLowlandsScaled.Bias = 0.5;

                    FastRidgedMultifractal fastPlanetMountainsBase = new FastRidgedMultifractal(seed);
                    fastPlanetMountainsBase.Frequency = 4;

                    ScaleBiasOutput fastPlanetMountainsScaled = new ScaleBiasOutput(fastPlanetMountainsBase);
                    fastPlanetMountainsScaled.Scale = 0.4;
                    fastPlanetMountainsScaled.Bias = 0.85;

                    FastTurbulence fastPlanetMountains = new FastTurbulence(fastPlanetMountainsScaled);
                    fastPlanetMountains.Power = 0.1;
                    fastPlanetMountains.Frequency = 50;

                    FastNoise fastPlanetLandFilter = new FastNoise(seed+1);
                    fastPlanetLandFilter.Frequency = 6;

                    Select fastPlanetLand = new Select(fastPlanetLandFilter, fastPlanetLowlandsScaled, fastPlanetMountains);
                    fastPlanetLand.SetBounds(0, 1000);
                    fastPlanetLand.EdgeFalloff = 0.5;

                    FastBillow fastPlanetOceanBase = new FastBillow(seed);
                    fastPlanetOceanBase.Frequency = 15;
                    ScaleOutput fastPlanetOcean = new ScaleOutput(fastPlanetOceanBase, 0.1);

                    Select fastPlanetFinal = new Select(fastPlanetContinents, fastPlanetOcean, fastPlanetLand);
                    fastPlanetFinal.SetBounds(0, 1000);
                    fastPlanetFinal.EdgeFalloff = 0.5;

                    module = fastPlanetFinal;
                    break;
                default:
                    module = new Constant(1.0);
                    break;
            }

            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();

            LibNoise.Models.Sphere sphere = new LibNoise.Models.Sphere(module);

            for (int x = 0; x < pictureBox1.ClientSize.Width - 1; x++)
                for (int y = 0; y < pictureBox1.ClientSize.Height - 1; y++)
                {
                    double value;
                    if(mapToSphere)
                    {
                        int offsetX = -(x-512);
                        int offsetY = -(y-512);
                        double longitude = offsetY/5.6888888888;
                        if(longitude > 90.0) longitude = 90.0;
                        if(longitude < -90.0) longitude = -90.0;
                        double latitude = offsetX/2.844444444;
                        if(latitude > 180.0) latitude = 180.0;
                        if(latitude < -190.0) latitude = -180.0;
                        value = sphere.GetValue(longitude, latitude);
                    }
                    else
                        value = (module.GetValue(x, y, 10) + 1) / 2.0;
                    if (mapToSphere)
                    {
                        if (value < 0) value = 0;
                        if (value > 1.0) value = 1.0;
                        int index = (int)(value * earthLookupTable.Length);
                        if (index >= earthLookupTable.Length) index = earthLookupTable.Length - 1;
                        colors[x, y] = earthLookupTable[index];
                    }
                    else
                    {
                        if (value < 0) value = 0;
                        if (value > 1.0) value = 1.0;
                        byte intensity = (byte)(value * 255.0);
                        colors[x, y] = Color.FromArgb(255, intensity, intensity, intensity);
                    }
                }

            stopWatch.Stop();
            label2.Text = "Generation time for a 1024x1024 image, not including rendering: " + stopWatch.Elapsed.TotalMilliseconds + " ms";

            for (int x = 0; x < pictureBox1.ClientSize.Width - 1; x++)
                for (int y = 0; y < pictureBox1.ClientSize.Height - 1; y++)
                    bitmap.SetPixel(x, y, colors[x, y]);

            pictureBox1.Image = bitmap;

            panel2.Enabled = true;
        }
开发者ID:xdray,项目名称:CubeWorld,代码行数:101,代码来源:Form1.cs

示例3: VisitConstant

        public virtual void VisitConstant(Constant c)
        {
            if (!c.IsValid)
            {
                writer.Write("<invalid>");
                return;
            }
            var pt = c.DataType.ResolveAs<PrimitiveType>();
            if (pt != null)
            {
                if (pt.Domain == Domain.Boolean)
                {
                    writer.Write(Convert.ToBoolean(c.GetValue()) ? "true" : "false");
                }
                else if (pt.Domain == Domain.Real)
                {
                    string sr;

                    if (pt.Size == 4)
                    {
                        sr = c.ToFloat().ToString("g", CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        sr = c.ToReal64().ToString("g", CultureInfo.InvariantCulture);
                    }
                    if (sr.IndexOfAny(nosuffixRequired) < 0)
                    {
                        sr += ".0";
                    }
                    if (pt.Size == 4)
                    {
                        sr += "F";
                    }
                    writer.Write(sr);
                }
                else 
                {
                    object v = c.GetValue();
                    writer.Write(FormatString(pt, v), v);
                }
                return;
            }
            StringConstant s = c as StringConstant;
            if (s != null)
            {
                writer.Write("{0}{1}{0}", '"', s.GetValue());
            }
        }
开发者ID:uxmal,项目名称:reko,代码行数:49,代码来源:CodeFormatter.cs


注:本文中的Constant.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。