-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d2f3b89
commit 78960c8
Showing
7 changed files
with
94 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,37 @@ | ||
namespace RueI.Extensions | ||
namespace RueI.Extensions; | ||
|
||
using RueI.Interfaces; | ||
|
||
/// <summary> | ||
/// Provides extensions and helpers for working with elements. | ||
/// </summary> | ||
public static class ElementHelpers | ||
{ | ||
/// <summary> | ||
/// Provides extensions and helpers for working with elements. | ||
/// Adds an <see cref="IElement"/> to a <see cref="IElementContainer"/>. | ||
/// </summary> | ||
public static class ElementHelpers | ||
{ | ||
/// <summary> | ||
/// Gets the functional (un-scaled) position of an element. | ||
/// </summary> | ||
/// <param name="element">The element to get the position for.</param> | ||
/// <returns>The un-scaled position..</returns> | ||
public static float GetFunctionalPosition(this IElement element) => Ruetility.ScaledPositionToFunctional(element.Position); | ||
/// <param name="element">The element to add.</param> | ||
/// <param name="container">The <see cref="IElementContainer"/> to add to.</param> | ||
/// <returns>A reference to this element.</returns> | ||
public static IElement AddTo(this IElement element, IElementContainer container) => element.AddTo(container.Elements); | ||
|
||
/// <summary> | ||
/// Calculates the offset for two hints. | ||
/// </summary> | ||
/// <param name="hintOnePos">The first hint's vertical position.</param> | ||
/// <param name="hintOneTotalLines">The first hint's total line-height, excluding the vertical position.</param> | ||
/// <param name="hintTwoPos">The second hint's vertical position.</param> | ||
/// <returns>A float indicating the new offset.</returns> | ||
public static float CalculateOffset(float hintOnePos, float hintOneTotalLines, float hintTwoPos) | ||
{ | ||
float calc = (hintOnePos + (2 * hintOneTotalLines)) - hintTwoPos; | ||
return calc / -2; | ||
} | ||
/// <summary> | ||
/// Gets the functional (un-scaled) position of an element. | ||
/// </summary> | ||
/// <param name="element">The element to get the position for.</param> | ||
/// <returns>The un-scaled position..</returns> | ||
public static float GetFunctionalPosition(this IElement element) => Ruetility.ScaledPositionToFunctional(element.Position); | ||
|
||
/// <summary> | ||
/// Calculates the offset for two hints. | ||
/// </summary> | ||
/// <param name="hintOnePos">The first hint's vertical position.</param> | ||
/// <param name="hintOneTotalLines">The first hint's total line-height, excluding the vertical position.</param> | ||
/// <param name="hintTwoPos">The second hint's vertical position.</param> | ||
/// <returns>A float indicating the new offset.</returns> | ||
public static float CalculateOffset(float hintOnePos, float hintOneTotalLines, float hintTwoPos) | ||
{ | ||
float calc = (hintOnePos + (2 * hintOneTotalLines)) - hintTwoPos; | ||
return calc / -2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace RueI.Interfaces | ||
{ | ||
/// <summary> | ||
/// Defines a container for multiple elements. | ||
/// </summary> | ||
public interface IElementContainer | ||
{ | ||
/// <summary> | ||
/// Gets the elements of this <see cref="IElementContainer"/>. | ||
/// </summary> | ||
public List<IElement> Elements { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<docs> | ||
<members name="display"> | ||
<Display> | ||
<example> | ||
This example demonstrates creating and using a <see cref="Display"/>. | ||
<code> | ||
Display display = new(referenceHub); // Create a new display from a <see cref="ReferenceHub"/> | ||
|
||
SetElement helloElem = new(300, zIndex: 10, "hello").AddTo(display); | ||
SetElement worldElem = new(250, zIndex: 10, "world").AddTo(display); | ||
display.Add(helloElem, worldElem); | ||
|
||
display.Update(); // Update the display | ||
</code> | ||
</example> | ||
</Display> | ||
</members> | ||
<members name="parser"> | ||
<Parser> | ||
<example> | ||
This example demonstrates creating and using a <see cref="ParserBuilder"/>. | ||
<code> | ||
Parser builder = new ParserBuilder() | ||
.ImportFrom(Constants.DefaultParser) | ||
.Build(); | ||
|
||
builder.Parse("hello world!") | ||
</code> | ||
</example> | ||
</Parser> | ||
</members> | ||
</docs> |