当前位置: 首页 > news >正文

鹰潭市网站建设_网站建设公司_跨域_seo优化

常用来做网站首业的是,购物网站 开店,商城网站建设都需要多少钱,互联网推广销售SkiaSharp是一个跨平台2D图形API#xff0c;用于.NET平台#xff0c;基于Googles Skia Graphics库(skia.org网站). 它提供了一个全面的2D API#xff0c;可以跨移动、服务器和桌面模型来渲染图像。该图形库可实现获取指定坐标像素值、绘制2d图形、绘制文字#xff08;必须有… SkiaSharp是一个跨平台2D图形API用于.NET平台基于Googles Skia Graphics库(skia.org网站). 它提供了一个全面的2D API可以跨移动、服务器和桌面模型来渲染图像。该图形库可实现获取指定坐标像素值、绘制2d图形、绘制文字必须有相应字库支持、创建缩略图等微软是大力支持的。可见此地址:https://docs.microsoft.com/zh-cn/dotnet/api/skiasharp首先是想熟悉下SkiaSharp的操作另外呢想基于SkiaSharp来做跨平台的UI渲染器一直没有动手在搜集资料现在基本搜集的差不多了所以就找点例子学学也挺有趣的。一个时钟的效果大概是以下的样子也挺简单的就是对度数是要计算的用到的方法也就画圆和画路径以及画文本几个方法。然后根据时间自动转动时钟的指针。自从毕业后就没有做过这样的案例了。但是上手了感觉还是很欣喜的。Wpf 和 SkiaSharp新建一个WPF项目然后Nuget包即可Install-Package SkiaSharp.Views.WPF -Version 2.88.0其中核心逻辑是这部分会以我设置的60FPS来刷新当前的画板。skContainer.PaintSurface  SkContainer_PaintSurface; _  Task.Run(()  {while (true){try{Dispatcher.Invoke(() {skContainer.InvalidateVisual();});_  SpinWait.SpinUntil(()  false, 1000 / 60);//每秒60帧}catch{break;}} });时钟逻辑/// summary/// 一个简单版的时钟/// /summarypublic class DrawClock{public SKPoint centerPoint;public int Radius  0;public int HAND_TRUNCATION;public int HOUR_HAND_TRUNCATION;public int HAND_RADIUS;public int TIPS;/// summary/// 渲染/// /summarypublic void Render(SKCanvas canvas, SKTypeface Font, int Width, int Height){centerPoint  new SKPoint(Width / 2, Height / 2);this.Radius  (int)(centerPoint.Y - 50);HAND_TRUNCATION  Width / 25;HOUR_HAND_TRUNCATION  Width / 10;HAND_RADIUS  this.Radius  15;TIPS  this.Radius - 40;canvas.Clear(SKColors.SkyBlue);DrawCircle(canvas, Font);DrawCenter(canvas, Font);DrawHands(canvas, Font);DrawTimeNumber(canvas, Font);DrawTips(canvas, Font);using var paint  new SKPaint{Color  SKColors.Black,IsAntialias  true,Typeface  Font,TextSize  20};using var paint2  new SKPaint{Color  SKColors.Blue,IsAntialias  true,Typeface  Font,TextSize  24};string msg  ${DateTime.Now:yyyy-MM-dd HH:mm:ss:fff:ffffff};string tishi   WPF SkiaSharp 自绘时钟 基础代码;string by  $by 蓝创精英团队;canvas.DrawText(msg, 0, 30, paint);canvas.DrawText(tishi, 450, 30, paint);canvas.DrawText(by, 600, 400, paint2);}/// summary/// 画一个圆/// /summarypublic void DrawCircle(SKCanvas canvas, SKTypeface Font){using var paint  new SKPaint{Color  SKColors.Black,Style  SKPaintStyle.Stroke,IsAntialias  true,StrokeWidth  2};canvas.DrawCircle(centerPoint.X, centerPoint.Y, Radius, paint);}/// summary/// 时钟的核心/// /summarypublic void DrawCenter(SKCanvas canvas, SKTypeface Font){using var paint  new SKPaint{Color  SKColors.Black,Style  SKPaintStyle.Fill,IsAntialias  true,StrokeWidth  2};canvas.DrawCircle(centerPoint.X, centerPoint.Y, 5, paint);}private void DrawHand(SKCanvas canvas, SKTypeface Font, int times, bool isHour  false){var angle  Math.PI * 2 * (times / (double)60) - Math.PI / 2;var handRadius  isHour ? this.Radius - HAND_TRUNCATION - HOUR_HAND_TRUNCATION : this.Radius - HAND_TRUNCATION;using var paint  new SKPaint{Color  (DateTimeOffset.Now.Second % 4  1) ? SKColors.Red : SKColors.Green,Style  SKPaintStyle.Fill,StrokeWidth  2,IsStroke  true,StrokeCap  SKStrokeCap.Round,IsAntialias  true};var path  new SKPath();path.MoveTo(centerPoint);path.LineTo((float)(centerPoint.X  Math.Cos(angle) * handRadius), (float)(centerPoint.Y  Math.Sin(angle) * handRadius));path.Close();canvas.DrawPath(path, paint);}/// summary/// 画时针/// /summarypublic void DrawHands(SKCanvas canvas, SKTypeface Font){var time  DateTime.Now;var hour  time.Hour  12 ? time.Hour - 12 : time.Hour;DrawHand(canvas, Font, hour * 5  time.Minute / 60 * 5, true);DrawHand(canvas, Font, time.Minute, false);DrawHand(canvas, Font, time.Second, false);}/// summary/// 画时间点/// /summarypublic void DrawTimeNumber(SKCanvas canvas, SKTypeface Font){using var paint  new SKPaint{Color  SKColors.Black,IsAntialias  true,Typeface  Font,TextSize  24};for (int i  1; i  12; i){var angle  Math.PI / 6 * (i - 3);var number  i.ToString();var numberTextWidth  paint.MeasureText(number);canvas.DrawText(number, (float)(centerPoint.X  Math.Cos(angle) * HAND_RADIUS - numberTextWidth / 2), (float)(centerPoint.Y  Math.Sin(angle) * HAND_RADIUS  24 / 3), paint);}}/// summary/// 画提示信息/// /summarypublic void DrawTips(SKCanvas canvas, SKTypeface Font){using var paint  new SKPaint{Color  SKColors.Black,IsAntialias  true,Typeface  Font,TextSize  20};var now  DateTime.Now;//年月日var Date  ${now.Year}/{now.Month}/{now.Day};var DateTextWidth  paint.MeasureText(Date);var angle  Math.PI / 6 * (6 - 3);canvas.DrawText(Date, (float)(centerPoint.X  Math.Cos(angle) * TIPS - DateTextWidth / 2), (float)(centerPoint.Y  Math.Sin(angle) * TIPS), paint);//PM AMvar amOrPm  now.Hour  12 ? PM : AM;var amOrPmTextWidth  paint.MeasureText(amOrPm);var angle2  Math.PI / 6 * (12 - 3);canvas.DrawText(amOrPm, (float)(centerPoint.X  Math.Cos(angle2) * TIPS - amOrPmTextWidth / 2), (float)(centerPoint.Y  Math.Sin(angle2) * TIPS), paint);}}运行结果总结这个录的GIF播放效果真不错基本体现出来了效果。也算是入门了后期可以基于SkiaSharp做更多的案例出来当然还是基于自绘的实现。代码地址https://github.com/kesshei/WPFSkiaClockDemo.githttps://gitee.com/kesshei/WPFSkiaClockDemo.git阅一键三连呦感谢大佬的支持您的支持就是我的动力!
http://www.ihoyoo.com/news/104729.html

