首页 > 解决方案 > 如何实现管道?

问题描述

该模块的想法是能够以图形方式表示管道内的数据。
例如,数据可能如下所示:

1,4

这将是一个function y=f(x),其中:

4=f(1)

我需要使用这条线

TODO: WritePointToHTML(rawData);

其基本思想是生成 HTML 文件,其中包含绘制所需行的代码。

我尝试使用 html 画一条线,但我无法理解如何在管道中表示它

  var canvas = document.getElementById('Canvas');
  var context = canvas.getContext('2d');

标签: c#

解决方案


我假设原始海报正在寻找画线,而不是使用 c# 管道。

var can;
var ctx;

function init(){
  can=document.getElementById("Canvas");
  ctx=can.getContext("2d");
  ctx.canvas.width  = window.innerWidth;
  ctx.canvas.height = window.innerHeight;
  DrawSlope(1,20);
}

function DrawSlope(x,y)
{
   var firstPoint = [x,0];
   var secondPoint = [1,x+y];

WritePointToHTML(firstPoint[0],firstPoint[1],secondPoint[0],secondPoint[1]);
}

function WritePointToHTML(x,y,xTwo,yTwo)
{
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(xTwo, yTwo);
ctx.stroke();
}

// 添加“绘制斜率”以考虑斜率公式。 https://codepen.io/hollyeplyler/pen/gqYyZx


推荐阅读