uniapp通过Canvas绘制网格(心电图,坐标纸等可用)

ucharts绘制心电图 自己手欠把hbuilderx版本升级了,没升级之前用的echarts,效果一样,升级之后echarts报错,但是定位不到哪里报错,所以才把echart换成ucharts,个人觉得还是慎用hbuilderx生成各个端吧,坑很深。 ucharts不支持一个图表显示两个x轴,所以我设置了两个图表,通过定位+透明使之重叠,来显示心电方格的效果。 1.显示效果 2.html代码段 <view class="qiun-chartsC"> <canvas canvas-id="canva 阅读详情

本篇文档是Canvas绘制心电图的第一个部分,想了解详情的可以关注后学习交流。

心电图的最底层需要一个网状底层,来方便进行数据的测量。
一、白底分大、中、小三个区域的网格
在这里插入图片描述
1、首先是HTML部分

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />

    <script src="js/jquery-3.2.1.min.js"></script>
    <!-- 引入JQuery文件(学习心电图的同学会用到,单纯学习网格不需要引入JQ文件) -->
    <link rel="stylesheet" href="style/index.css" />
    <!-- 引入样式文件 -->
    <title>网格</title>
  </head>
  <body>
    <div class="grids">
      <canvas id="grids" width="750px" height="750px"></canvas>
    </div>
    <script src="js/index.js"></script>
    <!-- 引入自己新建JS文件,为了完全保证程序正常运行,该段引入放在canvas后 -->
  </body>
</html>

HTML创建Canvas画布,并且定义画布大小。
2、使用JS绘制网格
2.1定义所需变量名

var ctx;

2.2编写网格绘制总函数
所需要的高级网格需要三种大小的网格,分别为大、中、小,这三种网格需要被同时调用执行,故专写一个函数来共同调用三种大小的绘制函数。

/**绘制网格总函数
 * 分别绘制
 * drawSmallGrid小网格
 * drawMediumGrid中网格
 * drawBigGrid大网格
 */
function drawgrid() {
  var c_canvas = document.getElementById("grids");
  drawSmallGrid(c_canvas);
  drawMediumGrid(c_canvas);
  drawBigGrid(c_canvas);
  return;
}

2.3编写小网格函数
众所周知,两点一线的道理canvas也受用,但是为了方便起见,网格类型的依靠循环来写,具体代码如下:

/**绘制小网格
 * 第一个for语句循环出纵向小方格细线条,间距为X轴方向3像素
 * 第二个for语句循环出横向小方格细线条,间距为Y轴方向3像素
 */
function drawSmallGrid(c_canvas) {
  ctx = c_canvas.getContext("2d");
  ctx.strokeStyle = "#f1dedf";
  ctx.strokeWidth = 1;
  ctx.beginPath();
  for (var x = 0.5; x < 750; x += 3) {
    ctx.moveTo(x, 0);
    ctx.lineTo(x, 750);
    ctx.stroke();
  }
  for (var y = 0.5; y < 750; y += 3) {
    ctx.moveTo(0, y);
    ctx.lineTo(750, y);
    ctx.stroke();
  }
  ctx.closePath();
  return;
}

2.4编写中网格函数
根据小网格,同理可绘制中型网格

 /**绘制中型网格
 * 第一个for语句循环出纵向中方格中线条,间距为X轴方向15像素,小网格的5倍
* 第二个for语句循环出横向中方格中线条,间距为Y轴方向15像素,小网格的5倍
 */
 function drawMediumGrid(c_canvas){
     ctx = c_canvas.getContext("2d");
     ctx.strokeStyle="#fdbeb9"; 8      ctx.strokeWidth = 2
    //宽度是小网格的2倍
     ctx.beginPath();
      for(var x=0.5;x<750;x+=15){
         ctx.moveTo(x,0);
        ctx.lineTo(x,750);
        ctx.stroke();
     }
      for(var y=0.5;y<750;y+=15){
         ctx.moveTo(0,y);
         ctx.lineTo(750,y);
         ctx.stroke();
     }
     ctx.closePath();
return;
  }

2.5编写大型网格
道理同中型网格

/**绘制大型网格
 * 第一个for语句循环出纵向大方格中线条,间距为X轴方向75像素,小网格的5倍
 * 第二个for语句循环出横向大方格中线条,间距为Y轴方向75像素,小网格的5倍
 */
function drawBigGrid(c_canvas) {
  ctx = c_canvas.getContext("2d");
  ctx.strokeStyle = "#e0514b";
  ctx.strokeWidth = 3;
  ctx.beginPath();
  for (var x = 0.5; x < 750; x += 75) {
    ctx.moveTo(x, 0);
    ctx.lineTo(x, 750);
    ctx.stroke();
  }
  for (var y = 0.5; y < 750; y += 75) {
    ctx.moveTo(0, y);
    ctx.lineTo(750, y);
    ctx.stroke();
  }
  ctx.closePath();
  return;
}

