public virtual int DrawBitmap( ID2D1Bitmap bitmap, ref System.Numerics.Vector4 destinationRectangle, float opacity, D2D1_INTERPOLATION_MODE interpolationMode, ref System.Numerics.Vector4 sourceRectangle, ref D2D_MATRIX_4X4_F perspectiveTransform ) { var fp = GetFunctionPointer(17); if (m_DrawBitmapFunc == null) { m_DrawBitmapFunc = (DrawBitmapFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(DrawBitmapFunc)); } return(m_DrawBitmapFunc(m_ptr, bitmap != null ? bitmap.Ptr : IntPtr.Zero, ref destinationRectangle, opacity, interpolationMode, ref sourceRectangle, ref perspectiveTransform)); }
static int Main(string[] args) { Point p = new Point(1, 2, 3, 4); S s = new S(); C c = new C(); s.p.X = 1; c.p.Y = 2; if (((int)Do(s.p) != 1)) { return 0; } if (((int)c.p.X) != 0 || ((int)c.p.Y) != 2) { return 0; } Point[] fixedArr = new Point[5]; Point fixedPoint = new Point(1); fixedArr[0] = fixedPoint; if (fixedArr[0].X != 1) { return 0; } List<Point> points = new List<Point>(); points.Add(fixedPoint); if (((int)points[0].X) != 1 && ((int)points[0].Y) != 2) { return 0; } return 100; }
static int Main(string[] args) { Point p = new Point(1, 2, 3, 4); Point c = p; p.X = 2; if (p.X == c.X) { return 0; } return 100; }
static int Main(string[] args) { Point a = new Point(1, 2, 3, 4); Point b = new Point(2, 2, 1, 1); float c = 33; Point d = (b + a) * c; Point q = d + a; if (CheckEQ(q.X, 100)) { return 100; } return 0; }
static float sum(Point[] arr) { int n = arr.Length; Point s = new Point(0); for (int i = 0; i < n; ++i) { arr[i] += new Point(1); arr[i] *= 2; arr[i] -= (i == 0) ? new Point(0) : arr[i - 1]; arr[i] += (i == n - 1) ? new Point(0) : arr[i + 1]; s += arr[i]; } return s.X; }
static float sum(Point[] arr) { int n = arr.Length; Point s = new Point(0); for (int i = 0; i < n; ++i) { arr[i] += new Point(1); arr[i] *= 2; arr[i] -= (i == 0) ? new Point(0) : arr[i - 1]; arr[i] += (i == n - 1) ? new Point(0) : arr[i + 1]; s += arr[i]; } return(s.X); }
public static unsafe bool ColorEdit4(string label, ref float r, ref float g, ref float b, ref float a, ColorEditFlags flags = ColorEditFlags.Default) { System.Numerics.Vector4 localColor = new System.Numerics.Vector4(r, g, b, a); bool result = ImGuiNative.igColorEdit4(label, &localColor, flags); if (result) { r = localColor.X; g = localColor.Y; b = localColor.Z; a = localColor.W; } return(result); }
System.Numerics.Vector4 GetClientStateColor(string txt) { var col = new System.Numerics.Vector4(192, 192, 192, 255) / 255f; if (txt.StartsWith("Connected")) { col = new System.Numerics.Vector4(39, 135, 65, 255) / 255f; } else if (txt.StartsWith("Offline")) { col = new System.Numerics.Vector4(212, 0, 4, 255) / 255f; } return(col); }
public static RGBP128F LerpToRGBP128F(BGR24 tl, BGR24 tr, BGR24 bl, BGR24 br, float rx, float by) { // calculate quantized weights var lx = 1f - rx; var ty = 1f - by; var wwww = new System.Numerics.Vector4(lx * ty, rx * ty, lx * by, rx * by) / 255f; var r = new System.Numerics.Vector4(tl.R, tl.G, tl.B, 255f) * wwww.X; r += new System.Numerics.Vector4(tr.R, tr.G, tr.B, 255f) * wwww.Y; r += new System.Numerics.Vector4(bl.R, bl.G, bl.B, 255f) * wwww.Z; r += new System.Numerics.Vector4(br.R, br.G, br.B, 255f) * wwww.W; return(new RGBP128F(r)); }
public virtual int GetGlyphRunWorldBounds( System.Numerics.Vector2 baselineOrigin, ref DWRITE_GLYPH_RUN glyphRun, DWRITE_MEASURING_MODE measuringMode, out System.Numerics.Vector4 bounds ) { var fp = GetFunctionPointer(72); if (m_GetGlyphRunWorldBoundsFunc == null) { m_GetGlyphRunWorldBoundsFunc = (GetGlyphRunWorldBoundsFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(GetGlyphRunWorldBoundsFunc)); } return(m_GetGlyphRunWorldBoundsFunc(m_ptr, baselineOrigin, ref glyphRun, measuringMode, out bounds)); }
public virtual void FillOpacityMask( ID2D1Bitmap opacityMask, ID2D1Brush brush, ref System.Numerics.Vector4 destinationRectangle, ref System.Numerics.Vector4 sourceRectangle ) { var fp = GetFunctionPointer(91); if (m_FillOpacityMaskFunc == null) { m_FillOpacityMaskFunc = (FillOpacityMaskFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(FillOpacityMaskFunc)); } m_FillOpacityMaskFunc(m_ptr, opacityMask != null ? opacityMask.Ptr : IntPtr.Zero, brush != null ? brush.Ptr : IntPtr.Zero, ref destinationRectangle, ref sourceRectangle); }
/// <summary> /// TODO: Check if this actually works. /// </summary> private NVector4 GetLoopStartFromLoopEnd(NVector4 loopEnd) { var angleAtStart = loopEnd.W + (Data.FirstFrame.W - Data.LastFrame.W); // Find the delta from end to start var deltaStartToEnd = (Data.LastFrame - Data.FirstFrame); // Rotate delta translation by the delta from end to start var translation = NVector3.Transform(deltaStartToEnd.XYZ(), NMatrix.CreateRotationY(angleAtStart)); deltaStartToEnd.X = loopEnd.X - translation.X; deltaStartToEnd.Y = loopEnd.Y - translation.Y; deltaStartToEnd.Z = loopEnd.Z - translation.Z; deltaStartToEnd.W = angleAtStart; return(deltaStartToEnd); }
public virtual void DrawRectangle( ref System.Numerics.Vector4 rect, ID2D1Brush brush, float strokeWidth, ID2D1StrokeStyle strokeStyle ) { var fp = GetFunctionPointer(16); if (m_DrawRectangleFunc == null) { m_DrawRectangleFunc = (DrawRectangleFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(DrawRectangleFunc)); } m_DrawRectangleFunc(m_ptr, ref rect, brush != null ? brush.Ptr : IntPtr.Zero, strokeWidth, strokeStyle != null ? strokeStyle.Ptr : IntPtr.Zero); }
public static void PushGrayedOut(float valueMult = 0.5f) { var dv = new System.Numerics.Vector4(valueMult, valueMult, valueMult, 1); ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(255f / 255f, 255f / 255f, 255f / 255f, 1) * dv); ImGui.PushStyleColor(ImGuiCol.FrameBg, new System.Numerics.Vector4(40f / 255f, 57f / 255f, 83f / 255f, 1) * dv); ImGui.PushStyleColor(ImGuiCol.Button, new System.Numerics.Vector4(49f / 255f, 83f / 255f, 123f / 255f, 1) * dv); ImGui.PushStyleColor(ImGuiCol.ButtonActive, new System.Numerics.Vector4(49f / 255f, 83f / 255f, 123f / 255f, 1) * dv); //new System.Numerics.Vector4(15f / 255f, 135f / 255f, 250f / 255f, 1) * dv); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new System.Numerics.Vector4(49f / 255f, 83f / 255f, 123f / 255f, 1) * dv); //new System.Numerics.Vector4(66f / 255f, 150f / 255f, 250f / 255f, 1) * dv); }
public override void RenderDebug() { base.RenderDebug(); var v = Light.Radius; if (ImGui.DragFloat("Radius", ref v)) { Light.Radius = v; } var color = new System.Numerics.Vector4(Light.Color.R / 255f, Light.Color.G / 255f, Light.Color.B / 255f, Light.Color.A / 255f); if (ImGui.DragFloat4("Color", ref color)) { Light.Color = new Color(color.X * 255, color.Y * 255, color.Z * 255, color.W * 255); } }
public virtual int GetEffectRequiredInputRectangles( ID2D1Effect renderEffect, ref System.Numerics.Vector4 renderImageRectangle, ref D2D1_EFFECT_INPUT_DESCRIPTION inputDescriptions, out System.Numerics.Vector4 requiredInputRects, uint inputCount ) { var fp = GetFunctionPointer(90); if (m_GetEffectRequiredInputRectanglesFunc == null) { m_GetEffectRequiredInputRectanglesFunc = (GetEffectRequiredInputRectanglesFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(GetEffectRequiredInputRectanglesFunc)); } return(m_GetEffectRequiredInputRectanglesFunc(m_ptr, renderEffect != null ? renderEffect.Ptr : IntPtr.Zero, ref renderImageRectangle, ref inputDescriptions, out requiredInputRects, inputCount)); }
public virtual int GetWidenedBounds( float strokeWidth, ID2D1StrokeStyle strokeStyle, ref System.Numerics.Matrix3x2 worldTransform, float flatteningTolerance, out System.Numerics.Vector4 bounds ) { var fp = GetFunctionPointer(5); if (m_GetWidenedBoundsFunc == null) { m_GetWidenedBoundsFunc = (GetWidenedBoundsFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(GetWidenedBoundsFunc)); } return(m_GetWidenedBoundsFunc(m_ptr, strokeWidth, strokeStyle != null ? strokeStyle.Ptr : IntPtr.Zero, ref worldTransform, flatteningTolerance, out bounds)); }
public virtual void DrawBitmap( ID2D1Bitmap bitmap, ref System.Numerics.Vector4 destinationRectangle, float opacity, D2D1_BITMAP_INTERPOLATION_MODE interpolationMode, ref System.Numerics.Vector4 sourceRectangle ) { var fp = GetFunctionPointer(26); if (m_DrawBitmapFunc == null) { m_DrawBitmapFunc = (DrawBitmapFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(DrawBitmapFunc)); } m_DrawBitmapFunc(m_ptr, bitmap != null ? bitmap.Ptr : IntPtr.Zero, ref destinationRectangle, opacity, interpolationMode, ref sourceRectangle); }
public virtual void DrawImage( ID2D1Image image, ref System.Numerics.Vector2 targetOffset, ref System.Numerics.Vector4 imageRectangle, D2D1_INTERPOLATION_MODE interpolationMode, D2D1_COMPOSITE_MODE compositeMode ) { var fp = GetFunctionPointer(83); if (m_DrawImageFunc == null) { m_DrawImageFunc = (DrawImageFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(DrawImageFunc)); } m_DrawImageFunc(m_ptr, image != null ? image.Ptr : IntPtr.Zero, ref targetOffset, ref imageRectangle, interpolationMode, compositeMode); }
static void Main() { // Load the input image Console.WriteLine(">> Loading image"); string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "city.jpg"); using Image <Rgba32> image = Image.Load(path); var(height, width) = (image.Height, image.Width); // Get the vector buffer Console.WriteLine(">> Getting pixel data"); Vector4[] vectorArray = new Vector4[height * width]; // Populate the buffer Parallel.For(0, height, i => { ref Rgba32 rPixel = ref image.GetPixelRowSpan(i).GetPinnableReference(); ref Vector4 r4 = ref vectorArray[i * width];
public static string ToBVectorString(this BVector vector, int length = 3) { if (PhxPredicates.IsZero(vector)) { switch (length) { case 1: return("0"); case 2: return("0,0"); case 3: return("0,0,0"); case 4: return("0,0,0,0"); default: return(""); } } var sb = new System.Text.StringBuilder(32); if (length >= 1) { sb.Append(vector.X.ToStringInvariant(Numbers.kFloatRoundTripFormatSpecifier)); } if (length >= 2) { sb.AppendFormat(",{0}", vector.Y.ToStringInvariant(Numbers.kFloatRoundTripFormatSpecifier)); } if (length >= 3) { sb.AppendFormat(",{0}", vector.Z.ToStringInvariant(Numbers.kFloatRoundTripFormatSpecifier)); } if (length >= 4) { sb.AppendFormat(",{0}", vector.W.ToStringInvariant(Numbers.kFloatRoundTripFormatSpecifier)); } return(sb.ToString()); }
static int Main() { Point x = new Point(1); Point y, z; unsafe { Do1(&x, &y); Do2(&y, &z); } if (((int)y.X) != 1) { return 0; } if (((int)z.X) != 1) { return 0; } return 100; }
public static void RenderDebug() { if (!WindowManager.Lighting) { return; } if (!ImGui.Begin("Lighting", ImGuiWindowFlags.AlwaysAutoResize)) { ImGui.End(); return; } ImGui.Checkbox("Enabled", ref LevelLayerDebug.Lights); ImGui.Checkbox("Enable fog", ref EnableFog); ImGui.DragFloat("Radius mod", ref RadiusMod); ImGui.Separator(); ImGui.InputFloat("Surface alpha", ref alpha); ImGui.InputFloat3("Surface tint", ref color); if (ImGui.Combo("Surface blend", ref surfaceBlendId, blends, blends.Length)) { surfaceBlend = BlendIdToBlend(surfaceBlendId); } ImGui.Separator(); if (ImGui.Combo("Light blend", ref lightBlendId, blends, blends.Length)) { lightBlend = BlendIdToBlend(lightBlendId); } var c = new System.Numerics.Vector4(ClearColor.R / 255f, ClearColor.G / 255f, ClearColor.B / 255f, ClearColor.A / 255f); if (ImGui.InputFloat4("Color", ref c)) { ClearColor = new Color(c.X, c.Y, c.Z, c.W); } ImGui.End(); }
public static int CompareTo(this BVector vector, BVector other) { if (vector.X != other.X) { return(vector.X.CompareTo(other.X)); } if (vector.Y != other.Y) { return(vector.Y.CompareTo(other.Y)); } if (vector.Z != other.Z) { return(vector.Z.CompareTo(other.Z)); } return(vector.W.CompareTo(other.W)); }
public virtual void DrawText( ref ushort _string, uint stringLength, IDWriteTextFormat textFormat, ref System.Numerics.Vector4 layoutRect, ID2D1Brush defaultFillBrush, D2D1_DRAW_TEXT_OPTIONS options, DWRITE_MEASURING_MODE measuringMode ) { var fp = GetFunctionPointer(27); if (m_DrawTextWFunc == null) { m_DrawTextWFunc = (DrawTextWFunc)Marshal.GetDelegateForFunctionPointer(fp, typeof(DrawTextWFunc)); } m_DrawTextWFunc(m_ptr, ref _string, stringLength, textFormat != null ? textFormat.Ptr : IntPtr.Zero, ref layoutRect, defaultFillBrush != null ? defaultFillBrush.Ptr : IntPtr.Zero, options, measuringMode); }
static int Main() { Point x = new Point(1); Point y, z; unsafe { Do1(&x, &y); Do2(&y, &z); } if (((int)y.X) != 1) { return(0); } if (((int)z.X) != 1) { return(0); } return(100); }
private bool ConstructOrdering(Vec3 axis) { // cache some values var count = m_colours.Count; var values = m_colours.Points; // build the list of dot products var dps = new float[count]; for (int i = 0; i < count; ++i) { dps[i] = Vec3.Dot(values[i], axis); m_order[i] = (Byte)i; } // stable sort using them for (int i = 0; i < dps.Length; ++i) { for (int j = i; j > 0 && dps[j] < dps[j - 1]; --j) { dps.SwapElements(j, j - 1); m_order.SwapElements(j, j - 1); } } // copy the ordering and weight all the points var unweighted = m_colours.Points; var weights = m_colours.Weights; for (int i = 0; i < count; ++i) { int j = m_order[i]; m_weights[i] = weights[j]; m_unweighted[i] = new Vec4(unweighted[j], 1); m_weighted[i] = m_unweighted[i] * m_weights[i]; } return(true); }
public unsafe void FillWithColorCube(GraphicsDevice d, System.Numerics.Vector4 c) { TextureDescription desc = new TextureDescription(); desc.Width = 1; desc.Height = 1; desc.MipLevels = 1; desc.SampleCount = TextureSampleCount.Count1; desc.ArrayLayers = 6; desc.Depth = 1; desc.Type = TextureType.Texture2D; desc.Usage = TextureUsage.Staging; desc.Format = PixelFormat.R32_G32_B32_A32_Float; _staging = d.ResourceFactory.CreateTexture(desc); float[] col = new float[4]; col[0] = c.X; col[1] = c.Y; col[2] = c.Z; col[3] = c.W; for (uint i = 0; i < 6; i++) { MappedResource map = d.Map(_staging, MapMode.Write, i); fixed(void *data = col) { Unsafe.CopyBlock(map.Data.ToPointer(), data, 16); } } _pool.DescriptorTableDirty = true; Renderer.AddBackgroundUploadTask((gd, cl) => { desc.ArrayLayers = 1; desc.Usage = TextureUsage.Sampled | TextureUsage.Cubemap; _texture = d.ResourceFactory.CreateTexture(desc); cl.CopyTexture(_staging, _texture); Resident = true; _pool.DescriptorTableDirty = true; }); }
//public void DrawUI System.Numerics.Vector4 GetScriptStateColor(string txt) { var col = new System.Numerics.Vector4(192, 192, 192, 255) / 255f; if (txt.StartsWith("Success")) { col = new System.Numerics.Vector4(39, 135, 65, 255) / 255f; col = new System.Numerics.Vector4(39, 135, 65, 255) / 255f; } else if (txt.StartsWith("Failure")) { col = new System.Numerics.Vector4(212, 0, 4, 255) / 255f; } else if (txt.StartsWith("InProgress") || txt.StartsWith("Killing")) { col = new System.Numerics.Vector4(8, 0, 252, 255) / 255f; } return(col); }
static int Main(string[] args) { System.Diagnostics.Stopwatch clock = new System.Diagnostics.Stopwatch(); clock.Start(); Random random = new Random(13); int N = 10000; Point[] arr = new Point[N]; for (int i = 0; i < N; ++i) { arr[i].X = NextFloat(random); arr[i].Y = NextFloat(random); arr[i].Z = NextFloat(random); arr[i].W = NextFloat(random); } for (int i = 0; i < 1000; ++i) { sum(arr); } return 100; }
static int Main(string[] args) { Point a = new Point(10, 50,0,-100); Point b = new Point(10); Point c = Point.Max(a, b); if (((int)c.Y) != 50 || ((int)c.W) != 10) { return 0; } Point d = Point.Min(a, b); Point q = Point.Min(d, d); if (q != d) { return 0; } if (((int)d.W) != -100) { return 0; } return 100; }
/// <remarks> /// this assumes that steps have been sorted by GradientEditor /// </remarks> public Vector4 Sample(float t) { t = t.Clamp(0, 1); Step previousStep = null; foreach (var step in Steps) { if (step.NormalizedPosition >= t) { if (previousStep == null || previousStep.NormalizedPosition >= step.NormalizedPosition) { return(step.Color); } float amount = 0; // Hold switch (Interpolation) { case Interpolations.Linear: amount = MathUtils.RemapAndClamp(t, previousStep.NormalizedPosition, step.NormalizedPosition, 0, 1); break; case Interpolations.Smooth: amount = MathUtils.RemapAndClamp(t, previousStep.NormalizedPosition, step.NormalizedPosition, 0, 1); amount = MathUtils.SmootherStep(0, 1, amount); break; case Interpolations.OkLab: amount = MathUtils.RemapAndClamp(t, previousStep.NormalizedPosition, step.NormalizedPosition, 0, 1); return(OkLab.Mix(previousStep.Color, step.Color, amount)); } return(Vector4.Lerp(previousStep.Color, step.Color, amount)); } previousStep = step; } return(previousStep?.Color ?? Vector4.One); }
public static BVector?ParseBVectorString(string vectorString) { var vector = new BVector(); if (vectorString.IsNullOrEmpty()) { return(vector); } if (gParseBVectorStringScratchList == null) { gParseBVectorStringScratchList = new List <string>(4); } var list = gParseBVectorStringScratchList; if (!Util.ParseStringList(vectorString, list)) { return(null); } if (list.Count >= 1 && !Numbers.FloatTryParseInvariant(list[0], out vector.X)) { return(null); } if (list.Count >= 2 && !Numbers.FloatTryParseInvariant(list[1], out vector.Y)) { return(null); } if (list.Count >= 3 && !Numbers.FloatTryParseInvariant(list[2], out vector.Z)) { return(null); } if (list.Count >= 4 && !Numbers.FloatTryParseInvariant(list[3], out vector.W)) { return(null); } return(vector); }
static int Main(string[] args) { System.Diagnostics.Stopwatch clock = new System.Diagnostics.Stopwatch(); clock.Start(); Random random = new Random(13); int N = 10000; Point[] arr = new Point[N]; for (int i = 0; i < N; ++i) { arr[i].X = NextFloat(random); arr[i].Y = NextFloat(random); arr[i].Z = NextFloat(random); arr[i].W = NextFloat(random); } for (int i = 0; i < 1000; ++i) { sum(arr); } return(100); }
static string VectorToString(uint offset, int length, XmbVariantMemoryPool pool) { float x = 0, y = 0, z = 0, w = 0; switch (length) { case 1: { x = pool.GetSingle(offset); } break; case 2: { var v = pool.GetVector2D(offset); x = v.X; y = v.Y; } break; case 3: { var v = pool.GetVector3D(offset); x = v.X; y = v.Y; z = v.Z; } break; case 4: { var v = pool.GetVector4D(offset); x = v.X; y = v.Y; z = v.Z; w = v.W; } break; default: throw new ArgumentOutOfRangeException("length", length.ToString()); } var vector = new BVector(x, y, z, w); return(vector.ToBVectorString(length)); }
public override unsafe void OnUpdate(float deltaTime, Particle *arrayPtr, int length) { Particle *tail = arrayPtr + length; int totalFrames = SheetRows * SheetColumns; int frameSize = (int)Emitter.TextureSize.X / SheetRows; switch (loopMode) { case Mode.Life: { for (Particle *particle = arrayPtr; particle < tail; particle++) { int frame = (int)Between(0.0f, totalFrames, particle->TimeAlive / particle->InitialLife); #if NETSTANDARD2_1 int frameX = (int)MathF.Floor(frame % SheetRows); int frameY = (int)MathF.Floor(frame / SheetRows); #else int frameX = (int)Math.Floor((double)frame % SheetRows); int frameY = (int)Math.Floor((double)frame / SheetRows); #endif particle->SourceRectangle = new Vector4( frameX * frameSize, frameY * frameSize, frameSize, frameSize); } } break; case Mode.Loop: { for (Particle *particle = arrayPtr; particle < tail; particle++) { // TODO: } } break; default: throw new ArgumentOutOfRangeException(); } }
static int Main(string[] args) { Point a = new Point(10, 50, 0, -100); Point b = new Point(10); Point c = Point.Max(a, b); if (((int)c.Y) != 50 || ((int)c.W) != 10) { return(0); } Point d = Point.Min(a, b); Point q = Point.Min(d, d); if (q != d) { return(0); } if (((int)d.W) != -100) { return(0); } return(100); }
private unsafe void SubmitImGuiStuff() { ImGui.GetStyle().WindowRounding = 0; ImGui.SetNextWindowSize(new System.Numerics.Vector2(_nativeWindow.Width - 10, _nativeWindow.Height - 20), SetCondition.Always); ImGui.SetNextWindowPosCenter(SetCondition.Always); ImGui.BeginWindow("ImGUI.NET Sample Program", ref _mainWindowOpened, WindowFlags.NoResize | WindowFlags.NoTitleBar | WindowFlags.NoMove); ImGui.BeginMainMenuBar(); if (ImGui.BeginMenu("Help")) { if (ImGui.MenuItem("About", "Ctrl-Alt-A", false, true)) { } ImGui.EndMenu(); } ImGui.EndMainMenuBar(); ImGui.Text("Hello,"); ImGui.Text("World!"); ImGui.Text("From ImGui.NET. ...Did that work?"); var pos = ImGui.GetIO().MousePosition; bool leftPressed = ImGui.GetIO().MouseDown[0]; ImGui.Text("Current mouse position: " + pos + ". Pressed=" + leftPressed); if (ImGui.Button("Increment the counter.")) { _pressCount += 1; } ImGui.Text($"Button pressed {_pressCount} times.", new System.Numerics.Vector4(0, 1, 1, 1)); ImGui.InputTextMultiline("Input some text:", _textInputBuffer, (uint)_textInputBufferLength, new System.Numerics.Vector2(360, 240), InputTextFlags.Default, OnTextEdited); ImGui.SliderFloat("SlidableValue", ref _sliderVal, -50f, 100f, $"{_sliderVal.ToString("##0.00")}", 1.0f); ImGui.DragVector3("Vector3", ref _positionValue, -100, 100); if (ImGui.TreeNode("First Item")) { ImGui.Text("Word!"); ImGui.TreePop(); } if (ImGui.TreeNode("Second Item")) { ImGui.ColorButton(_buttonColor, false, true); if (ImGui.Button("Push me to change color", new System.Numerics.Vector2(120, 30))) { _buttonColor = new System.Numerics.Vector4(_buttonColor.Y + .25f, _buttonColor.Z, _buttonColor.X, _buttonColor.W); if (_buttonColor.X > 1.0f) { _buttonColor.X -= 1.0f; } } ImGui.TreePop(); } if (ImGui.Button("Press me!", new System.Numerics.Vector2(100, 30))) { ImGuiNative.igOpenPopup("SmallButtonPopup"); } if (ImGui.BeginPopup("SmallButtonPopup")) { ImGui.Text("Here's a popup menu."); ImGui.Text("With two lines."); ImGui.EndPopup(); } if (ImGui.Button("Open Modal window")) { ImGui.OpenPopup("ModalPopup"); } if (ImGui.BeginPopupModal("ModalPopup")) { ImGui.Text("You can't press on anything else right now."); ImGui.Text("You are stuck here."); if (ImGui.Button("OK", new System.Numerics.Vector2(0, 0))) { } ImGui.SameLine(); ImGui.Dummy(100f, 0f); ImGui.SameLine(); if (ImGui.Button("Please go away", new System.Numerics.Vector2(0, 0))) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } ImGui.Text("I have a context menu."); if (ImGui.BeginPopupContextItem("ItemContextMenu")) { if (ImGui.Selectable("How's this for a great menu?")) { } ImGui.Selectable("Just click somewhere to get rid of me."); ImGui.EndPopup(); } ImGui.EndWindow(); if (ImGui.GetIO().AltPressed && ImGui.GetIO().KeysDown[(int)Key.F4]) { _nativeWindow.Close(); } }
unsafe static void Do1(Point* src, Point* dst) { *((Point*)dst) = *((Point*)src); }
unsafe static void Do2(Point* src, Point* dst) { *((long*)dst) = *((long*)src); }
static float Do(Point p) { return p.X; }