• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# float2类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中float2的典型用法代码示例。如果您正苦于以下问题:C# float2类的具体用法?C# float2怎么用?C# float2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



float2类属于命名空间,在下文中一共展示了float2类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
            }
        }
开发者ID:alzeih,项目名称:OpenRA,代码行数:27,代码来源:CheckboxWidget.cs


示例2: VoxelRenderProxy

		public VoxelRenderProxy(Sprite sprite, Sprite shadowSprite, float2[] projectedShadowBounds, float shadowDirection)
		{
			Sprite = sprite;
			ShadowSprite = shadowSprite;
			ProjectedShadowBounds = projectedShadowBounds;
			ShadowDirection = shadowDirection;
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:7,代码来源:VoxelRenderer.cs


示例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);
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:30,代码来源:SpriteWidget.cs


示例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;
 }
开发者ID:GameProduction,项目名称:ScharfschiessenGame,代码行数:10,代码来源:Lerp.cs


示例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();
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:25,代码来源:SpriteFont.cs


示例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);
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:7,代码来源:BuildPaletteWidget.cs


示例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);
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:26,代码来源:Selectable.cs


示例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);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:29,代码来源:RgbaColorRenderer.cs


示例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;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:34,代码来源:CncLoadScreen.cs


示例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);
        }
开发者ID:jeff-1amstudios,项目名称:OpenRA,代码行数:33,代码来源:PowerBarWidget.cs


示例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();
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:34,代码来源:BrickShader.cs


示例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);
 }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:7,代码来源:DrawLineToTarget.cs


示例13: MoveFlash

 public MoveFlash( World world, float2 pos )
 {
     this.pos = pos;
     anim.PlayThen( "idle",
         () => world.AddFrameEndTask(
             w => w.Remove( this ) ) );
 }
开发者ID:pdovy,项目名称:OpenRA,代码行数:7,代码来源:MoveFlash.cs


示例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);
        }
开发者ID:alzeih,项目名称:OpenRA,代码行数:26,代码来源:SiloBarWidget.cs


示例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();
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:25,代码来源:PerfGraphWidget.cs


示例16: Draw

        public override void Draw()
        {
            if (world == null) return;

            var o = new float2(mapRect.Location.X, mapRect.Location.Y + world.Map.Bounds.Height * previewScale * (1 - radarMinimapHeight)/2);
            var s = new float2(mapRect.Size.Width, mapRect.Size.Height*radarMinimapHeight);
            var rsr = Game.Renderer.RgbaSpriteRenderer;
            rsr.DrawSprite(terrainSprite, o, s);
            rsr.DrawSprite(customTerrainSprite, o, s);
            rsr.DrawSprite(actorSprite, o, s);
            rsr.DrawSprite(shroudSprite, o, s);

            // Draw viewport rect
            if (hasRadar && !animating)
            {
                var wr = Game.viewport.WorldRect;
                var wro = new CPos(wr.X, wr.Y);
                var tl = CellToMinimapPixel(wro);
                var br = CellToMinimapPixel(wro + new CVec(wr.Width, wr.Height));

                Game.Renderer.EnableScissor((int)mapRect.Left, (int)mapRect.Top, (int)mapRect.Width, (int)mapRect.Height);
                Game.Renderer.LineRenderer.DrawRect(tl, br, Color.White);
                Game.Renderer.DisableScissor();
            }
        }
开发者ID:nevelis,项目名称:OpenRA,代码行数:25,代码来源:RadarWidget.cs


示例17: FastCreateQuad

 public static void FastCreateQuad(Vertex[] vertices, float2 o, Sprite r, int palette, int nv, float2 size)
 {
     var b = new float2(o.X + size.X, o.Y);
     var c = new float2(o.X + size.X, o.Y + size.Y);
     var d = new float2(o.X, o.Y + size.Y);
     FastCreateQuad(vertices, o, b, c, d, r, palette, nv);
 }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:7,代码来源:Util.cs