至此,大中小三中网格绘制成功,接下来只需要调用总函数,三中网格就能显示在页面上
2.6调用总函数

drawgrid();

二、更改网格样式(之前文档心电图样式)
我之前文档内的心电图同款网格只需要将小型网格和大型网格函数删除,并且在总函数内,删除对这两个函数的调用即可。

同时,将网格的颜色改变,即可实现我之前文档中的心电图同款网格。这里只告诉大家方法,理解了便能画出来了。

在这里给大家上一段CSS代码,来修改一些细节样式

* {
    padding: 0;
    margin: 0;
}

.grids {
    width: 750px;
    height: 750px;
    background: black;
}

通过这段代码,可以将网格的外边距取消,并且将网格的背景颜色改成黑色(或者其他颜色自己喜欢就好),通过这种改变DIV的背景颜色实现对网格添加背景颜色的方法,有利于我们之后在心电图操作中“显示/隐藏”网格的操作选项。

canvas绘制心电图 变量leadData是心电数据,类型是数组,举例:[2,3,5,5…],可以用随机数试一下。 阅读详情

相关推荐

Canvas案例-实现ECG心电图

这是一个用原生canvas实现ecg心电图的实现过程

weixin_50723565的博客 2053

uniapp中uchart

<template> <view class="bg-gray radius line-gray margin text-center padding-top-sm padding-bottom"> <view class="text-lg"> 全息心理档案总体图 </view> <!-- 折线图 --> <view class="qiun-charts"> <view class="canvas"&

weixin_45638909的博客 767

详细解析:uni-app|vue组件实现跳动的心脏图标纯CSS动效

今天,小凡继续跟大家分享一个非常实用的动效,一颗跳动的心脏动效。大家先别急着往下看,可以先考虑一下,如果我们自己来做一个心形的图形,应该怎样做呢?~(嘘.....悄悄告诉大家,小凡我刚开始时也没想出来,而且还是那种一点思路都没有的o(╥﹏╥)o),好啦,想不出来也没关系,大家继续往下看吧!O(∩_∩)O

偏科程序猿 2806

uniapp连接蓝牙获取设备心电图,并通过canvas进行绘画

canvas绘画心电图

Agont_的博客 1259

微信小程序中使用画布canvas实现动态心电图绘制

近期,接了个项目,三端(小程序、PC、公众号)同步开发,PC端没的问题,以前一直做的就是PC端,但是小程序和公众号之前没有做过,只能通过这个项目,边做边学了。人家都说小程序用原生的特别难,大部分都用uniapp开发,说是这个方便快捷,还能写app呢,因为我们的项目,需要用到蓝牙采集数据、画布画仪表盘以及心电图等,所以我们不太敢用uniapp开发,硬着头皮开始用原生开发。开发的过程中,也遇到过很多问题,但是好在经过我们团队的不懈努力,问题基本都解决了。下面我就来分享一下,在小程序中,如何通过canvas。

穆雄雄的博客 3655

ECG html canvas绘制心电图

ECG html canvas绘制心电图

uniapp实现蓝牙自动连接并获取心电图(代码篇)

我们最近的项目是需要写一个app和公司设备通过蓝牙连接,并且获取到心电图,这次是实现自动的,用户在第一次的时候需要点击连接蓝牙实现自动连接,后续更是不需要点击直接获取心电图,直接上代码,供大家参考!我这里是直接拿设备的名称和uuid,因考虑到用户大多数为中老年人,实现一键自动连接完全很有必要(只是自己的一些看法,这个还是得根据需求来)只不过我们的需求是这样的,如果有更好的方法请大家多多评论!

Agont_的博客 1120

Canvas绘制心电图

Canvas绘制心电图

使用canvas简单绘制心电图