相关文章:

  • 电器类网站设计休闲游戏开发
  • 电商网站建设怎么样网络营销与直播电商怎么样
  • 用asp.net做后台网站工信部网站首页
  • 旅游网站后台模板专业网站设计公司
  • 温州网站建设免费咨询有什么网站有小学生做的题目
  • 网站开发常用的语言html5商业网站开发北大青鸟
  • 邯郸企业网站制作重庆沙坪坝地图
  • 网站开发好不好农业电商网站建设
  • 怎么查看网站开发人域名的正确书写格式
  • 王悦做网站学生个人网页设计素材图片
  • 政务网站建设建议颜色广告
  • 学生怎么制作网站上海大型外贸公司
  • 广水网站建设昆明网站建设有限公司
  • 黄冈网站建设收费今天重大新闻100字
  • 远洋国际建设有限公司网站python自学网
  • icp备案和网站不符网站建设公司找博行
  • 绵阳网站建设推广佛山网站开发招聘
  • 长春免费建站用模板做的网站不好优化
  • dhl做运单的网站网上卖货的平台有哪些
  • 个旧网站建设公司信息流广告公司
  • 怎么创建教育网站南阳设计公司排名
  • 东莞设计网站公司响应式网站建设特征
  • 国内 上市网站建设公司网站标志的原则
  • 网站推广员是什么app开发费用
  • 顺的网站建设效果发稿渠道
  • 兰州做家教去哪个网站比较好南宁营销型网站设计
  • 手机网站制作建设电子商务物流
  • 网站收录查询网个人博客系统的设计与实现
  • 律师的网站模板订阅号怎么做免费的视频网站
  • 网站怎么做页面解析跳转廊坊seo优化排名