public AGSSlicedImageBorder(SliceValues slice, SliceValues width, SliceValues outset, BorderRepeat repeat, [MethodParam(Browsable = false, DefaultProvider = nameof(GetDefaultGLUtils))] IGLUtils glUtils) : this(glUtils) { Slice = slice; Width = width; Outset = outset; Repeat = repeat; }
/// <summary> /// Determines if the given value represents a valid state of this property. /// </summary> /// <param name="value">The state that should be used.</param> /// <returns>True if the state is valid, otherwise false.</returns> protected override Boolean IsValid(CSSValue value) { var mode = value.ToBorderRepeat(); if (mode != null) { _horizontal = _vertical = mode.Value; } else if (value is CSSValueList) { var list = (CSSValueList)value; BorderRepeat?horizontal = null; BorderRepeat?vertical = null; if (list.Length > 2) { return(false); } foreach (var entry in list) { mode = entry.ToBorderRepeat(); if (mode == null) { return(false); } else if (horizontal == null) { horizontal = mode; } else { vertical = mode; } } _horizontal = horizontal.Value; _vertical = vertical.Value; } else { return(false); } return(true); }
internal override void Reset() { _horizontal = Default; _vertical = Default; }
void SetRepeat(BorderRepeat horizontal, BorderRepeat vertical) { _horizontal = horizontal; _vertical = vertical; }
internal override void Reset() { _horizontal = BorderRepeat.Stretch; _vertical = BorderRepeat.Stretch; }
private void drawEdges(SliceValues border, SliceValues slice, SliceValues width, BorderRepeat repeat) { float leftX = border.Left.Value + width.Left.Value; float rightX = border.Right.Value - width.Right.Value; float rowWidth = rightX - leftX; float textureWorldWidth = ((1f - slice.Left.Value - slice.Right.Value) * _width); int stepsX = (int)(rowWidth / textureWorldWidth); float remainderX = rowWidth - textureWorldWidth * stepsX; float textureWidth = 1f - slice.Left.Value - slice.Right.Value; if (textureWidth < 0f) { textureWidth = 1f; } float topY = border.Top.Value - width.Top.Value; float farBottomY = border.Bottom.Value; float stepX = textureWorldWidth; float widthX = textureWorldWidth; float startX = leftX; if (remainderX > 0.001f) { switch (repeat) { case BorderRepeat.Round: stepX = rowWidth / stepsX; widthX = stepX; break; case BorderRepeat.Space: stepX = rowWidth / stepsX; startX = startX + (stepX - widthX) / 2f; break; } } drawHorizQuadRows(stepsX, startX, widthX, topY, farBottomY, width.Top.Value, width.Bottom.Value, textureWidth, slice.Top.Value, slice.Bottom.Value, slice.Left.Value, 1f - slice.Top.Value, 0f, stepX); float bottomY = border.Bottom.Value + width.Bottom.Value; float rowHeight = topY - bottomY; float textureWorldHeight = ((1f - slice.Top.Value - slice.Bottom.Value) * _height); int stepsY = (int)(rowHeight / textureWorldHeight); float textureHeight = 1f - slice.Top.Value - slice.Bottom.Value; if (textureHeight < 0f) { textureHeight = 1f; } float remainderY = rowHeight - textureWorldHeight * stepsY; float stepY = textureWorldHeight; float heightY = textureWorldHeight; float startY = bottomY; if (remainderY > 0.001f) { switch (repeat) { case BorderRepeat.Round: stepY = rowHeight / stepsY; heightY = stepY; break; case BorderRepeat.Space: stepY = rowHeight / stepsY; startY = startY + (stepY - heightY) / 2f; break; } } drawVertQuadRows(stepsY, border.Left.Value, rightX, width.Left.Value, width.Right.Value, startY, heightY, slice.Left.Value, slice.Right.Value, textureHeight, 0f, 1f - slice.Right.Value, slice.Bottom.Value, stepY); if (repeat == BorderRepeat.Repeat) { if (remainderX > 0.0001f) { textureWidth = (remainderX / textureWorldWidth) * textureWidth; leftX = leftX + textureWorldWidth * stepsX; drawHorizQuadRows(1, leftX, remainderX, topY, farBottomY, width.Top.Value, width.Bottom.Value, textureWidth, slice.Top.Value, slice.Bottom.Value, slice.Left.Value, 1f - slice.Top.Value, 0f, remainderX); } if (remainderY > 0.001f) { textureHeight = (remainderY / textureWorldHeight) * textureHeight; bottomY = bottomY + textureWorldHeight * stepsY; drawVertQuadRows(1, border.Left.Value, rightX, width.Left.Value, width.Right.Value, bottomY, remainderY, slice.Left.Value, slice.Right.Value, textureHeight, 0f, 1f - slice.Right.Value, slice.Bottom.Value, remainderY); } } }
private void drawEdges(SliceValues border, SliceValues slice, SliceValues width, BorderRepeat repeat) { float leftX = border.Left.Value + width.Left.Value; float rightX = border.Right.Value - width.Right.Value; float rowWidth = rightX - leftX; float textureWorldWidth = ((1f - slice.Left.Value - slice.Right.Value) * _width); int stepsX = (int)(rowWidth / textureWorldWidth); float remainderX = rowWidth - textureWorldWidth * ((float)stepsX); float textureWidth = 1f - slice.Left.Value - slice.Right.Value; if (textureWidth < 0f) textureWidth = 1f; float topY = border.Top.Value - width.Top.Value; float farBottomY = border.Bottom.Value; float stepX = textureWorldWidth; float widthX = textureWorldWidth; float startX = leftX; if (remainderX > 0.001f) { switch (repeat) { case BorderRepeat.Round: stepX = rowWidth / stepsX; widthX = stepX; break; case BorderRepeat.Space: stepX = rowWidth / stepsX; startX = startX + (stepX - widthX) / 2f; break; } } drawHorizQuadRows(stepsX, startX, widthX, topY, farBottomY, width.Top.Value, width.Bottom.Value, textureWidth, slice.Top.Value, slice.Bottom.Value, slice.Left.Value, 1f - slice.Top.Value, 0f, stepX); float bottomY = border.Bottom.Value + width.Bottom.Value; float rowHeight = topY - bottomY; float textureWorldHeight = ((1f - slice.Top.Value - slice.Bottom.Value) * _height); int stepsY = (int)(rowHeight / textureWorldHeight); float textureHeight = 1f - slice.Top.Value - slice.Bottom.Value; if (textureHeight < 0f) textureHeight = 1f; float remainderY = rowHeight - textureWorldHeight * ((float)stepsY); float stepY = textureWorldHeight; float heightY = textureWorldHeight; float startY = bottomY; if (remainderY > 0.001f) { switch (repeat) { case BorderRepeat.Round: stepY = rowHeight / stepsY; heightY = stepY; break; case BorderRepeat.Space: stepY = rowHeight / stepsY; startY = startY + (stepY - heightY) / 2f; break; } } drawVertQuadRows(stepsY, border.Left.Value, rightX, width.Left.Value, width.Right.Value, startY, heightY, slice.Left.Value, slice.Right.Value, textureHeight, 0f, 1f - slice.Right.Value, slice.Bottom.Value, stepY); if (repeat == BorderRepeat.Repeat) { if (remainderX > 0.0001f) { textureWidth = (remainderX / textureWorldWidth) * textureWidth; leftX = leftX + textureWorldWidth * stepsX; drawHorizQuadRows(1, leftX, remainderX, topY, farBottomY, width.Top.Value, width.Bottom.Value, textureWidth, slice.Top.Value, slice.Bottom.Value, slice.Left.Value, 1f - slice.Top.Value, 0f, remainderX); } if (remainderY > 0.001f) { textureHeight = (remainderY / textureWorldHeight) * textureHeight; bottomY = bottomY + textureWorldHeight * stepsY; drawVertQuadRows(1, border.Left.Value, rightX, width.Left.Value, width.Right.Value, bottomY, remainderY, slice.Left.Value, slice.Right.Value, textureHeight, 0f, 1f - slice.Right.Value, slice.Bottom.Value, remainderY); } } }