示例18: Draw

        public override void Draw()
        {
            if (world == null)
                return;

            var o = new float2(mapRect.Location.X, mapRect.Location.Y + world.Map.Bounds.Height * previewScale * (1 - radarMinimapHeight)/2);
            var s = new float2(mapRect.Size.Width, mapRect.Size.Height*radarMinimapHeight);

            var rsr = Game.Renderer.RgbaSpriteRenderer;
            rsr.DrawSprite(terrainSprite, o, s);
            rsr.DrawSprite(customTerrainSprite, o, s);
            rsr.DrawSprite(actorSprite, o, s);
            rsr.DrawSprite(shroudSprite, o, s);

            // Draw viewport rect
            if (hasRadar)
            {
                var tl = CellToMinimapPixel(worldRenderer.Position(worldRenderer.Viewport.TopLeft).ToCPos());
                var br = CellToMinimapPixel(worldRenderer.Position(worldRenderer.Viewport.BottomRight).ToCPos());

                Game.Renderer.EnableScissor(mapRect);
                Game.Renderer.LineRenderer.DrawRect(tl, br, Color.White);
                Game.Renderer.DisableScissor();
            }
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:25,代码来源:RadarWidget.cs


示例19: Add

 public Sprite Add(byte[] src, Size size, float2 spriteOffset)
 {
     var rect = Allocate(size, spriteOffset);
     Util.FastCopyIntoChannel(rect, src);
     current.CommitData();
     return rect;
 }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:7,代码来源:SheetBuilder.cs


示例20: DrawInner

        public override void DrawInner(World world)
        {
            radarCollection = "radar-" + world.LocalPlayer.Country.Race;

            Game.Renderer.RgbaSpriteRenderer.DrawSprite(ChromeProvider.GetImage(radarCollection, "left"), radarOrigin);
            Game.Renderer.RgbaSpriteRenderer.DrawSprite(ChromeProvider.GetImage(radarCollection, "right"), radarOrigin + new float2(201, 0));
            Game.Renderer.RgbaSpriteRenderer.DrawSprite(ChromeProvider.GetImage(radarCollection, "bottom"), radarOrigin + new float2(0, 192));
            Game.Renderer.RgbaSpriteRenderer.DrawSprite(ChromeProvider.GetImage(radarCollection, "bg"), radarOrigin + new float2(9, 0));

            // Don't draw the radar if the tray is moving
            if (radarAnimationFrame >= radarSlideAnimationLength)
            {
                var o = new float2(mapRect.Location.X, mapRect.Location.Y + world.Map.Height * previewScale * (1 - radarMinimapHeight)/2);
                var s = new float2(mapRect.Size.Width, mapRect.Size.Height*radarMinimapHeight);
                Game.Renderer.RgbaSpriteRenderer.DrawSprite(terrainSprite, o, s);
                Game.Renderer.RgbaSpriteRenderer.DrawSprite(customTerrainSprite, o, s);
                Game.Renderer.RgbaSpriteRenderer.DrawSprite(actorSprite, o, s);
                Game.Renderer.RgbaSpriteRenderer.DrawSprite(shroudSprite, o, s);

                // Draw viewport rect
                if (radarAnimationFrame == radarSlideAnimationLength + radarActivateAnimationLength)
                {
                    var tl = CellToMinimapPixel(new int2((int)(Game.viewport.Location.X/Game.CellSize), (int)(Game.viewport.Location.Y/Game.CellSize)));
                    var br = CellToMinimapPixel(new int2((int)((Game.viewport.Location.X + Game.viewport.Width)/Game.CellSize), (int)((Game.viewport.Location.Y + Game.viewport.Height)/Game.CellSize)));
                    var tr = new int2(br.X, tl.Y);
                    var bl = new int2(tl.X, br.Y);
                    Game.Renderer.EnableScissor((int)mapRect.Left, (int)mapRect.Top, (int)mapRect.Width, (int)mapRect.Height);
                    Game.Renderer.LineRenderer.DrawLine(Game.viewport.Location + tl, Game.viewport.Location + tr, Color.White, Color.White);
                    Game.Renderer.LineRenderer.DrawLine(Game.viewport.Location + tr, Game.viewport.Location + br, Color.White, Color.White);
                    Game.Renderer.LineRenderer.DrawLine(Game.viewport.Location + br, Game.viewport.Location + bl, Color.White, Color.White);
                    Game.Renderer.LineRenderer.DrawLine(Game.viewport.Location + bl, Game.viewport.Location + tl, Color.White, Color.White);
                    Game.Renderer.DisableScissor();
                }
            }
        }
开发者ID:subspace,项目名称:OpenRA,代码行数:35,代码来源:RadarBinWidget.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# float3类代码示例发布时间:2022-05-24
下一篇:
C# fftw_flags类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap