本文整理汇总了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());
}
}
示例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;
}
示例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());
}
}