nm9505

Canvas

Oct 4th, 2023
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | Science | 0 0
  1. //This example requires the 'Xamarin.Android GUI' option to be enabled
  2. //+ref=Java.Interop
  3. using System;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6. using NativeUiLib;
  7. using Android.Graphics;
  8.  
  9. namespace CSharp_Shell
  10. {
  11.  
  12.     public static class Program
  13.     {
  14.         public static void Main()
  15.         {
  16.             Ui.RunOnUiThread(()=> UiStuff());
  17.         }
  18.        
  19.         private static void UiStuff()
  20.         {
  21.                 var w = 800;
  22.                 var h = 600;
  23.                 var lay = new LinearLayout();
  24.                
  25.                 var drawingImageView = new ImageView();
  26.                 lay.AddView(drawingImageView);
  27.                
  28.                                
  29.                 var paint = new Paint();
  30.                 paint.Color = Color.Blue;
  31.                 paint.SetStyle(Paint.Style.Stroke);
  32.                 paint.StrokeWidth = 15;    
  33.                 var bmpBase = Bitmap.CreateBitmap(w, h, Bitmap.Config.Argb8888);
  34.                 Canvas canvas = new Canvas(bmpBase);
  35.                 canvas.DrawCircle(100, 100, 30, paint);
  36.                 drawingImageView.SetImageBitmap(bmpBase);
  37.                
  38.                 Ui.ShowLayout(lay);
  39.         }
  40.     }
  41. }
Add Comment
Please, Sign In to add comment