本文整理汇总了C#中float2类的典型用法代码示例。如果您正苦于以下问题:C# float2类的具体用法?C# float2怎么用?C# float2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
float2类属于命名空间,在下文中一共展示了float2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw()
{
var disabled = IsDisabled();
var font = Game.Renderer.Fonts[Font];
var rect = RenderBounds;
var check = new Rectangle(rect.Location, new Size(Bounds.Height, Bounds.Height));
var state = disabled ? "checkbox-disabled" :
Depressed && HasPressedState ? "checkbox-pressed" :
Widget.MouseOverWidget == this ? "checkbox-hover" :
"checkbox";
WidgetUtils.DrawPanel(state, check);
var textSize = font.Measure(Text);
font.DrawText(Text,
new float2(rect.Left + rect.Height * 1.5f, RenderOrigin.Y - BaseLine + (Bounds.Height - textSize.Y)/2), Color.White);
if (IsChecked() || (Depressed && HasPressedState && !disabled))
{
var checkType = GetCheckType();
if (HasPressedState && (Depressed || disabled))
checkType += "-disabled";
var offset = new float2(rect.Left + CheckOffset, rect.Top + CheckOffset);
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("checkbox-bits", checkType), offset);
}
}
示例2: VoxelRenderProxy
public VoxelRenderProxy(Sprite sprite, Sprite shadowSprite, float2[] projectedShadowBounds, float shadowDirection)
{
Sprite = sprite;
ShadowSprite = shadowSprite;
ProjectedShadowBounds = projectedShadowBounds;
ShadowDirection = shadowDirection;
}
示例3: Draw
public override void Draw()
{
var sprite = GetSprite();
var palette = GetPalette();
var scale = GetScale();
if (sprite == null || palette == null)
return;
if (sprite != cachedSprite)
{
offset = 0.5f * (new float2(RenderBounds.Size) - sprite.Size);
cachedSprite = sprite;
}
if (palette != cachedPalette)
{
pr = WorldRenderer.Palette(palette);
cachedPalette = palette;
}
if (scale != cachedScale)
{
offset *= scale;
cachedScale = scale;
}
var size = new float2(sprite.Size.X * scale, sprite.Size.Y * scale);
Game.Renderer.SpriteRenderer.DrawSprite(sprite, RenderOrigin + offset, pr, size);
}
示例4: Float2Lerp
/// <summary>
/// Lerp Function for Float2.
/// </summary>
public static float2 Float2Lerp(float2 val1, float2 val2, float time1, float time2)
{
float2 values = new float2();
values.x = val1.x + ((val2.x - val1.x)/time1)*time2;
values.y = val1.y + ((val2.y - val1.y) / time1) * time2;
return values;
}
示例5: DrawText
public void DrawText(SpriteRenderer r, string text, float2 location, Color c)
{
location.Y += size; // baseline vs top
var p = location;
foreach (var s in text)
{
if (s == '\n')
{
location.Y += size;
p = location;
continue;
}
var g = glyphs[s];
r.DrawSprite(g.Sprite,
new float2(
(int)Math.Round(p.X + g.Offset.X, 0),
p.Y + g.Offset.Y),
"chrome");
p.X += g.Advance;
}
r.Flush();
}
示例6: Initialize
public override void Initialize(WidgetArgs args)
{
paletteOpenOrigin = new float2(Game.Renderer.Resolution.Width - Columns*IconWidth - 23, 280);
paletteClosedOrigin = new float2(Game.Renderer.Resolution.Width - 16, 280);
paletteOrigin = paletteClosedOrigin;
base.Initialize(args);
}
示例7: DrawSelectionBar
void DrawSelectionBar(WorldRenderer wr, float2 xy, float2 Xy, float value, Color barColor)
{
if (!self.IsInWorld)
return;
var health = self.TraitOrDefault<Health>();
if (health == null || health.IsDead) return;
var c = Color.FromArgb(128, 30, 30, 30);
var c2 = Color.FromArgb(128, 10, 10, 10);
var p = new float2(0, -4 / wr.Viewport.Zoom);
var q = new float2(0, -3 / wr.Viewport.Zoom);
var r = new float2(0, -2 / wr.Viewport.Zoom);
var barColor2 = Color.FromArgb(255, barColor.R / 2, barColor.G / 2, barColor.B / 2);
var z = float2.Lerp(xy, Xy, value);
var wlr = Game.Renderer.WorldLineRenderer;
wlr.DrawLine(xy + p, Xy + p, c, c);
wlr.DrawLine(xy + q, Xy + q, c2, c2);
wlr.DrawLine(xy + r, Xy + r, c, c);
wlr.DrawLine(xy + p, z + p, barColor2, barColor2);
wlr.DrawLine(xy + q, z + q, barColor, barColor);
wlr.DrawLine(xy + r, z + r, barColor2, barColor2);
}
示例8: DrawLine
public void DrawLine(float2 start, float2 end, float width, Color startColor, Color endColor)
{
renderer.CurrentBatchRenderer = this;
if (nv + 6 > renderer.TempBufferSize)
Flush();
var delta = (end - start) / (end - start).Length;
var corner = width / 2 * new float2(-delta.Y, delta.X);
startColor = Util.PremultiplyAlpha(startColor);
var sr = startColor.R / 255.0f;
var sg = startColor.G / 255.0f;
var sb = startColor.B / 255.0f;
var sa = startColor.A / 255.0f;
endColor = Util.PremultiplyAlpha(endColor);
var er = endColor.R / 255.0f;
var eg = endColor.G / 255.0f;
var eb = endColor.B / 255.0f;
var ea = endColor.A / 255.0f;
vertices[nv++] = new Vertex(start - corner + Offset, sr, sg, sb, sa);
vertices[nv++] = new Vertex(start + corner + Offset, sr, sg, sb, sa);
vertices[nv++] = new Vertex(end + corner + Offset, er, eg, eb, ea);
vertices[nv++] = new Vertex(end + corner + Offset, er, eg, eb, ea);
vertices[nv++] = new Vertex(end - corner + Offset, er, eg, eb, ea);
vertices[nv++] = new Vertex(start - corner + Offset, sr, sg, sb, sa);
}
示例9: Init
public override void Init(Manifest m, Dictionary<string, string> info)
{
loadInfo = info;
// Avoid standard loading mechanisms so we
// can display loadscreen as early as possible
r = Game.Renderer;
if (r == null) return;
sheet = new Sheet(SheetType.BGRA, Platform.ResolvePath(loadInfo["Image"]));
var res = r.Resolution;
bounds = new Rectangle(0, 0, res.Width, res.Height);
borderTop = new Sprite(sheet, new Rectangle(161, 128, 62, 33), TextureChannel.Alpha);
borderBottom = new Sprite(sheet, new Rectangle(161, 223, 62, 33), TextureChannel.Alpha);
borderLeft = new Sprite(sheet, new Rectangle(128, 161, 33, 62), TextureChannel.Alpha);
borderRight = new Sprite(sheet, new Rectangle(223, 161, 33, 62), TextureChannel.Alpha);
cornerTopLeft = new Sprite(sheet, new Rectangle(128, 128, 33, 33), TextureChannel.Alpha);
cornerTopRight = new Sprite(sheet, new Rectangle(223, 128, 33, 33), TextureChannel.Alpha);
cornerBottomLeft = new Sprite(sheet, new Rectangle(128, 223, 33, 33), TextureChannel.Alpha);
cornerBottomRight = new Sprite(sheet, new Rectangle(223, 223, 33, 33), TextureChannel.Alpha);
nodLogo = new Sprite(sheet, new Rectangle(0, 256, 256, 256), TextureChannel.Alpha);
gdiLogo = new Sprite(sheet, new Rectangle(256, 256, 256, 256), TextureChannel.Alpha);
evaLogo = new Sprite(sheet, new Rectangle(256, 64, 128, 64), TextureChannel.Alpha);
nodPos = new float2(bounds.Width / 2 - 384, bounds.Height / 2 - 128);
gdiPos = new float2(bounds.Width / 2 + 128, bounds.Height / 2 - 128);
evaPos = new float2(bounds.Width - 43 - 128, 43);
brightBlock = new Sprite(sheet, new Rectangle(320, 0, 16, 35), TextureChannel.Alpha);
dimBlock = new Sprite(sheet, new Rectangle(336, 0, 16, 35), TextureChannel.Alpha);
versionText = m.Mod.Version;
}
示例10: Draw
public override void Draw()
{
float powerScaleBy = 100;
var maxPower = Math.Max(pm.PowerProvided, pm.PowerDrained);
while (maxPower >= powerScaleBy) powerScaleBy *= 2;
// Current power supply
var providedFrac = pm.PowerProvided / powerScaleBy;
lastProvidedFrac = providedFrac = float2.Lerp(lastProvidedFrac.GetValueOrDefault(providedFrac), providedFrac, .3f);
var color = Color.LimeGreen;
if (pm.PowerState == PowerState.Low)
color = Color.Orange;
if (pm.PowerState == PowerState.Critical)
color = Color.Red;
var b = RenderBounds;
var rect = new RectangleF(b.X,
b.Y + (1-providedFrac)*b.Height,
(float)b.Width,
providedFrac*b.Height);
Game.Renderer.LineRenderer.FillRect(rect, color);
var indicator = ChromeProvider.GetImage("sidebar-bits", "left-indicator");
var drainedFrac = pm.PowerDrained / powerScaleBy;
lastDrainedFrac = drainedFrac = float2.Lerp(lastDrainedFrac.GetValueOrDefault(drainedFrac), drainedFrac, .3f);
float2 pos = new float2(b.X + b.Width - indicator.size.X,
b.Y + (1-drainedFrac)*b.Height - indicator.size.Y / 2);
Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, pos);
}
示例11: BrickShader
public BrickShader(GraphicsInterface gi)
: base(gi)
{
//Console.WriteLine("BrickShader Link Log: \n{0}", InfoLog);
GLSLVertexShader vShader = new GLSLVertexShader(gi, Brick_VertexSource);
AttachShader(vShader);
GLSLFragmentShader fShader = new GLSLFragmentShader(gi, Brick_FragmentSource);
AttachShader(fShader);
Link();
// Do an initial selection so that all the variables can be located
Bind();
BrickColor_Pos = GetUniformLocation("BrickColor");
MortarColor_Pos = GetUniformLocation("MortarColor");
BrickSize_Pos = GetUniformLocation("BrickSize");
BrickPct_Pos = GetUniformLocation("BrickPct");
// From the Vertex Shader
LightPosition_Pos = GetUniformLocation("LightPosition");
// Set some initial values
BrickColor = new ColorRGBA(1.0f, 0.3f, 0.2f);
MortarColor = new ColorRGBA(0.85f, 0.86f, 0.84f);
BrickSize = new float2(0.30f, 0.15f);
BrickPct = new float2(0.90f, 0.85f);
LightPosition = new Vector3f(0.0f, 0.0f, 4.0f);
// Unselect so we start in an unselected state
Unbind();
}
示例12: DrawTargetMarker
void DrawTargetMarker(LineRenderer wlr, float2 p)
{
wlr.DrawLine(p + new float2(-1, -1), p + new float2(-1, 1), c, c);
wlr.DrawLine(p + new float2(-1, 1), p + new float2(1, 1), c, c);
wlr.DrawLine(p + new float2(1, 1), p + new float2(1, -1), c, c);
wlr.DrawLine(p + new float2(1, -1), p + new float2(-1, -1), c, c);
}
示例13: MoveFlash
public MoveFlash( World world, float2 pos )
{
this.pos = pos;
anim.PlayThen( "idle",
() => world.AddFrameEndTask(
w => w.Remove( this ) ) );
}
示例14: Draw
public override void Draw()
{
float scaleBy = 100;
var max = Math.Max(pr.OreCapacity, pr.Ore);
while (max >= scaleBy) scaleBy *= 2;
// Current capacity
var capacityFrac = pr.OreCapacity / scaleBy;
lastCapacityFrac = capacityFrac = float2.Lerp(lastCapacityFrac.GetValueOrDefault(capacityFrac), capacityFrac, .3f);
var color = GetBarColor();
var b = RenderBounds;
var rect = new RectangleF(b.X, float2.Lerp( b.Bottom, b.Top, capacityFrac ),
(float)b.Width, capacityFrac*b.Height);
Game.Renderer.LineRenderer.FillRect(rect, color);
var indicator = ChromeProvider.GetImage("sidebar-bits", "right-indicator");
var storedFrac = pr.Ore / scaleBy;
lastStoredFrac = storedFrac = float2.Lerp(lastStoredFrac.GetValueOrDefault(storedFrac), storedFrac, .3f);
float2 pos = new float2(b.X, float2.Lerp( b.Bottom, b.Top, storedFrac ) - indicator.size.Y / 2);
Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, pos);
}
示例15: DrawInner
public override void DrawInner(World world)
{
var rect = RenderBounds;
float2 origin = Game.viewport.Location + new float2(rect.Right, rect.Bottom);
float2 basis = new float2(-rect.Width / 100, -rect.Height / 100);
Game.Renderer.LineRenderer.DrawLine(origin, origin + new float2(100, 0) * basis, Color.White, Color.White);
Game.Renderer.LineRenderer.DrawLine(origin + new float2(100, 0) * basis, origin + new float2(100, 100) * basis, Color.White, Color.White);
foreach (var item in PerfHistory.items.Values)
{
int n = 0;
item.Samples().Aggregate((a, b) =>
{
Game.Renderer.LineRenderer.DrawLine(
origin + new float2(n, (float)a) * basis,
origin + new float2(n + 1, (float)b) * basis,
item.c, item.c);
++n;
return b;
});
}
Game.Renderer.LineRenderer.Flush();
}