绘制心电图,首先就要绘制表格 先贴出html代码 : 然后是绘制表格的函数,此表格包含大中小三种格子,分别对应三种函数: function drawSmallGrid(c_canvas){ var context = c_canvas.getContext("2d"); context.strokeStyle = "#f1dedf"; con

_破败的博客 9736

canvas绘制动态心电图

canvas绘制动态心电图,和监护仪上的一样,可参考使用!

差分分析.

差分分析是一种强大的密码攻击技术,通过研究明文差分与密文差分的关系来破解加密算法。本文系统介绍了差分分析的核心概念和方法: 基础差分分析:通过异或运算抵消密钥影响,利用差分分布表(DDT)寻找高概率差分特征,以FEAL-4为例展示了具体攻击过程。 高级差分技术:包括截断差分分析(关注部分特征)、不可能差分分析(排除概率为0的路径)和飞来去器分析(将算法分段处理)。 自动化搜索方法:介绍了松井算法和MILP(混合整数线性规划)方法,将差分路径搜索转化为数学优化问题。 这些方法展现了差分分析从基础理论到现代应用

weixin_61562383的博客 793

uniapp利用canvas绘制ECG网格图附带心电图显示------代码

之前是一个关于如何绘制心电图的代码,后续需求是添加ECG的网格背景图也是利用canvas绘制的。首先我们需要把两个分开分别ecg的背景图和心电图加蓝牙,分别写在两个盒子里写。这里先看看代码,后续我会继续发代码解读。

Agont_的博客 1184

基于STM32的智能计步器

通过这个项目,你将学习到STM32开发的基本流程、传感器数据采集及显示模块的使用。- 将MPU6050的SCL连接到STM32的SCL引脚,将SDA连接到SDA引脚。- 解决方案: 确保OLED模块已正确连接并初始化,检查初始化代码是否被执行。- 解决方案: 检查SCL和SDA的连接是否正确,确保引脚配置没有错误。- 库文件: 需要下载MPU6050和OLED的库,并包含在项目中。- 确保所有模块都与STM32的GND和VCC正确连接。- OLED显示模块的连接同样需要SCL和SDA。

G66666666666666的博客 886

uni-app使用websocket(封装、心跳检测)

实用的小程序websocket轻量封装,便捷引入

烈阳, 2万+

Megatron-LM中的TP、PP、DP、SP、CP并行

SP主要优化的是激活内存,它沿序列维度切分部分激活,适用于较短序列并行。CP主要解决的是长序列的显存问题,它沿序列维度切分所有激活和输入,并且对注意力机制也进行并行处理。二者可以组合使用,特别是当 TP > 1 并且需要处理长序列时,通过启用 SP 和 CP 可以最大化地优化内存使用和加速计算。

u013250861的博客 873

RK3568平台(USB篇)USB Gadget 驱动

USB 设备驱动,按照设备端关联的 USB 控制器 是工作在 主模式 还是 从模式,分为 USB 设备主机侧驱动 (主模式),或者 USB 设备从机侧驱动 (从模式)。同时,工作在 主模式 的 USB 控制器,称为 USB 主机控制器 (UHC: USB Host Controller),工作在 从模式 的 USB 控制器,称为 USB 设备控制器 (UDC: USB Device Controller)。有的 USB 控制器,只能工作在 主模式 或 从模式 中的某一种;

weixin_49303682的博客 1443

uni-app APP端Echarts 使用与踩坑总结

q

qq_37565670的博客 1万+

工业-实时数据采集

在主节点使用Flume采集/data_log目录下实时日志文件中的数据,将数据存入到Kafka的Topic 中(Topic名称分别为ChangeRecord、ProduceRecord和EnvironmentData,分区数为4),Flume 采集ChangeRecord。

dafsq的博客 596

nodejs+vue微信小程序 uniapp学生心理健康测评系统

本文介绍了使用微信小程序技术开发健康管理系统的设计与实现过程,首先对实现该系统的技术进行分析,说明选择Java后台技术和MySQL数据库的必要性,然后对基于微信小程序的健康管理系统的需求进行分析。基于微信小程序的健康管理系统上线后,反应良好,达到了所有的需求目的,完善了健康信息的工作,为人民健康管理发展具有一定的实际价值。然后通过详细的分析,进行系统设计,其次,系统在实施的可行性上,我选择了Node.js技术来进行开发设计,在数据存储上,采用 Mysql数据库来进行设计。1.3项目研究现状及内容 5。

QQ402205496的博客 600

ardupilot 获取避障传感器数据

本节主要记录自己学ardupilot的避障代码过程,首先看下怎么注册避障传感器,然后怎么获取避障数据。

陌城烟雨 5526

YOLOv8改进策略【独家融合改进】| StarNet + 小目标检测头,加强跨尺度的上下文特征融合,提高小目标检测能力

P3/8 - small检测头原始模型中的P3/8特征层对应的检测头主要用于检测相对较小的目标。其特征图大小相对较大,空间分辨率较高。适合检测尺寸大概在8x8到32x32像素左右的目标。P4/16 - medium检测头这个检测头对应的P4/16特征层经过了更多的下采样操作,相比P3/8特征图空间分辨率降低,但通道数增加,特征更抽象且有语义信息。它主要用于检测中等大小的目标,尺寸范围大概在32x32到64x64像素左右。P5/32 - large检测头P5/32。

Limiiiing的博客 640

自定义环形电量图uniapp可用

刚说完uniapp不可用,就惨遭打脸:注意驼峰的写法要用 kekbeb-case命名 <template> <view class="ring-data"> <view class="loading"> <view class="left" ref="left" :style="{'--background-color': backgroundColor,'--left-rote': leftRote,'--right-rote':rightRote}"

小权权的博客 695

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

uni-app开发安卓,再发布ios遇到的兼容性问题

1.错误效果:期望效果:

cozy666的博客 31

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

上一篇: uniapp实现蓝牙自动连接并获取心电图(代码篇)
下一篇: 如何评价GPT-4o?
爱抽烟的老汉
博客等级 码龄4年 321粉丝 64原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值