public static void drawDropDown(NvgContext vg, string text, float x, float y, float w, float h) { Paint bg; float cornerRadius = 4.0f; bg = vg.LinearGradient(x, y, x, y + h, new Color(255, 255, 255, 16), new Color(0, 0, 0, 16)); vg.BeginPath(); vg.RoundedRect(x + 1, y + 1, w - 2, h - 2, cornerRadius - 1); vg.FillPaint(bg); vg.Fill(); vg.BeginPath(); vg.RoundedRect(x + 0.5f, y + 0.5f, w - 1, h - 1, cornerRadius - 0.5f); vg.StrokeColor(new Color(0, 0, 0, 48)); vg.Stroke(); vg.FontSize(20.0f); vg.FontFace("sans"); vg.FillColor(new Color(255, 255, 255, 160)); vg.TextAlign(Alignment.Left | Alignment.Middle); vg.Text(x + h * 0.3f, y + h * 0.5f, text); vg.FontSize(h * 1.3f); vg.FontFace("icons"); vg.FillColor(new Color(255, 255, 255, 64)); vg.TextAlign(Alignment.Center | Alignment.Middle); vg.Text(x + w - h * 0.5f, y + h * 0.5f, ICON_CHEVRON_RIGHT); }
public static void drawCaps(NvgContext vg, float x, float y, float width) { int i; LineCap[] caps = new[] { LineCap.Butt, LineCap.Round, LineCap.Square }; float lineWidth = 8.0f; vg.Save(); vg.BeginPath(); vg.Rect(x - lineWidth / 2, y, width + lineWidth, 40); vg.FillColor(new Color(255, 255, 255, 32)); vg.Fill(); vg.BeginPath(); vg.Rect(x, y, width, 40); vg.FillColor(new Color(255, 255, 255, 32)); vg.Fill(); vg.StrokeWidth(lineWidth); for (i = 0; i < 3; i++) { vg.LineCap(caps[i]); vg.StrokeColor(new Color(0, 0, 0, 255)); vg.BeginPath(); vg.MoveTo(x, y + i * 10 + 5); vg.LineTo(x + width, y + i * 10 + 5); vg.Stroke(); } vg.Restore(); }
void draw_noodles(NvgContext vg, int x, int y) { int w = 200; int s = 70; vg.bndNodeBackground(x + w, y - 50, 100, 200, BNDwidgetState.BND_DEFAULT, BNDicon.BND_ICON_GHOST, "Default", new Color(0.392f, 0.392f, 0.392f)); vg.bndNodeBackground(x + w + 120, y - 50, 100, 200, BNDwidgetState.BND_HOVER, BNDicon.BND_ICON_GHOST, "Hover", new Color(0.392f, 0.392f, 0.392f)); vg.bndNodeBackground(x + w + 240, y - 50, 100, 200, BNDwidgetState.BND_ACTIVE, BNDicon.BND_ICON_GHOST, "Active", new Color(0.392f, 0.392f, 0.392f)); for (int i = 0; i < 9; ++i) { int a = i % 3; int b = i / 3; vg.bndNodeWire(x, y + s * a, x + w, y + s * b, (BNDwidgetState)a, (BNDwidgetState)b); } vg.bndNodePort(x, y, BNDwidgetState.BND_DEFAULT, new Color(0.5f, 0.5f, 0.5f)); vg.bndNodePort(x + w, y, BNDwidgetState.BND_DEFAULT, new Color(0.5f, 0.5f, 0.5f)); vg.bndNodePort(x, y + s, BNDwidgetState.BND_HOVER, new Color(0.5f, 0.5f, 0.5f)); vg.bndNodePort(x + w, y + s, BNDwidgetState.BND_HOVER, new Color(0.5f, 0.5f, 0.5f)); vg.bndNodePort(x, y + 2 * s, BNDwidgetState.BND_ACTIVE, new Color(0.5f, 0.5f, 0.5f)); vg.bndNodePort(x + w, y + 2 * s, BNDwidgetState.BND_ACTIVE, new Color(0.5f, 0.5f, 0.5f)); }
public int loadDemoData(GraphicsDevice device, NvgContext vg) { int i; if (vg == null) { return(-1); } for (i = 0; i < 12; i++) { var path = "Assets/images/image" + (i + 1).ToString() + ".jpg"; int width, height; byte[] data; using (var stream = File.OpenRead(path)) { var texture = Texture2D.FromStream(device, stream); width = texture.Width; height = texture.Height; data = new byte[texture.Width * texture.Height * 4]; texture.GetData(data); } images[i] = vg.CreateImageRGBA(width, height, 0, data); } fontIcons = LoadFont(vg, "icons", "Assets/entypo.ttf"); fontNormal = LoadFont(vg, "sans", "Assets/Roboto-Regular.ttf"); fontBold = LoadFont(vg, "sans-bold", "Assets/Roboto-Bold.ttf"); return(0); }
public static void drawSpinner(NvgContext vg, float cx, float cy, float r, float t) { float a0 = 0.0f + t * 6; float a1 = (float)Math.PI + t * 6; float r0 = r; float r1 = r * 0.75f; float ax, ay, bx, by; Paint paint; vg.Save(); vg.BeginPath(); vg.Arc(cx, cy, r0, a0, a1, Winding.ClockWise); vg.Arc(cx, cy, r1, a1, a0, Winding.CounterClockWise); vg.ClosePath(); ax = cx + (float)Math.Cos(a0) * (r0 + r1) * 0.5f; 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, new Color(0, 0, 0, 0), new Color(0, 0, 0, 128)); vg.FillPaint(paint); vg.Fill(); vg.Restore(); }
public static void drawScissor(NvgContext vg, float x, float y, float t) { vg.Save(); // Draw first rect and set scissor to it's area. vg.Translate(x, y); vg.Rotate(NvgUtility.DegToRad(5)); vg.BeginPath(); vg.Rect(-20, -20, 60, 40); vg.FillColor(new Color(255, 0, 0, 255)); vg.Fill(); vg.Scissor(-20, -20, 60, 40); // Draw second rectangle with offset and rotation. vg.Translate(40, 0); vg.Rotate(t); // Draw the intended second rectangle without any scissoring. vg.Save(); vg.ResetScissor(); vg.BeginPath(); vg.Rect(-20, -10, 60, 30); vg.FillColor(new Color(255, 128, 0, 64)); vg.Fill(); vg.Restore(); // Draw second rectangle with combined scissoring. vg.IntersectScissor(-20, -10, 60, 30); vg.BeginPath(); vg.Rect(-20, -10, 60, 30); vg.FillColor(new Color(255, 128, 0, 255)); vg.Fill(); vg.Restore(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use Content to load your game content here _nvgContext = new NvgContext(GraphicsDevice); }
public static void drawLabel(NvgContext vg, string text, float x, float y, float w, float h) { vg.FontSize(18.0f); vg.FontFace("sans"); vg.FillColor(new Color(255, 255, 255, 128)); vg.TextAlign(Alignment.Left | Alignment.Middle); vg.Text(x, y + h * 0.5f, text); }
public static void drawLines(NvgContext vg, float x, float y, float w, float h, float t) { int i, j; 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 }; vg.Save(); pts[0] = -s * 0.25f + (float)Math.Cos(t * 0.3f) * s * 0.5f; pts[1] = (float)Math.Sin(t * 0.3f) * s * 0.5f; pts[2] = -s * 0.25f; pts[3] = 0; pts[4] = s * 0.25f; pts[5] = 0; pts[6] = s * 0.25f + (float)Math.Cos(-t * 0.3f) * s * 0.5f; pts[7] = (float)Math.Sin(-t * 0.3f) * s * 0.5f; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { fx = x + s * 0.5f + (i * 3 + j) / 9.0f * w + pad; fy = y - s * 0.5f + pad; vg.LineCap(caps[i]); vg.LineJoin(joins[j]); vg.StrokeWidth(s * 0.3f); vg.StrokeColor(new Color(0, 0, 0, 160)); vg.BeginPath(); vg.MoveTo(fx + pts[0], fy + pts[1]); vg.LineTo(fx + pts[2], fy + pts[3]); vg.LineTo(fx + pts[4], fy + pts[5]); vg.LineTo(fx + pts[6], fy + pts[7]); vg.Stroke(); vg.LineCap(LineCap.Butt); vg.LineJoin(LineCap.Bevel); vg.StrokeWidth(1.0f); vg.StrokeColor(new Color(0, 192, 255, 255)); vg.BeginPath(); vg.MoveTo(fx + pts[0], fy + pts[1]); vg.LineTo(fx + pts[2], fy + pts[3]); vg.LineTo(fx + pts[4], fy + pts[5]); vg.LineTo(fx + pts[6], fy + pts[7]); vg.Stroke(); } } vg.Restore(); }
/// <inheritdoc /> protected override void OnPaint(object sender, NvgContext e) { base.OnPaint(sender, e); e.FillColor(NanoVg.Rgba(ForeColor)); e.FontFace(Font.Family); e.FontSize(Font.Size); e.TextAlign(NvgAlign.Left | NvgAlign.Top); e.Text(ClientLocation.X, ClientLocation.Y, Text); }
public static void drawEditBox(NvgContext vg, string text, float x, float y, float w, float h) { drawEditBoxBase(vg, x, y, w, h); vg.FontSize(20.0f); vg.FontFace("sans"); vg.FillColor(new Color(255, 255, 255, 64)); vg.TextAlign(Alignment.Left | Alignment.Middle); vg.Text(x + h * 0.3f, y + h * 0.5f, text); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { var device = GraphicsDevice; _context = new NvgContext(GraphicsDevice, 0); _context.bndSetDefaultResources(GraphicsDevice); _demo = new Demo(); _spriteBatch = new SpriteBatch(GraphicsDevice); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { var device = GraphicsDevice; _context = new NvgContext(GraphicsDevice); _demo = new Demo(); _demo.loadDemoData(GraphicsDevice, _context); _spriteBatch = new SpriteBatch(GraphicsDevice); }
public virtual void Render(Flat6Engine engine, NvgContext context, FrameEventArgs e) { _fpsGraph.UpdateGraph((float)engine.Window.RenderTime); context.FillColor(NanoVg.Rgba(255, 255, 255, 255)); context.FontFace("engine_mono"); context.FontSize(18); context.TextAlign(NvgAlign.Top | NvgAlign.Left); _fpsGraph.RenderGraph(context, 3, 3); _tpsGraph.RenderGraph(context, 3, 45); }
public static 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, new Color(255, 255, 255, isBlack(col) ? 16 : 32), new Color(0, 0, 0, isBlack(col) ? 16 : 32)); vg.BeginPath(); vg.RoundedRect(x + 1, y + 1, w - 2, h - 2, cornerRadius - 1); if (!isBlack(col)) { vg.FillColor(col); vg.Fill(); } vg.FillPaint(bg); vg.Fill(); vg.BeginPath(); vg.RoundedRect(x + 0.5f, y + 0.5f, w - 1, h - 1, cornerRadius - 0.5f); vg.StrokeColor(new Color(0, 0, 0, 48)); vg.Stroke(); vg.FontSize(20.0f); vg.FontFace("sans-bold"); Bounds bounds = new Bounds(); tw = vg.TextBounds(0, 0, text, ref bounds); if (!string.IsNullOrEmpty(preicon)) { vg.FontSize(h * 1.3f); vg.FontFace("icons"); iw = vg.TextBounds(0, 0, preicon, ref bounds); iw += h * 0.15f; } if (!string.IsNullOrEmpty(preicon)) { vg.FontSize(h * 1.3f); vg.FontFace("icons"); vg.FillColor(new Color(255, 255, 255, 96)); vg.TextAlign(Alignment.Left | Alignment.Middle); vg.Text(x + w * 0.5f - tw * 0.5f - iw * 0.75f, y + h * 0.5f, preicon); } vg.FontSize(20.0f); vg.FontFace("sans-bold"); vg.TextAlign(Alignment.Left | Alignment.Middle); vg.FillColor(new Color(0, 0, 0, 160)); vg.Text(x + w * 0.5f - tw * 0.5f + iw * 0.25f, y + h * 0.5f - 1, text); vg.FillColor(new Color(255, 255, 255, 160)); vg.Text(x + w * 0.5f - tw * 0.5f + iw * 0.25f, y + h * 0.5f, text); }
/// <inheritdoc /> protected override void OnPaint(object sender, NvgContext e) { base.OnPaint(sender, e); e.BeginPath(); e.Circle(ClientLocation.X + Size.Width / 2f, ClientLocation.Y + Size.Height / 2f, Size.Width / 2f); e.FillColor(Lit ? NanoVg.Rgba(ActiveColor) : NanoVg.Rgba(0xFF475054)); e.Fill(); e.StrokeColor(NanoVg.Rgba(0xFF192025)); e.Stroke(); }
public static void drawWindow(NvgContext vg, string title, float x, float y, float w, float h) { float cornerRadius = 3.0f; Paint shadowPaint; Paint headerPaint; vg.Save(); // ClearState(vg); // Window vg.BeginPath(); vg.RoundedRect(x, y, w, h, cornerRadius); vg.FillColor(new Color(28, 30, 34, 192)); // vg.FillColor(new Color(0,0,0,128)); vg.Fill(); // Drop shadow shadowPaint = vg.BoxGradient(x, y + 2, w, h, cornerRadius * 2, 10, new Color(0, 0, 0, 128), new Color(0, 0, 0, 0)); vg.BeginPath(); vg.Rect(x - 10, y - 10, w + 20, h + 30); vg.RoundedRect(x, y, w, h, cornerRadius); vg.PathWinding(Solidity.Hole); vg.FillPaint(shadowPaint); vg.Fill(); // Header headerPaint = vg.LinearGradient(x, y, x, y + 15, new Color(255, 255, 255, 8), new Color(0, 0, 0, 16)); vg.BeginPath(); vg.RoundedRect(x + 1, y + 1, w - 2, 30, cornerRadius - 1); vg.FillPaint(headerPaint); vg.Fill(); vg.BeginPath(); vg.MoveTo(x + 0.5f, y + 0.5f + 30); vg.LineTo(x + 0.5f + w - 1, y + 0.5f + 30); vg.StrokeColor(new Color(0, 0, 0, 32)); vg.Stroke(); vg.FontSize(18.0f); vg.FontFace("sans-bold"); vg.TextAlign(Alignment.Center | Alignment.Middle); vg.FontBlur(2); vg.FillColor(new Color(0, 0, 0, 128)); vg.Text(x + w / 2, y + 16 + 1, title); vg.FontBlur(0); vg.FillColor(new Color(220, 220, 220, 160)); vg.Text(x + w / 2, y + 16, title); vg.Restore(); }
private static int LoadFont(NvgContext vg, string name, string path) { byte[] data; var ms = new MemoryStream(); using (var stream = TitleContainer.OpenStream(path)) { stream.CopyTo(ms); data = ms.ToArray(); } return(vg.CreateFontMem(name, data)); }
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, new Color(255, 255, 255, 32), new Color(32, 32, 32, 32)); vg.BeginPath(); vg.RoundedRect(x + 1, y + 1, w - 2, h - 2, 4 - 1); vg.FillPaint(bg); vg.Fill(); vg.BeginPath(); vg.RoundedRect(x + 0.5f, y + 0.5f, w - 1, h - 1, 4 - 0.5f); vg.StrokeColor(new Color(0, 0, 0, 48)); vg.Stroke(); }
/// <inheritdoc /> protected override void OnPaint(object sender, NvgContext e) { base.OnPaint(sender, e); e.BeginPath(); e.RoundedRect(ClientLocation.X, ClientLocation.Y, Size.Width, Size.Height, 2); e.StrokeColor(NanoVg.Rgba(43, 51, 55, 255)); e.Stroke(); e.FillColor(NanoVg.Rgba(ForeColor)); e.FontFace(Font.Family); e.FontSize(Font.Size); e.TextAlign(NvgAlign.Baseline | NvgAlign.Left); e.Text(ClientLocation.X, ClientLocation.Y - 3, Text); }
public void Init(Flat6Window window) { Window = window; Lumberjack.Debug("Creating framebuffers"); FramebufferScene = new Framebuffer(8); FramebufferScene.Init(Window.Width, Window.Height); FramebufferInterface = new Framebuffer(8); FramebufferInterface.Init(Window.Width, Window.Height); CreateScreenVao(); Lumberjack.Debug("Creating shaders"); ShaderDefault = new ShaderProgram(EmbeddedResources.FsDefault, EmbeddedResources.VsDefault); ShaderDefault.Uniforms.SetValue("texModel", 0); ShaderDefault.Uniforms.SetValue("texRandom", 1); ShaderScreen = new ShaderProgram(EmbeddedResources.FsScreen, EmbeddedResources.VsScreen); ShaderScreen.Uniforms.SetValue("width", Window.Width); ShaderScreen.Uniforms.SetValue("height", Window.Height); ShaderScreen.Uniforms.SetValue("texScene", 0); ShaderScreen.Uniforms.SetValue("texInterface", 1); ShaderScreen.Uniforms.SetValue("samplesScene", FramebufferScene.Width); ShaderScreen.Uniforms.SetValue("samplesInterface", FramebufferInterface.Samples); TextureDefault = TexturePointer.Create(EmbeddedResources.ImgNoTexture); TextureRandom = TexturePointer.Create(EmbeddedResources.ImgRandom); Lumberjack.Debug("Creating NanoVG context"); Nvg = GlNanoVg.CreateGl(NvgCreateFlags.StencilStrokes); Nvg.CreateFont("engine_mono", EmbeddedResources.IBMPlexMono_Text); // Just so ProcGraph is happy for now, TODO Nvg.CreateFont("sans", EmbeddedResources.IBMPlexMono_Text); UserInterface = new DebugUserInterface(); Lumberjack.Debug("Creating scene"); Camera = new Camera(); Scene = new Scene(); Flat6Window.SuppressGlMessage(131218); // "Shader will be recompiled due to..." WindowCreated?.Invoke(this, EventArgs.Empty); }
/// <inheritdoc /> protected override void OnPaint(object sender, NvgContext e) { base.OnPaint(sender, e); e.BeginPath(); e.RoundedRect(ClientLocation.X, ClientLocation.Y, Size.Width, Size.Height, 2); e.FillColor(Checked ? NanoVg.Rgba(ActiveColor) : NanoVg.Rgba(0xFF475054)); e.Fill(); e.StrokeColor(NanoVg.Rgba(0xFF192025)); e.Stroke(); e.FillColor(NanoVg.Rgba(ForeColor)); e.FontFace(Font.Family); e.FontSize(Font.Size); e.TextAlign(NvgAlign.Left | NvgAlign.Middle); e.Text(ClientLocation.X + Size.Width + 4, ClientLocation.Y + Size.Height / 2f, Text); }
/// <inheritdoc /> protected override void OnPaint(object sender, NvgContext e) { float x = Location.X; float y = Location.Y; e.BeginPath(); e.Rect(x, y, Width, Height); e.FillColor(NanoVg.Rgba(255, 255, 255, 64)); e.Fill(); x += FrameWidth; y += FrameWidth; var usableWidth = Width - 2 * FrameWidth; var usableHeight = Height - 2 * FrameWidth; var i = 0; var hPos = 0f; e.FontSize(15); e.FontFace("sans"); e.TextAlign(NvgAlign.Left | NvgAlign.Top); foreach (var pair in _profiles) { var perc = pair.Value.Average.GetAverage() / _totalTime; var barWidth = perc * usableWidth; e.FillColor(NanoVg.Rgba(Colors[i % Colors.Length])); e.BeginPath(); e.Rect(x + hPos, y, barWidth, usableHeight); e.Fill(); e.Text(x + hPos, y + Height + 15 * i, $"{perc:N2} {pair.Key}"); hPos += barWidth; i++; } base.OnPaint(sender, e); }
/// <inheritdoc /> protected override void OnPaint(object sender, NvgContext e) { base.OnPaint(sender, e); e.BeginPath(); e.Circle(ClientLocation.X + 7, ClientLocation.Y + 7, 7); e.FillColor(Checked ? NanoVg.Rgba(ActiveColor) : NanoVg.Rgba(0xFF475054)); e.Fill(); e.StrokeColor(NanoVg.Rgba(0xFF192025)); e.Stroke(); e.FillColor(NanoVg.Rgba(ForeColor)); e.FontFace(Font.Family); e.FontSize(Font.Size); e.TextAlign(NvgAlign.Left | NvgAlign.Middle); e.Text(ClientLocation.X + 18, ClientLocation.Y + 7.5f, Text); }
/// <inheritdoc /> protected override void OnPaint(object sender, NvgContext e) { base.OnPaint(sender, e); e.BeginPath(); e.RoundedRect(ClientLocation.X, ClientLocation.Y, Size.Width, Size.Height, 2); if (Active) { e.FillPaint(e.LinearGradient(ClientLocation.X, ClientLocation.Y, ClientLocation.X, ClientLocation.Y + Size.Height, NanoVg.Rgba(0xFF323B40), NanoVg.Rgba(0xFF323B40))); } else { e.FillPaint(e.LinearGradient(ClientLocation.X, ClientLocation.Y, ClientLocation.X, ClientLocation.Y + Size.Height, NanoVg.Rgba(0xFF50595E), NanoVg.Rgba(0xFF2B3337))); } e.Fill(); e.StrokeColor(NanoVg.Rgba(0xFF192025)); e.Stroke(); e.BeginPath(); e.RoundedRect(ClientLocation.X + 1, ClientLocation.Y + 1, Size.Width - 2, Size.Height - 2, 1); if (Active) { e.StrokeColor(NanoVg.Rgba(0xFF293034)); } else { e.StrokePaint(e.LinearGradient(ClientLocation.X, ClientLocation.Y, ClientLocation.X, ClientLocation.Y + Size.Height, NanoVg.Rgba(0xFF6E757B), NanoVg.Rgba(0xFF323B40))); } e.Stroke(); e.FillColor(NanoVg.Rgba(ForeColor)); e.FontFace(Font.Family); e.FontSize(Font.Size); e.TextAlign(NvgAlign.Center | NvgAlign.Middle); e.Text(ClientLocation.X + Size.Width / 2, ClientLocation.Y + Size.Height / 2, Text); }
public static void drawSlider(NvgContext vg, float pos, float x, float y, float w, float h) { Paint bg, knob; float cy = y + (int)(h * 0.5f); float kr = (int)(h * 0.25f); vg.Save(); // ClearState(vg); // Slot bg = vg.BoxGradient(x, cy - 2 + 1, w, 4, 2, 2, new Color(0, 0, 0, 32), new Color(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, new Color(0, 0, 0, 64), new Color(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); vg.PathWinding(Solidity.Hole); vg.FillPaint(bg); vg.Fill(); // Knob knob = vg.LinearGradient(x, cy - kr, x, cy + kr, new Color(255, 255, 255, 16), new Color(0, 0, 0, 16)); vg.BeginPath(); vg.Circle(x + (int)(pos * w), cy, kr - 1); vg.FillColor(new Color(40, 43, 48, 255)); vg.Fill(); vg.FillPaint(knob); vg.Fill(); vg.BeginPath(); vg.Circle(x + (int)(pos * w), cy, kr - 0.5f); vg.StrokeColor(new Color(0, 0, 0, 92)); vg.Stroke(); vg.Restore(); }
public static void drawWidths(NvgContext vg, float x, float y, float width) { int i; vg.Save(); vg.StrokeColor(new Color(0, 0, 0, 255)); for (i = 0; i < 20; i++) { float w = (i + 0.5f) * 0.1f; vg.StrokeWidth(w); vg.BeginPath(); vg.MoveTo(x, y); vg.LineTo(x + width, y + width * 0.3f); vg.Stroke(); y += 10; } vg.Restore(); }
public static void drawEditBoxNum(NvgContext vg, string text, string units, float x, float y, float w, float h) { float uw; drawEditBoxBase(vg, x, y, w, h); Bounds bounds = new Bounds(); uw = vg.TextBounds(0, 0, units, ref bounds); vg.FontSize(18.0f); vg.FontFace("sans"); vg.FillColor(new Color(255, 255, 255, 64)); vg.TextAlign(Alignment.Right | Alignment.Middle); vg.Text(x + w - h * 0.3f, y + h * 0.5f, units); vg.FontSize(20.0f); vg.FontFace("sans"); vg.FillColor(new Color(255, 255, 255, 128)); vg.TextAlign(Alignment.Right | Alignment.Middle); vg.Text(x + w - uw - h * 0.5f, y + h * 0.5f, text); }
public static void drawCheckBox(NvgContext vg, string text, float x, float y, float w, float h) { Paint bg; vg.FontSize(18.0f); vg.FontFace("sans"); vg.FillColor(new Color(255, 255, 255, 160)); vg.TextAlign(Alignment.Left | Alignment.Middle); vg.Text(x + 28, y + h * 0.5f, text); bg = vg.BoxGradient(x + 1, y + (int)(h * 0.5f) - 9 + 1, 18, 18, 3, 3, new Color(0, 0, 0, 32), new Color(0, 0, 0, 92)); vg.BeginPath(); vg.RoundedRect(x + 1, y + (int)(h * 0.5f) - 9, 18, 18, 3); vg.FillPaint(bg); vg.Fill(); vg.FontSize(40); vg.FontFace("icons"); vg.FillColor(new Color(255, 255, 255, 128)); vg.TextAlign(Alignment.Center | Alignment.Middle); vg.Text(x + 9 + 2, y + h * 0.5f, ICON_CHECK); }
public static void drawSearchBox(NvgContext vg, string text, float x, float y, float w, float h) { Paint bg; float cornerRadius = h / 2 - 1; // Edit bg = vg.BoxGradient(x, y + 1.5f, w, h, h / 2, 5, new Color(0, 0, 0, 16), new Color(0, 0, 0, 92)); vg.BeginPath(); vg.RoundedRect(x, y, w, h, cornerRadius); vg.FillPaint(bg); vg.Fill(); /* vg.BeginPath(); * vg.RoundedRect(x+0.5f,y+0.5f, w-1,h-1, cornerRadius-0.5f); * vg.StrokeColor(new Color(0,0,0,48)); * vg.Stroke();*/ vg.FontSize(h * 1.3f); vg.FontFace("icons"); vg.FillColor(new Color(255, 255, 255, 64)); vg.TextAlign(Alignment.Center | Alignment.Middle); vg.Text(x + h * 0.55f, y + h * 0.55f, ICON_SEARCH); vg.FontSize(20.0f); vg.FontFace("sans"); vg.FillColor(new Color(255, 255, 255, 32)); vg.TextAlign(Alignment.Left | Alignment.Middle); vg.Text(x + h * 1.05f, y + h * 0.5f, text); vg.FontSize(h * 1.3f); vg.FontFace("icons"); vg.FillColor(new Color(255, 255, 255, 32)); vg.TextAlign(Alignment.Center | Alignment.Middle); vg.Text(x + w - h * 0.55f, y + h * 0.55f, ICON_CIRCLED_CROSS); }