public AGSColoredBorder(IGLUtils glUtils, float lineWidth, FourCorners<Color> color, FourCorners<bool> hasRoundCorner) { _glUtils = glUtils; LineWidth = lineWidth; Color = color; HasRoundCorner = hasRoundCorner; _roundCorner = new GLVertex[ROUND_CORNER_SAMPLE_SIZE + 1]; }
private void drawQuad(ISquare quad, ISquare border, FourCorners<IGLColor> colors) { GLColor bottomLeftColor = getColor(colors, border, quad.BottomLeft); GLColor bottomRightColor = getColor(colors, border, quad.BottomRight); GLColor topRightColor = getColor(colors, border, quad.TopRight); GLColor topLeftColor = getColor(colors, border, quad.TopLeft); _glUtils.DrawQuad(0, quad.BottomLeft.ToVector3(), quad.BottomRight.ToVector3(), quad.TopLeft.ToVector3(), quad.TopRight.ToVector3(), bottomLeftColor, bottomRightColor, topLeftColor, topRightColor); }
private GLColor getColor(FourCorners<IGLColor> color, float fractionX, float fractionY) { GLColor colorBottomX = getColor(color.BottomLeft, color.BottomRight, fractionX); GLColor colorTopX = getColor(color.TopLeft, color.TopRight, fractionX); return getColor(colorBottomX, colorTopX, fractionY); }
private GLColor getColor(FourCorners<IGLColor> colors, ISquare border, PointF point) { return getColor(colors, MathUtils.Lerp(border.BottomLeft.X, 0f, border.BottomRight.X, 1f, point.X), MathUtils.Lerp(border.BottomRight.Y, 0f, border.TopRight.Y, 1f, point.Y)); }
private void drawRoundCorner(PointF center, float radius, float angle, ISquare border, FourCorners<IGLColor> colors) { Vector2 tex = new Vector2 (); GLVertex centerVertex = new GLVertex (center.ToVector2(), tex, getColor(colors, border, center)); _roundCorner[0] = centerVertex; float step = (90f / (_roundCorner.Length - 2)); for (int i = 1; i < _roundCorner.Length; i++) { float anglerad = (float)Math.PI * angle / 180.0f; float x = (float)Math.Sin(anglerad) * radius; float y = (float)Math.Cos(anglerad) * radius; angle += step; PointF point = new PointF (x + center.X, y + center.Y); _roundCorner[i] = new GLVertex (point.ToVector2(), tex, getColor(colors, border, point)); } _glUtils.DrawTriangleFan(0, _roundCorner); }
public void DrawQuad(int texture, Vector3 bottomLeft, Vector3 bottomRight, Vector3 topLeft, Vector3 topRight, IGLColor color, FourCorners<Vector2> texturePos) { texture = getTexture(texture); _graphics.BindTexture2D (texture); GLVertex[] vertices = new GLVertex[]{ new GLVertex(bottomLeft.Xy, texturePos.BottomLeft, color), new GLVertex(bottomRight.Xy, texturePos.BottomRight, color), new GLVertex(topRight.Xy, texturePos.TopRight, color), new GLVertex(topLeft.Xy, texturePos.TopLeft, color)}; drawVertices(vertices); }
/// <summary> /// Initializes a new instance of the <see cref="T:AGS.API.AGSCropInfo"/> struct. /// </summary> /// <param name="boundingBox">Bounding box.</param> /// <param name="textureBox">Texture box.</param> /// <param name="cropFrom">The direction the item was cropped from, if fully cropped.</param> public AGSCropInfo(AGSBoundingBox boundingBox, FourCorners <Vector2> textureBox, CropFrom cropFrom) { TextureBox = textureBox; BoundingBox = boundingBox; CropFrom = cropFrom; }
/// <summary> /// Initializes a new instance of the <see cref="T:AGS.API.AGSCropInfo"/> struct. /// </summary> /// <param name="boundingBox">Bounding box.</param> /// <param name="textureBox">Texture box.</param> public AGSCropInfo(AGSBoundingBox boundingBox, FourCorners <Vector2> textureBox) { TextureBox = textureBox; BoundingBox = boundingBox; }
public static AGSColoredBorder Gradient(IGLUtils glUtils, FourCorners<Color> color, float lineWidth = 10f, bool hasRoundCorners = false) { return new AGSColoredBorder (glUtils, lineWidth, color, new FourCorners<bool> (hasRoundCorners)); }
private void drawQuad(ISquare quad, FourCorners<Vector2> texturePos) { _glUtils.DrawQuad(_texture, quad.BottomLeft.ToVector3(), quad.BottomRight.ToVector3(), quad.TopLeft.ToVector3(), quad.TopRight.ToVector3(), _white, texturePos); }