public void SetValues(F2 p2, float deltaT) { startFromBegining = true; this.p2.Copy(p2); this.deltaT = deltaT; }
public void SetValues(F2 p1, F2 p2, float deltaT) { startFromBegining = false; this.p1.Copy(p1); this.p2.Copy(p2); this.deltaT = deltaT; }
public Viewport(F2 viewportPositionOnScreen, F2 viewportSizeOnScreen) { this.viewportPositionOnScreen.Copy(viewportPositionOnScreen); this.viewportSizeOnScreen.Copy(viewportSizeOnScreen); viewportYXRatio = viewportSizeOnScreen.y / viewportSizeOnScreen.x; viewportToScreenRatio.x = viewportSizeOnScreen.x; viewportToScreenRatio.y = viewportSizeOnScreen.y / viewportYXRatio; }
private void CalculatePerp() { F2 diff = p2 - p1; if (curvature != 0) { perp.y = diff.x * curvature; perp.x = -diff.y * curvature; } }
public override void Draw(int dt, float depth) { float screenBarHeight = 0; //PositionManager.Get().UiXToScreenXRatio(barHeight, ref screenBarHeight); App.Get().defaultUIViewport.ViewportXToScreenXRatio(barHeight, out screenBarHeight); float screenBarWidth = 0; //PositionManager.Get().UiXToScreenXRatio(Size.x, ref screenBarWidth); App.Get().defaultUIViewport.ViewportXToScreenXRatio(barHeight, out screenBarHeight); F2 absolutePos = new F2(GetAbsoluteX(), GetAbsoluteY()); //PositionManager.Get().UiToScreen(absolutePos, screenPos); App.Get().defaultUIViewport.ViewportToScreen(absolutePos, ref screenPos); cursorPos.y = absolutePos.y; cursorPos.x = absolutePos.x + (Value - 0.5f) * Size.x; //PositionManager.Get().UiToScreen(cursorPos, cursorPos); App.Get().defaultUIViewport.ViewportToScreen(cursorPos, ref cursorPos); float screenCursorSide = 0; //PositionManager.Get().UiXToScreenXRatio(cursorSide, ref screenCursorSide); App.Get().defaultUIViewport.ViewportXToScreenXRatio(cursorSide, out screenCursorSide); int opacity = (int)(255 * GetAbsoluteOpacity()); float absoluteDepth = GetAbsoluteDepth(); App.Get().spriteBatchGui.Draw(texBar, screenPos.ToVector2(), null, Color.FromNonPremultiplied(Color.R, Color.G, Color.B, opacity), 0, new Vector2(texBar.Width / 2, texBar.Height / 2), new Vector2(screenBarWidth / texBar.Width, screenBarHeight / texBar.Height), SpriteEffects.None, absoluteDepth); App.Get().spriteBatchGui.Draw(texCursor, cursorPos.ToVector2(), null, Color.FromNonPremultiplied(CursorColor.R, CursorColor.G, CursorColor.B, opacity), 0, new Vector2(texCursor.Width / 2, texCursor.Width / 2), new Vector2(screenCursorSide / texCursor.Width, screenCursorSide / texCursor.Height), SpriteEffects.None, absoluteDepth + 0.01f); }
public override void Draw(int dt, float depth) { if (!Visible) { return; } F2 screenPosVetor = new F2(); //PositionManager.Get().UiToScreen(new F2(GetAbsoluteX(), GetAbsoluteY()),screenPosVetor); App.Get().defaultUIViewport.ViewportToScreen(new F2(GetAbsoluteX(), GetAbsoluteY()), ref screenPosVetor); Vector2 screenPos = screenPosVetor.ToVector2(); float opacityFloat = GetAbsoluteOpacity(); byte opacity = (byte)(255 * opacityFloat); Color color = Color.FromNonPremultiplied(Color.R, Color.G, Color.B, opacity); App.Get().spriteBatchGui.DrawString(font, Text, screenPos, color, 0, origin, 1, SpriteEffects.None, depth + 0.002f); if (Border) { color.R = borderColor.R; color.G = borderColor.G; color.B = borderColor.B; color.A = (byte)(255 * opacityFloat * opacityFloat * opacityFloat); screenPos.X -= 1; screenPos.Y -= 1; App.Get().spriteBatchGui.DrawString(font, Text, screenPos, color, 0, origin, 1, SpriteEffects.None, depth + 0.001f); screenPos.X += 2; App.Get().spriteBatchGui.DrawString(font, Text, screenPos, color, 0, origin, 1, SpriteEffects.None, depth + 0.001f); screenPos.Y += 2; App.Get().spriteBatchGui.DrawString(font, Text, screenPos, color, 0, origin, 1, SpriteEffects.None, depth + 0.001f); screenPos.X -= 2; App.Get().spriteBatchGui.DrawString(font, Text, screenPos, color, 0, origin, 1, SpriteEffects.None, depth + 0.001f); screenPos.X += 1; screenPos.Y += 1; App.Get().spriteBatchGui.DrawString(font, Text, screenPos, color, 0, origin, 1, SpriteEffects.None, depth + 0.001f); } }
public override void Draw(int dt, float depth) { if (!Visible || texBackground == null) { return; } F2 screenPosVetor = new F2(); //PositionManager.Get().UiToScreen(new F2(GetAbsoluteX(), GetAbsoluteY()), screenPosVetor); App.Get().defaultUIViewport.ViewportToScreen(new F2(GetAbsoluteX(), GetAbsoluteY()), ref screenPosVetor); F2 screenSizeVetor = new F2(); //PositionManager.Get().UiToScreenRatio(Size, screenSizeVetor); App.Get().defaultUIViewport.ViewportToScreenRatio(Size, ref screenSizeVetor); screenSizeVetor.x /= texBackground.Width; screenSizeVetor.y /= texBackground.Height; App.Get().spriteBatchGui.Draw(texBackground, screenPosVetor.ToVector2(), null, Color.FromNonPremultiplied(Color.R, Color.G, Color.B, (int)(255 * GetAbsoluteOpacity())), Rotation.Value, new Vector2(texBackground.Width / 2, texBackground.Height / 2), screenSizeVetor.ToVector2(), SpriteEffects.None, depth); }
protected virtual void InitScreenSize(float screenWidth, float screenHeight) { screenSize = new F2(screenWidth, screenHeight); screenYXRatio = screenHeight / screenWidth; }
public F2(F2 toCopy) { this.x = toCopy.x; this.y = toCopy.y; }
public void Copy(F2 copiedVetor) { this.x = copiedVetor.x; this.y = copiedVetor.y; }
public AffectorF2(F2 obj, float x1, float y1, float x2, float y2, float deltaT) { this.obj = obj; SetValues(x1, y1, x2, y2, deltaT); }
public void setDelta(F2 p1, F2 p2) { Delta.x = p2.x - p1.y; Delta.y = p2.y - p1.y; }
public AffectorF2(F2 obj) { this.obj = obj; }
public AffectorF2(F2 obj, F2 p2, float deltaT) { this.obj = obj; SetValues(p2, deltaT); }
public void ViewportToScreen(F2 input, ref F2 output) { output.x = input.x * viewportToScreenRatio.x + viewportPositionOnScreen.x; output.y = input.y * viewportToScreenRatio.y + viewportPositionOnScreen.y; }
public void ScreenToViewport(F2 input, ref F2 output) { output.x = (input.x - viewportPositionOnScreen.x) / viewportToScreenRatio.x; output.y = (input.y - viewportPositionOnScreen.y) / viewportToScreenRatio.y; }
public void ViewportToScreenRatio(F2 input, ref F2 output) { output.x = input.x * viewportToScreenRatio.x; output.y = input.y * viewportToScreenRatio.y; }
public void ConvertPosition(Viewport other, F2 positionThis, ref F2 positionOther) { ViewportToScreen(positionThis, ref tmpF2); other.ScreenToViewport(tmpF2, ref positionOther); }
public bool IsInsideViewport(F2 input) { return(input.x >= 0 && input.x <= 1 && input.y >= 0 && input.y <= viewportYXRatio); }