diff --git a/samples/NvgSharp.Samples.Demo/Demo.cs b/samples/NvgSharp.Samples.Demo/Demo.cs index 80e9fd8..4a338f1 100644 --- a/samples/NvgSharp.Samples.Demo/Demo.cs +++ b/samples/NvgSharp.Samples.Demo/Demo.cs @@ -1,16 +1,20 @@ using System; using System.IO; using FontStashSharp; +using FontStashSharp.RichText; #if MONOGAME || FNA using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Vector2 = Microsoft.Xna.Framework.Vector2; + #elif STRIDE using Stride.Core.Mathematics; #else using StbImageSharp; using System.Drawing; using Texture2D = NvgSharp.Samples.Texture; +using Vector2 = System.Numerics.Vector2; #endif namespace NvgSharp.Samples @@ -28,6 +32,10 @@ public class Demo SpriteFontBase fontSans18, fontSans20, fontBold18, fontBold20; Texture2D[] images = new Texture2D[12]; + private RichTextLayout rtLayout = new RichTextLayout() { + IgnoreColorCommand = false + }; + static float clampf(float a, float mn, float mx) { return a < mn ? mn : (a > mx ? mx : a); @@ -72,6 +80,8 @@ public Demo(NvgContext vg) fontBold18 = fontSystemBold.GetFont(18); fontBold20 = fontSystemBold.GetFont(20); + + rtLayout.Font = fontSans20; } public void drawWindow(NvgContext vg, string title, float x, float y, float w, float h) @@ -90,7 +100,8 @@ public void drawWindow(NvgContext vg, string title, float x, float y, float w, f vg.Fill(); // Drop shadow - shadowPaint = vg.BoxGradient(x, y + 2, w, h, cornerRadius * 2, 10, Utility.FromRGBA(0, 0, 0, 128), Utility.FromRGBA(0, 0, 0, 0)); + shadowPaint = vg.BoxGradient(x, y + 2, w, h, cornerRadius * 2, 10, Utility.FromRGBA(0, 0, 0, 128), + Utility.FromRGBA(0, 0, 0, 0)); vg.BeginPath(); vg.Rect(x - 10, y - 10, w + 20, h + 30); vg.RoundedRect(x, y, w, h, cornerRadius); @@ -99,7 +110,7 @@ public void drawWindow(NvgContext vg, string title, float x, float y, float w, f vg.Fill(); // Header - headerPaint = vg.LinearGradient(x, y, x, y + 15, Utility.FromRGBA(255, 255, 255, 8), Utility.FromRGBA(0, 0, 0, 16)); + headerPaint = vg.LinearGradient(x, y, x, y + 15, Utility.FromRGBA(255, 255, 255, 8),Utility.FromRGBA(0, 0, 0, 16)); vg.BeginPath(); vg.RoundedRect(x + 1, y + 1, w - 2, 30, cornerRadius - 1); vg.FillPaint(headerPaint); @@ -111,10 +122,10 @@ public void drawWindow(NvgContext vg, string title, float x, float y, float w, f vg.Stroke(); vg.FillColor(Utility.FromRGBA(0, 0, 0, 128)); - vg.TextAligned(fontBold18, title, x + w / 2, y + 16 + 1, TextHorizontalAlignment.Center, TextVerticalAlignment.Center); + vg.TextAligned(fontBold18, title, x + w / 2, y + 16 + 1, Vector2.One, TextHorizontalAlignment.Center,TextVerticalAlignment.Center); vg.FillColor(Utility.FromRGBA(220, 220, 220, 160)); - vg.TextAligned(fontBold18, title, x + w / 2, y + 16, TextHorizontalAlignment.Center, TextVerticalAlignment.Center); + vg.TextAligned(fontBold18, title, x + w / 2, y + 16, Vector2.One, TextHorizontalAlignment.Center, TextVerticalAlignment.Center, effect: FontSystemEffect.Stroked, effectAmount: 2); vg.RestoreState(); } @@ -125,7 +136,8 @@ public void drawSearchBox(NvgContext vg, string text, float x, float y, float w, float cornerRadius = h / 2 - 1; // Edit - bg = vg.BoxGradient(x, y + 1.5f, w, h, h / 2, 5, Utility.FromRGBA(0, 0, 0, 16), Utility.FromRGBA(0, 0, 0, 92)); + bg = vg.BoxGradient(x, y + 1.5f, w, h, h / 2, 5, Utility.FromRGBA(0, 0, 0, 16), + Utility.FromRGBA(0, 0, 0, 92)); vg.BeginPath(); vg.RoundedRect(x, y, w, h, cornerRadius); vg.FillPaint(bg); @@ -134,13 +146,13 @@ public void drawSearchBox(NvgContext vg, string text, float x, float y, float w, var fontIcons = fontSystemIcons.GetFont((int)(h * 1.3f)); vg.FillColor(Utility.FromRGBA(255, 255, 255, 64)); - vg.TextAligned(fontIcons, ICON_SEARCH, x + h * 0.55f, y + h * 0.55f, TextHorizontalAlignment.Center, TextVerticalAlignment.Center); + vg.TextAligned(fontIcons, ICON_SEARCH, x + h * 0.55f, y + h * 0.55f, Vector2.One ,TextHorizontalAlignment.Center, TextVerticalAlignment.Center); vg.FillColor(Utility.FromRGBA(255, 255, 255, 32)); - vg.TextAligned(fontSans20, text, x + h * 1.05f, y + h * 0.5f, TextHorizontalAlignment.Left, TextVerticalAlignment.Center); + vg.TextAligned(fontSans20, text, x + h * 1.05f, y + h * 0.5f, Vector2.One, TextHorizontalAlignment.Left, TextVerticalAlignment.Center); vg.FillColor(Utility.FromRGBA(255, 255, 255, 32)); - vg.TextAligned(fontIcons, ICON_CIRCLED_CROSS, x + w - h * 0.55f, y + h * 0.55f, TextHorizontalAlignment.Center, TextVerticalAlignment.Center); + vg.TextAligned(fontIcons, ICON_CIRCLED_CROSS, x + w - h * 0.55f, y + h * 0.55f, Vector2.One, TextHorizontalAlignment.Center, TextVerticalAlignment.Center); } public void drawDropDown(NvgContext vg, string text, float x, float y, float w, float h) @@ -160,24 +172,28 @@ public void drawDropDown(NvgContext vg, string text, float x, float y, float w, vg.Stroke(); vg.FillColor(Utility.FromRGBA(255, 255, 255, 160)); - vg.TextAligned(fontSans20, text, x + h * 0.3f, y + h * 0.5f, TextHorizontalAlignment.Left, TextVerticalAlignment.Center); + vg.TextAligned(fontSans20, text, x + h * 0.3f, y + h * 0.5f, Vector2.One, TextHorizontalAlignment.Left, + TextVerticalAlignment.Center); var fontIcons = fontSystemIcons.GetFont((int)(h * 1.3f)); vg.FillColor(Utility.FromRGBA(255, 255, 255, 64)); - vg.TextAligned(fontIcons, ICON_CHEVRON_RIGHT, x + w - h * 0.5f, y + h * 0.5f, TextHorizontalAlignment.Center, TextVerticalAlignment.Center); + vg.TextAligned(fontIcons, ICON_CHEVRON_RIGHT, x + w - h * 0.5f, y + h * 0.5f, Vector2.One, + TextHorizontalAlignment.Center, TextVerticalAlignment.Center); } public void drawLabel(NvgContext vg, string text, float x, float y, float w, float h) { vg.FillColor(Utility.FromRGBA(255, 255, 255, 128)); - vg.TextAligned(fontSans18, text, x, y + h * 0.5f, TextHorizontalAlignment.Left, TextVerticalAlignment.Center); + vg.TextAligned(fontSans18, text, x, y + h * 0.5f, Vector2.One, TextHorizontalAlignment.Left, + TextVerticalAlignment.Center); } public static void drawEditBoxBase(NvgContext vg, float x, float y, float w, float h) { Paint bg; // Edit - bg = vg.BoxGradient(x + 1, y + 1 + 1.5f, w - 2, h - 2, 3, 4, Utility.FromRGBA(255, 255, 255, 32), Utility.FromRGBA(32, 32, 32, 32)); + bg = vg.BoxGradient(x + 1, y + 1 + 1.5f, w - 2, h - 2, 3, 4, Utility.FromRGBA(255, 255, 255, 32), + Utility.FromRGBA(32, 32, 32, 32)); vg.BeginPath(); vg.RoundedRect(x + 1, y + 1, w - 2, h - 2, 4 - 1); vg.FillPaint(bg); @@ -194,7 +210,8 @@ public void drawEditBox(NvgContext vg, string text, float x, float y, float w, f drawEditBoxBase(vg, x, y, w, h); vg.FillColor(Utility.FromRGBA(255, 255, 255, 64)); - vg.TextAligned(fontSans20, text, x + h * 0.3f, y + h * 0.5f, TextHorizontalAlignment.Left, TextVerticalAlignment.Center); + vg.TextAligned(fontSans20, text, x + h * 0.3f, y + h * 0.5f, Vector2.One, TextHorizontalAlignment.Left, + TextVerticalAlignment.Center); } public void drawEditBoxNum(NvgContext vg, string text, string units, float x, float y, float w, float h) @@ -204,10 +221,12 @@ public void drawEditBoxNum(NvgContext vg, string text, string units, float x, fl var sz = fontSans18.MeasureString(units); vg.FillColor(Utility.FromRGBA(255, 255, 255, 64)); - vg.TextAligned(fontSans18, units, x + w - h * 0.3f, y + h * 0.5f, TextHorizontalAlignment.Right, TextVerticalAlignment.Center); + vg.TextAligned(fontSans18, units, x + w - h * 0.3f, y + h * 0.5f, Vector2.One, + TextHorizontalAlignment.Right, TextVerticalAlignment.Center); vg.FillColor(Utility.FromRGBA(255, 255, 255, 128)); - vg.TextAligned(fontSans20, text, x + w - sz.X - h * 0.5f, y + h * 0.5f, TextHorizontalAlignment.Right, TextVerticalAlignment.Center); + vg.TextAligned(fontSans20, text, x + w - sz.X - h * 0.5f, y + h * 0.5f, Vector2.One, + TextHorizontalAlignment.Right, TextVerticalAlignment.Center); } public void drawCheckBox(NvgContext vg, string text, float x, float y, float w, float h) @@ -215,9 +234,11 @@ public void drawCheckBox(NvgContext vg, string text, float x, float y, float w, Paint bg; vg.FillColor(Utility.FromRGBA(255, 255, 255, 160)); - vg.TextAligned(fontSans18, text, x + 28, y + h * 0.5f, TextHorizontalAlignment.Left, TextVerticalAlignment.Center); + vg.TextAligned(fontSans18, text, x + 28, y + h * 0.5f, Vector2.One, TextHorizontalAlignment.Left, + TextVerticalAlignment.Center); - bg = vg.BoxGradient(x + 1, y + (int)(h * 0.5f) - 9 + 1, 18, 18, 3, 3, Utility.FromRGBA(0, 0, 0, 32), Utility.FromRGBA(0, 0, 0, 92)); + bg = vg.BoxGradient(x + 1, y + (int)(h * 0.5f) - 9 + 1, 18, 18, 3, 3, Utility.FromRGBA(0, 0, 0, 32), + Utility.FromRGBA(0, 0, 0, 92)); vg.BeginPath(); vg.RoundedRect(x + 1, y + (int)(h * 0.5f) - 9, 18, 18, 3); vg.FillPaint(bg); @@ -225,16 +246,19 @@ public void drawCheckBox(NvgContext vg, string text, float x, float y, float w, var fontIcons = fontSystemIcons.GetFont(40); vg.FillColor(Utility.FromRGBA(255, 255, 255, 128)); - vg.TextAligned(fontIcons, ICON_CHECK, x + 9 + 2, y + h * 0.5f, TextHorizontalAlignment.Center, TextVerticalAlignment.Center); + vg.TextAligned(fontIcons, ICON_CHECK, x + 9 + 2, y + h * 0.5f, Vector2.One, TextHorizontalAlignment.Center, + TextVerticalAlignment.Center); } - public void drawButton(NvgContext vg, string preicon, string text, float x, float y, float w, float h, Color col) + public void drawButton(NvgContext vg, string preicon, string text, float x, float y, float w, float h, + Color col) { Paint bg; float cornerRadius = 4.0f; float tw = 0, iw = 0; - bg = vg.LinearGradient(x, y, x, y + h, Utility.FromRGBA(255, 255, 255, isBlack(col) ? (byte)16 : (byte)32), + bg = vg.LinearGradient(x, y, x, y + h, + Utility.FromRGBA(255, 255, 255, isBlack(col) ? (byte)16 : (byte)32), Utility.FromRGBA(0, 0, 0, isBlack(col) ? (byte)16 : (byte)32)); vg.BeginPath(); vg.RoundedRect(x + 1, y + 1, w - 2, h - 2, cornerRadius - 1); @@ -243,6 +267,7 @@ public void drawButton(NvgContext vg, string preicon, string text, float x, floa vg.FillColor(col); vg.Fill(); } + vg.FillPaint(bg); vg.Fill(); @@ -261,13 +286,16 @@ public void drawButton(NvgContext vg, string preicon, string text, float x, floa iw += h * 0.15f; vg.FillColor(Utility.FromRGBA(255, 255, 255, 96)); - vg.TextAligned(fontIcons, preicon, x + w * 0.5f - tw * 0.5f - iw * 0.75f, y + h * 0.5f, TextHorizontalAlignment.Left, TextVerticalAlignment.Center); + vg.TextAligned(fontIcons, preicon, x + w * 0.5f - tw * 0.5f - iw * 0.75f, y + h * 0.5f, Vector2.One, + TextHorizontalAlignment.Left, TextVerticalAlignment.Center); } vg.FillColor(Utility.FromRGBA(0, 0, 0, 160)); - vg.TextAligned(fontBold20, text, x + w * 0.5f - tw * 0.5f + iw * 0.25f, y + h * 0.5f - 1, TextHorizontalAlignment.Left, TextVerticalAlignment.Center); + vg.TextAligned(fontBold20, text, x + w * 0.5f - tw * 0.5f + iw * 0.25f, y + h * 0.5f - 1, Vector2.One, + TextHorizontalAlignment.Left, TextVerticalAlignment.Center); vg.FillColor(Utility.FromRGBA(255, 255, 255, 160)); - vg.TextAligned(fontBold20, text, x + w * 0.5f - tw * 0.5f + iw * 0.25f, y + h * 0.5f, TextHorizontalAlignment.Left, TextVerticalAlignment.Center); + vg.TextAligned(fontBold20, text, x + w * 0.5f - tw * 0.5f + iw * 0.25f, y + h * 0.5f, Vector2.One, + TextHorizontalAlignment.Left, TextVerticalAlignment.Center); } public static void drawSlider(NvgContext vg, float pos, float x, float y, float w, float h) @@ -280,14 +308,16 @@ public static void drawSlider(NvgContext vg, float pos, float x, float y, float // ClearState(vg); // Slot - bg = vg.BoxGradient(x, cy - 2 + 1, w, 4, 2, 2, Utility.FromRGBA(0, 0, 0, 32), Utility.FromRGBA(0, 0, 0, 128)); + bg = vg.BoxGradient(x, cy - 2 + 1, w, 4, 2, 2, Utility.FromRGBA(0, 0, 0, 32), + Utility.FromRGBA(0, 0, 0, 128)); vg.BeginPath(); vg.RoundedRect(x, cy - 2, w, 4, 2); vg.FillPaint(bg); vg.Fill(); // Knob Shadow - bg = vg.RadialGradient(x + (int)(pos * w), cy + 1, kr - 3, kr + 3, Utility.FromRGBA(0, 0, 0, 64), Utility.FromRGBA(0, 0, 0, 0)); + bg = vg.RadialGradient(x + (int)(pos * w), cy + 1, kr - 3, kr + 3, Utility.FromRGBA(0, 0, 0, 64), + Utility.FromRGBA(0, 0, 0, 0)); vg.BeginPath(); vg.Rect(x + (int)(pos * w) - kr - 5, cy - kr - 5, kr * 2 + 5 + 5, kr * 2 + 5 + 5 + 3); vg.Circle(x + (int)(pos * w), cy, kr); @@ -296,7 +326,8 @@ public static void drawSlider(NvgContext vg, float pos, float x, float y, float vg.Fill(); // Knob - knob = vg.LinearGradient(x, cy - kr, x, cy + kr, Utility.FromRGBA(255, 255, 255, 16), Utility.FromRGBA(0, 0, 0, 16)); + knob = vg.LinearGradient(x, cy - kr, x, cy + kr, Utility.FromRGBA(255, 255, 255, 16), + Utility.FromRGBA(0, 0, 0, 16)); vg.BeginPath(); vg.Circle(x + (int)(pos * w), cy, kr - 1); vg.FillColor(Utility.FromRGBA(40, 43, 48, 255)); @@ -312,6 +343,13 @@ public static void drawSlider(NvgContext vg, float pos, float x, float y, float vg.RestoreState(); } + public static void drawFssRtl(NvgContext vg, RichTextLayout rtl, float x, float y, int w, string text) + { + rtl.Text = text; + rtl.Width = w; + vg.Text(rtl, x, y, Vector2.One, 0); + } + public static void drawEyes(NvgContext vg, float x, float y, float w, float h, float mx, float my, float t) { Paint gloss, bg; @@ -325,14 +363,16 @@ public static void drawEyes(NvgContext vg, float x, float y, float w, float h, f float br = (ex < ey ? ex : ey) * 0.5f; float blink = 1 - (float)(Math.Pow(Math.Sin(t * 0.5f), 200) * 0.8f); - bg = vg.LinearGradient(x, y + h * 0.5f, x + w * 0.1f, y + h, Utility.FromRGBA(0, 0, 0, 32), Utility.FromRGBA(0, 0, 0, 16)); + bg = vg.LinearGradient(x, y + h * 0.5f, x + w * 0.1f, y + h, Utility.FromRGBA(0, 0, 0, 32), + Utility.FromRGBA(0, 0, 0, 16)); vg.BeginPath(); vg.Ellipse(lx + 3.0f, ly + 16.0f, ex, ey); vg.Ellipse(rx + 3.0f, ry + 16.0f, ex, ey); vg.FillPaint(bg); vg.Fill(); - bg = vg.LinearGradient(x, y + h * 0.25f, x + w * 0.1f, y + h, Utility.FromRGBA(220, 220, 220, 255), Utility.FromRGBA(128, 128, 128, 255)); + bg = vg.LinearGradient(x, y + h * 0.25f, x + w * 0.1f, y + h, Utility.FromRGBA(220, 220, 220, 255), + Utility.FromRGBA(128, 128, 128, 255)); vg.BeginPath(); vg.Ellipse(lx, ly, ex, ey); vg.Ellipse(rx, ry, ex, ey); @@ -347,6 +387,7 @@ public static void drawEyes(NvgContext vg, float x, float y, float w, float h, f dx /= d; dy /= d; } + dx *= ex * 0.4f; dy *= ey * 0.5f; vg.BeginPath(); @@ -362,6 +403,7 @@ public static void drawEyes(NvgContext vg, float x, float y, float w, float h, f dx /= d; dy /= d; } + dx *= ex * 0.4f; dy *= ey * 0.5f; vg.BeginPath(); @@ -369,13 +411,15 @@ public static void drawEyes(NvgContext vg, float x, float y, float w, float h, f vg.FillColor(Utility.FromRGBA(32, 32, 32, 255)); vg.Fill(); - gloss = vg.RadialGradient(lx - ex * 0.25f, ly - ey * 0.5f, ex * 0.1f, ex * 0.75f, Utility.FromRGBA(255, 255, 255, 128), Utility.FromRGBA(255, 255, 255, 0)); + gloss = vg.RadialGradient(lx - ex * 0.25f, ly - ey * 0.5f, ex * 0.1f, ex * 0.75f, + Utility.FromRGBA(255, 255, 255, 128), Utility.FromRGBA(255, 255, 255, 0)); vg.BeginPath(); vg.Ellipse(lx, ly, ex, ey); vg.FillPaint(gloss); vg.Fill(); - gloss = vg.RadialGradient(rx - ex * 0.25f, ry - ey * 0.5f, ex * 0.1f, ex * 0.75f, Utility.FromRGBA(255, 255, 255, 128), Utility.FromRGBA(255, 255, 255, 0)); + gloss = vg.RadialGradient(rx - ex * 0.25f, ry - ey * 0.5f, ex * 0.1f, ex * 0.75f, + Utility.FromRGBA(255, 255, 255, 128), Utility.FromRGBA(255, 255, 255, 0)); vg.BeginPath(); vg.Ellipse(rx, ry, ex, ey); vg.FillPaint(gloss); @@ -434,7 +478,8 @@ public static void drawGraph(NvgContext vg, float x, float y, float w, float h, // Graph sample pos for (i = 0; i < 6; i++) { - bg = vg.RadialGradient(sx[i], sy[i] + 2, 3.0f, 8.0f, Utility.FromRGBA(0, 0, 0, 32), Utility.FromRGBA(0, 0, 0, 0)); + bg = vg.RadialGradient(sx[i], sy[i] + 2, 3.0f, 8.0f, Utility.FromRGBA(0, 0, 0, 32), + Utility.FromRGBA(0, 0, 0, 0)); vg.BeginPath(); vg.Rect(sx[i] - 10, sy[i] - 10 + 2, 20, 20); vg.FillPaint(bg); @@ -481,7 +526,8 @@ public static void drawSpinner(NvgContext vg, float cx, float cy, float r, float vg.RestoreState(); } - public static void drawThumbnails(NvgContext vg, float x, float y, float w, float h, Texture2D[] images, float t) + public static void drawThumbnails(NvgContext vg, float x, float y, float w, float h, Texture2D[] images, + float t) { float cornerRadius = 3.0f; Paint shadowPaint, imgPaint, fadePaint; @@ -499,7 +545,8 @@ public static void drawThumbnails(NvgContext vg, float x, float y, float w, floa // ClearState(vg); // Drop shadow - shadowPaint = vg.BoxGradient(x, y + 4, w, h, cornerRadius * 2, 20, Utility.FromRGBA(0, 0, 0, 128), Utility.FromRGBA(0, 0, 0, 0)); + shadowPaint = vg.BoxGradient(x, y + 4, w, h, cornerRadius * 2, 20, Utility.FromRGBA(0, 0, 0, 128), + Utility.FromRGBA(0, 0, 0, 0)); vg.BeginPath(); vg.Rect(x - 10, y - 10, w + 20, h + 30); vg.RoundedRect(x, y, w, h, cornerRadius); @@ -560,7 +607,8 @@ public static void drawThumbnails(NvgContext vg, float x, float y, float w, floa vg.FillPaint(imgPaint); vg.Fill(); - shadowPaint = vg.BoxGradient(tx - 1, ty, thumb + 2, thumb + 2, 5, 3, Utility.FromRGBA(0, 0, 0, 128), Utility.FromRGBA(0, 0, 0, 0)); + shadowPaint = vg.BoxGradient(tx - 1, ty, thumb + 2, thumb + 2, 5, 3, Utility.FromRGBA(0, 0, 0, 128), + Utility.FromRGBA(0, 0, 0, 0)); vg.BeginPath(); vg.Rect(tx - 5, ty - 5, thumb + 10, thumb + 10); vg.RoundedRect(tx, ty, thumb, thumb, 6); @@ -574,23 +622,27 @@ public static void drawThumbnails(NvgContext vg, float x, float y, float w, floa vg.StrokeColor(Utility.FromRGBA(255, 255, 255, 192)); vg.Stroke(); } + vg.RestoreState(); // Hide fades - fadePaint = vg.LinearGradient(x, y, x, y + 6, Utility.FromRGBA(200, 200, 200, 255), Utility.FromRGBA(200, 200, 200, 0)); + fadePaint = vg.LinearGradient(x, y, x, y + 6, Utility.FromRGBA(200, 200, 200, 255), + Utility.FromRGBA(200, 200, 200, 0)); vg.BeginPath(); vg.Rect(x + 4, y, w - 8, 6); vg.FillPaint(fadePaint); vg.Fill(); - fadePaint = vg.LinearGradient(x, y + h, x, y + h - 6, Utility.FromRGBA(200, 200, 200, 255), Utility.FromRGBA(200, 200, 200, 0)); + fadePaint = vg.LinearGradient(x, y + h, x, y + h - 6, Utility.FromRGBA(200, 200, 200, 255), + Utility.FromRGBA(200, 200, 200, 0)); vg.BeginPath(); vg.Rect(x + 4, y + h - 6, w - 8, 6); vg.FillPaint(fadePaint); vg.Fill(); // Scroll bar - shadowPaint = vg.BoxGradient(x + w - 12 + 1, y + 4 + 1, 8, h - 8, 3, 4, Utility.FromRGBA(0, 0, 0, 32), Utility.FromRGBA(0, 0, 0, 92)); + shadowPaint = vg.BoxGradient(x + w - 12 + 1, y + 4 + 1, 8, h - 8, 3, 4, Utility.FromRGBA(0, 0, 0, 32), + Utility.FromRGBA(0, 0, 0, 92)); vg.BeginPath(); vg.RoundedRect(x + w - 12, y + 4, 8, h - 8, 3); vg.FillPaint(shadowPaint); @@ -598,7 +650,8 @@ public static void drawThumbnails(NvgContext vg, float x, float y, float w, floa vg.Fill(); scrollh = (h / stackh) * (h - 8); - shadowPaint = vg.BoxGradient(x + w - 12 - 1, y + 4 + (h - 8 - scrollh) * u - 1, 8, scrollh, 3, 4, Utility.FromRGBA(220, 220, 220, 255), Utility.FromRGBA(128, 128, 128, 255)); + shadowPaint = vg.BoxGradient(x + w - 12 - 1, y + 4 + (h - 8 - scrollh) * u - 1, 8, scrollh, 3, 4, + Utility.FromRGBA(220, 220, 220, 255), Utility.FromRGBA(128, 128, 128, 255)); vg.BeginPath(); vg.RoundedRect(x + w - 12 + 1, y + 4 + 1 + (h - 8 - scrollh) * u, 8 - 2, scrollh - 2, 2); vg.FillPaint(shadowPaint); @@ -618,15 +671,15 @@ public static void drawColorwheel(NvgContext vg, float x, float y, float w, floa vg.SaveState(); /* vg.BeginPath(); - vg.Rect(x,y,w,h); - vg.FillColor(GLUtility.FromRGBA(255,0,0,128)); - vg.Fill();*/ + vg.Rect(x,y,w,h); + vg.FillColor(GLUtility.FromRGBA(255,0,0,128)); + vg.Fill();*/ cx = x + w * 0.5f; cy = y + h * 0.5f; r1 = (w < h ? w : h) * 0.5f - 5.0f; r0 = r1 - 20.0f; - aeps = 0.5f / r1; // half a pixel arc length in radians (2pi cancels out). + aeps = 0.5f / r1; // half a pixel arc length in radians (2pi cancels out). for (i = 0; i < 6; i++) { @@ -640,7 +693,8 @@ public static void drawColorwheel(NvgContext vg, float x, float y, float w, floa ay = cy + (float)Math.Sin(a0) * (r0 + r1) * 0.5f; bx = cx + (float)Math.Cos(a1) * (r0 + r1) * 0.5f; by = cy + (float)Math.Sin(a1) * (r0 + r1) * 0.5f; - paint = vg.LinearGradient(ax, ay, bx, by, Utility.HSLA(a0 / ((float)Math.PI * 2), 1.0f, 0.55f, 255), Utility.HSLA(a1 / ((float)Math.PI * 2), 1.0f, 0.55f, 255)); + paint = vg.LinearGradient(ax, ay, bx, by, Utility.HSLA(a0 / ((float)Math.PI * 2), 1.0f, 0.55f, 255), + Utility.HSLA(a1 / ((float)Math.PI * 2), 1.0f, 0.55f, 255)); vg.FillPaint(paint); vg.Fill(); } @@ -664,7 +718,8 @@ public static void drawColorwheel(NvgContext vg, float x, float y, float w, floa vg.StrokeColor(Utility.FromRGBA(255, 255, 255, 192)); vg.Stroke(); - paint = vg.BoxGradient(r0 - 3, -5, r1 - r0 + 6, 10, 2, 4, Utility.FromRGBA(0, 0, 0, 128), Utility.FromRGBA(0, 0, 0, 0)); + paint = vg.BoxGradient(r0 - 3, -5, r1 - r0 + 6, 10, 2, 4, Utility.FromRGBA(0, 0, 0, 128), + Utility.FromRGBA(0, 0, 0, 0)); vg.BeginPath(); vg.Rect(r0 - 2 - 10, -4 - 10, r1 - r0 + 4 + 20, 8 + 20); vg.Rect(r0 - 2, -4, r1 - r0 + 4, 8); @@ -683,10 +738,12 @@ public static void drawColorwheel(NvgContext vg, float x, float y, float w, floa vg.LineTo(ax, ay); vg.LineTo(bx, by); vg.ClosePath(); - paint = vg.LinearGradient(r, 0, ax, ay, Utility.HSLA(hue, 1.0f, 0.5f, 255), Utility.FromRGBA(255, 255, 255, 255)); + paint = vg.LinearGradient(r, 0, ax, ay, Utility.HSLA(hue, 1.0f, 0.5f, 255), + Utility.FromRGBA(255, 255, 255, 255)); vg.FillPaint(paint); vg.Fill(); - paint = vg.LinearGradient((r + ax) * 0.5f, (0 + ay) * 0.5f, bx, by, Utility.FromRGBA(0, 0, 0, 0), Utility.FromRGBA(0, 0, 0, 255)); + paint = vg.LinearGradient((r + ax) * 0.5f, (0 + ay) * 0.5f, bx, by, Utility.FromRGBA(0, 0, 0, 0), + Utility.FromRGBA(0, 0, 0, 255)); vg.FillPaint(paint); vg.Fill(); vg.StrokeColor(Utility.FromRGBA(0, 0, 0, 64)); @@ -720,8 +777,8 @@ public static void drawLines(NvgContext vg, float x, float y, float w, float h, float pad = 5.0f, s = w / 9.0f - pad * 2; float[] pts = new float[4 * 2]; float fx, fy; - LineCap[] joins = new LineCap[] { LineCap.Miter, LineCap.Round, LineCap.Bevel }; - LineCap[] caps = new LineCap[] { LineCap.Butt, LineCap.Round, LineCap.Square }; + LineCap[] joins = new LineCap[] {LineCap.Miter, LineCap.Round, LineCap.Bevel}; + LineCap[] caps = new LineCap[] {LineCap.Butt, LineCap.Round, LineCap.Square}; vg.SaveState(); pts[0] = -s * 0.25f + (float)Math.Cos(t * 0.3f) * s * 0.5f; @@ -805,7 +862,7 @@ public static void drawWidths(NvgContext vg, float x, float y, float width) public static void drawCaps(NvgContext vg, float x, float y, float width) { int i; - LineCap[] caps = new[] { LineCap.Butt, LineCap.Round, LineCap.Square }; + LineCap[] caps = new[] {LineCap.Butt, LineCap.Round, LineCap.Square}; float lineWidth = 8.0f; vg.SaveState(); @@ -871,7 +928,7 @@ public static void drawScissor(NvgContext vg, float x, float y, float t) } public void renderDemo(NvgContext vg, float mx, float my, float width, float height, - float t, bool blowup) + float t, bool blowup) { float x, y, popy; @@ -879,6 +936,10 @@ public void renderDemo(NvgContext vg, float mx, float my, float width, float hei drawGraph(vg, 0, height / 2, width, height / 2, t); drawColorwheel(vg, width - 300, height - 300, 250.0f, 250.0f, t); + drawFssRtl(vg, rtLayout, 600, 10, 190, + "This is a rich text layout string./nThis supports /v[-3]/es[2]all FontStashSharp effects. /eb[2](really!)/vd" + + "/ed\n\nIt does however not support FSS rich colors (overriden by Nvg FillColor)"); + // Line joints drawLines(vg, 120, height - 50, 600, 50, t); diff --git a/samples/NvgSharp.Samples.Demo/NvgExtensions.cs b/samples/NvgSharp.Samples.Demo/NvgExtensions.cs index 6412a71..0d454b8 100644 --- a/samples/NvgSharp.Samples.Demo/NvgExtensions.cs +++ b/samples/NvgSharp.Samples.Demo/NvgExtensions.cs @@ -1,6 +1,16 @@ using FontStashSharp; using System.Text; +#if MONOGAME || FNA +using Vector2 = Microsoft.Xna.Framework.Vector2; + +#elif STRIDE +using Stride.Core.Mathematics; + +#else +using Vector2 = System.Numerics.Vector2; +#endif + namespace NvgSharp { public enum TextHorizontalAlignment @@ -41,9 +51,10 @@ public enum TextVerticalAlignment internal static class NvgExtensions { - public static void TextAligned(this NvgContext context, SpriteFontBase font, string text, float x, float y, + public static void TextAligned(this NvgContext context, SpriteFontBase font, string text, float x, float y, Vector2 scale, TextHorizontalAlignment horizontalAlignment = TextHorizontalAlignment.Left, TextVerticalAlignment verticalAlignment = TextVerticalAlignment.Top, - float layerDepth = 0.0f, float characterSpacing = 0.0f, float lineSpacing = 0.0f) + float layerDepth = 0.0f, float characterSpacing = 0.0f, float lineSpacing = 0.0f, FontSystemEffect effect = FontSystemEffect.Stroked, + int effectAmount = 0) { if (string.IsNullOrEmpty(text)) { @@ -72,12 +83,13 @@ public static void TextAligned(this NvgContext context, SpriteFontBase font, str y -= font.LineHeight; } - context.Text(font, text, x, y, layerDepth, characterSpacing, lineSpacing); + context.Text(font, text, x, y, scale, layerDepth, characterSpacing, lineSpacing, effect, effectAmount); } - public static void TextAligned(this NvgContext context, SpriteFontBase font, StringBuilder text, float x, float y, - TextHorizontalAlignment horizontalAlignment = TextHorizontalAlignment.Left, TextVerticalAlignment verticalAlignment = TextVerticalAlignment.Top, - float layerDepth = 0.0f, float characterSpacing = 0.0f, float lineSpacing = 0.0f) + public static void TextAligned(this NvgContext context, SpriteFontBase font, StringBuilder text, float x, float y, Vector2 scale, + TextHorizontalAlignment horizontalAlignment = TextHorizontalAlignment.Left, TextVerticalAlignment verticalAlignment = TextVerticalAlignment.Top, + float layerDepth = 0.0f, float characterSpacing = 0.0f, float lineSpacing = 0.0f, FontSystemEffect effect = FontSystemEffect.Stroked, + int effectAmount = 0) { if (text == null || text.Length == 0) { @@ -106,7 +118,7 @@ public static void TextAligned(this NvgContext context, SpriteFontBase font, Str y -= font.LineHeight; } - context.Text(font, text, x, y, layerDepth, characterSpacing, lineSpacing); + context.Text(font, text, x, y, scale, layerDepth, characterSpacing, lineSpacing, effect, effectAmount); } } } \ No newline at end of file diff --git a/samples/NvgSharp.Samples.Demo/NvgSharp.Samples.Demo.FNA.csproj b/samples/NvgSharp.Samples.Demo/NvgSharp.Samples.Demo.FNA.csproj index 5d446c1..973a6fb 100644 --- a/samples/NvgSharp.Samples.Demo/NvgSharp.Samples.Demo.FNA.csproj +++ b/samples/NvgSharp.Samples.Demo/NvgSharp.Samples.Demo.FNA.csproj @@ -1,7 +1,7 @@  WinExe - net461 + net471 bin\FNA\$(Configuration) $(DefineConstants);FNA diff --git a/samples/NvgSharp.Samples.Demo/NvgSharp.Samples.Demo.MonoGame.csproj b/samples/NvgSharp.Samples.Demo/NvgSharp.Samples.Demo.MonoGame.csproj index 4e6881e..736b6b1 100644 --- a/samples/NvgSharp.Samples.Demo/NvgSharp.Samples.Demo.MonoGame.csproj +++ b/samples/NvgSharp.Samples.Demo/NvgSharp.Samples.Demo.MonoGame.csproj @@ -1,4 +1,4 @@ - + WinExe net6.0 @@ -63,7 +63,7 @@ - + diff --git a/samples/NvgSharp.Samples.Demo/PerfGraph.cs b/samples/NvgSharp.Samples.Demo/PerfGraph.cs index a48a368..d6866f5 100644 --- a/samples/NvgSharp.Samples.Demo/PerfGraph.cs +++ b/samples/NvgSharp.Samples.Demo/PerfGraph.cs @@ -7,6 +7,7 @@ #else using System.Drawing; using Texture2D = System.Object; +using Vector2 = System.Numerics.Vector2; #endif namespace NvgSharp.Samples @@ -114,7 +115,7 @@ public void Render(NvgContext vg, float x, float y) { var font = _fontSystem.GetFont(14); vg.FillColor(Utility.FromRGBA(240, 240, 240, 192)); - vg.TextAligned(font, _name, x + 3, y + 1, TextHorizontalAlignment.Left, TextVerticalAlignment.Top); + vg.TextAligned(font, _name, x + 3, y + 1, Vector2.One, TextHorizontalAlignment.Left, TextVerticalAlignment.Top); } if (_style == Style.GRAPH_RENDER_FPS) @@ -122,26 +123,26 @@ public void Render(NvgContext vg, float x, float y) var font = _fontSystem.GetFont(18); vg.FillColor(Utility.FromRGBA(240, 240, 240, 255)); str = string.Format("{0:0.00} FPS", 1.0f / avg); - vg.TextAligned(font, str, x + w - 3, y + 1, TextHorizontalAlignment.Right, TextVerticalAlignment.Top); + vg.TextAligned(font, str, x + w - 3, y + 1, Vector2.One, TextHorizontalAlignment.Right, TextVerticalAlignment.Top); font = _fontSystem.GetFont(15); vg.FillColor(Utility.FromRGBA(240, 240, 240, 160)); str = string.Format("{0:0.00} ms", avg * 1000.0f); - vg.TextAligned(font, str, x + w - 3, y + h - 1, TextHorizontalAlignment.Right, TextVerticalAlignment.Bottom); + vg.TextAligned(font, str, x + w - 3, y + h - 1, Vector2.One, TextHorizontalAlignment.Right, TextVerticalAlignment.Bottom); } else if (_style == Style.GRAPH_RENDER_PERCENT) { var font = _fontSystem.GetFont(18); vg.FillColor(Utility.FromRGBA(240, 240, 240, 255)); str = string.Format("{0:0.00} %%", avg); - vg.TextAligned(font, str, x + w - 3, y + 1, TextHorizontalAlignment.Right, TextVerticalAlignment.Top); + vg.TextAligned(font, str, x + w - 3, y + 1, Vector2.One, TextHorizontalAlignment.Right, TextVerticalAlignment.Top); } else { var font = _fontSystem.GetFont(18); vg.FillColor(Utility.FromRGBA(240, 240, 240, 255)); str = string.Format("{0:0.00} ms", avg * 1000.0f); - vg.TextAligned(font, str, x + w - 3, y + 1, TextHorizontalAlignment.Right, TextVerticalAlignment.Top); + vg.TextAligned(font, str, x + w - 3, y + 1, Vector2.One, TextHorizontalAlignment.Right, TextVerticalAlignment.Top); } } diff --git a/src/NvgSharp.Text/NvgSharp.Text.FNA.csproj b/src/NvgSharp.Text/NvgSharp.Text.FNA.csproj index 3a0934c..32832d3 100644 --- a/src/NvgSharp.Text/NvgSharp.Text.FNA.csproj +++ b/src/NvgSharp.Text/NvgSharp.Text.FNA.csproj @@ -1,6 +1,6 @@ - net461 + net471 NvgSharp.Text.FNA NvgSharp.Text.FNA NvgSharp.Text for FNA diff --git a/src/NvgSharp.Text/NvgSharp.Text.MonoGame.csproj b/src/NvgSharp.Text/NvgSharp.Text.MonoGame.csproj index 277d590..b02d219 100644 --- a/src/NvgSharp.Text/NvgSharp.Text.MonoGame.csproj +++ b/src/NvgSharp.Text/NvgSharp.Text.MonoGame.csproj @@ -1,9 +1,10 @@  - netstandard2.0 + net60 NvgSharp.Text for MonoGame $(DefineConstants);MONOGAME bin\MonoGame\$(Configuration) + 0.8.0 @@ -11,8 +12,12 @@ - - + + All + + + All + diff --git a/src/NvgSharp.Text/NvgSharp.Text.csproj b/src/NvgSharp.Text/NvgSharp.Text.csproj index a1d2f60..e8626e6 100644 --- a/src/NvgSharp.Text/NvgSharp.Text.csproj +++ b/src/NvgSharp.Text/NvgSharp.Text.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/NvgSharp.Text/NvgText.cs b/src/NvgSharp.Text/NvgText.cs index 60ef7ba..a127406 100644 --- a/src/NvgSharp.Text/NvgText.cs +++ b/src/NvgSharp.Text/NvgText.cs @@ -1,6 +1,7 @@ using System.Text; using FontStashSharp; using FontStashSharp.Interfaces; +using FontStashSharp.RichText; #if MONOGAME || FNA using Microsoft.Xna.Framework; @@ -27,9 +28,9 @@ private class TextRenderer : IFontStashRenderer2 internal int _lastVertexOffset; internal Texture2D _lastTextTexture = null; - #if MONOGAME || FNA || STRIDE +#if MONOGAME || FNA || STRIDE public GraphicsDevice GraphicsDevice => _context.GraphicsDevice; - #else +#else public ITexture2DManager TextureManager => this; @@ -39,7 +40,7 @@ private class TextRenderer : IFontStashRenderer2 public void SetTextureData(object texture, Rectangle bounds, byte[] data) => _context._renderer.SetTextureData(texture, bounds, data); - #endif +#endif public TextRenderer(NvgContext context) { @@ -109,7 +110,8 @@ private void FlushText() _lastTextTexture = null; } - public void Text(SpriteFontBase font, TextSource text, float x, float y, float layerDepth, float characterSpacing, float lineSpacing) + public void Text(SpriteFontBase font, TextSource text, float x, float y, float layerDepth, float characterSpacing, + float lineSpacing, Vector2 scale, FontSystemEffect effect = FontSystemEffect.None, int effectAmount = 0) { if (text.IsNull) { @@ -121,38 +123,75 @@ public void Text(SpriteFontBase font, TextSource text, float x, float y, float l if (text.StringText != null) { font.DrawText(this, text.StringText, new Vector2(x, y), Color.White, - layerDepth: layerDepth, characterSpacing: characterSpacing, lineSpacing: lineSpacing); + layerDepth: layerDepth, characterSpacing: characterSpacing, lineSpacing: lineSpacing, scale: scale, + effect: effect, effectAmount: effectAmount); } else { font.DrawText(this, text.StringBuilderText, new Vector2(x, y), Color.White, - layerDepth: layerDepth, characterSpacing: characterSpacing, lineSpacing: lineSpacing); + layerDepth: layerDepth, characterSpacing: characterSpacing, lineSpacing: lineSpacing, + scale: scale, effect: effect, effectAmount: effectAmount); + } + + FlushText(); + } + + public void Text(RichTextLayout rtl, float x, float y, Vector2 scale, float layerDepth, TextHorizontalAlignment horzAlign) + { + if (rtl == null || rtl.Text.Length == 0) + { + return; } + _lastVertexOffset = _context._renderCache.VertexCount; + rtl.Draw(this, new Vector2(x, y), Color.Blue, 0, + layerDepth: layerDepth, scale: scale, horizontalAlignment: horzAlign); FlushText(); } } + private static void Text(this NvgContext context, SpriteFontBase font, TextSource text, float x, float y, - float layerDepth, float characterSpacing, float lineSpacing) + float layerDepth, float characterSpacing, float lineSpacing, Vector2 scale, + FontSystemEffect effect = FontSystemEffect.None, int effectAmount = 0) { TextRenderer textRenderer; if (context._textRenderer == null) { textRenderer = new TextRenderer(context); context._textRenderer = textRenderer; - } else { + } + else + { + textRenderer = (TextRenderer)context._textRenderer; + } + + textRenderer.Text(font, text, x, y, layerDepth, characterSpacing, lineSpacing, scale, effect, effectAmount); + } + + public static void Text(this NvgContext context, RichTextLayout rtl, float x, float y, Vector2 scale, float layerDepth, TextHorizontalAlignment horzAlign = TextHorizontalAlignment.Left) + { + TextRenderer textRenderer; + if (context._textRenderer == null) + { + textRenderer = new TextRenderer(context); + context._textRenderer = textRenderer; + } + else + { textRenderer = (TextRenderer)context._textRenderer; } - textRenderer.Text(font, text, x, y, layerDepth, characterSpacing, lineSpacing); + textRenderer.Text(rtl, x, y, layerDepth: layerDepth, scale: scale, horzAlign: horzAlign); } - public static void Text(this NvgContext context, SpriteFontBase font, string text, float x, float y, - float layerDepth = 0.0f, float characterSpacing = 0.0f, float lineSpacing = 0.0f) => - Text(context, font, new TextSource(text), x, y, layerDepth, characterSpacing, lineSpacing); + public static void Text(this NvgContext context, SpriteFontBase font, string text, float x, float y, Vector2 scale, + float layerDepth = 0.0f, float characterSpacing = 0.0f, float lineSpacing = 0.0f, + FontSystemEffect effect = FontSystemEffect.None, int effectAmount = 0) => + Text(context, font, new TextSource(text), x, y, layerDepth, characterSpacing, lineSpacing, scale, effect, effectAmount); - public static void Text(this NvgContext context, SpriteFontBase font, StringBuilder text, float x, float y, - float layerDepth = 0.0f, float characterSpacing = 0.0f, float lineSpacing = 0.0f) => - Text(context, font, new TextSource(text), x, y, layerDepth, characterSpacing, lineSpacing); + public static void Text(this NvgContext context, SpriteFontBase font, StringBuilder text, float x, float y, Vector2 scale, + float layerDepth = 0.0f, float characterSpacing = 0.0f, float lineSpacing = 0.0f, + FontSystemEffect effect = FontSystemEffect.None, int effectAmount = 0) => + Text(context, font, new TextSource(text), x, y, layerDepth, characterSpacing, lineSpacing, scale, effect, effectAmount); } } diff --git a/src/XNA/NvgSharp.FNA.csproj b/src/XNA/NvgSharp.FNA.csproj index b5bd451..db4ab45 100644 --- a/src/XNA/NvgSharp.FNA.csproj +++ b/src/XNA/NvgSharp.FNA.csproj @@ -1,6 +1,6 @@ - net461 + net471 NvgSharp.FNA NvgSharp.FNA NvgSharp for FNA diff --git a/src/XNA/NvgSharp.MonoGame.csproj b/src/XNA/NvgSharp.MonoGame.csproj index cf29d1c..11fb3a3 100644 --- a/src/XNA/NvgSharp.MonoGame.csproj +++ b/src/XNA/NvgSharp.MonoGame.csproj @@ -1,9 +1,11 @@  - netstandard2.0 + net60 NvgSharp for MonoGame $(DefineConstants);MONOGAME bin\MonoGame\$(Configuration) + Library + 0.8.0 @@ -23,6 +25,7 @@ - + + diff --git a/src/XNA/Resources/Effect.dx11.mgfxo b/src/XNA/Resources/Effect.dx11.mgfxo index 9014531..7128d31 100644 Binary files a/src/XNA/Resources/Effect.dx11.mgfxo and b/src/XNA/Resources/Effect.dx11.mgfxo differ diff --git a/src/XNA/Resources/Effect_AA.dx11.mgfxo b/src/XNA/Resources/Effect_AA.dx11.mgfxo index c7e4890..6e5b832 100644 Binary files a/src/XNA/Resources/Effect_AA.dx11.mgfxo and b/src/XNA/Resources/Effect_AA.dx11.mgfxo differ diff --git a/src/XNA/Resources/Effect_AA.ogl.mgfxo b/src/XNA/Resources/Effect_AA.ogl.mgfxo index a1240ce..2c109f5 100644 Binary files a/src/XNA/Resources/Effect_AA.ogl.mgfxo and b/src/XNA/Resources/Effect_AA.ogl.mgfxo differ diff --git a/src/XNA/Resources/build.bat b/src/XNA/Resources/build.bat index 577a98a..e770ab4 100644 --- a/src/XNA/Resources/build.bat +++ b/src/XNA/Resources/build.bat @@ -3,5 +3,5 @@ mgfxc Effect.fx Effect_AA.ogl.mgfxo /Profile:OpenGL /defines:EDGE_AA=1 mgfxc Effect.fx Effect.dx11.mgfxo /Profile:DirectX_11 mgfxc Effect.fx Effect_AA.dx11.mgfxo /Profile:DirectX_11 /defines:EDGE_AA=1 -"D:\Windows Kits\10\bin\10.0.19041.0\x64\fxc.exe" /T fx_2_0 /Fo Effect.fxb Effect.fx -"D:\Windows Kits\10\bin\10.0.19041.0\x64\fxc.exe" /T fx_2_0 /Fo Effect_AA.fxb Effect.fx /D EDGE_AA=1 \ No newline at end of file +"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\fxc.exe" /T fx_2_0 /Fo Effect.fxb Effect.fx +"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\fxc.exe" /T fx_2_0 /Fo Effect_AA.fxb Effect.fx /D EDGE_AA=1 \ No newline at end of file