欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

TOUCHGFX CANVAS WIDGET (划线)

程序员文章站 2022-04-02 07:54:16
...

1.draw line (参考例程  touchgfx demo1)

      demo1  实现了多种线条的绘制

     实现的文件为

TOUCHGFX CANVAS WIDGET (划线)

 

void Screen1View::setupScreen()
{
 //   Screen1ViewBase::setupScreen();

	//Screen1ViewBase::setupScreen();

	// Place the graph on the screen
	graph.setXY(20, 20);

	// Set the outer dimensions and color of the graph
	graph.setup(440, 200, Color::getColorFrom24BitRGB(0xFF, 0, 0));

	// Set the range for the x and y axis of the graph. That is
	// the max and min x/y value that can be displayed inside the
	// dimension of the graph.
	graph.setRange(0, 50, 0, 200);

	// Set the line width in pixels
	graph.setLineWidth(3);

	add(graph);


}

 

void Screen1View::handleTickEvent()
{
	// Number of ticks between inserting a point in the graph
	int interval = 5;

	tickCounter++;

	if (tickCounter % interval == 0)
	{
		// Insert a point in the graph.
		// The Y value is a random number in the y range of the graph.
		graph.addValue(tickCounter / interval, tickCounter);  // randomNumberBetween(graph.getRangeBottom(), graph.getRangeTop()
	}

	if (tickCounter == 37 * interval)
	{
		// Change the range of the Y axis
	//	graph.setRange(0, 50, 0, 400);
	//	graph.invalidate();
	}

	if (tickCounter == 50 * interval)
	{
		// Reset the graph and start over
	//	graph.setRange(0, 50, 0, 200);
	//	graph.setLineWidth(2);
	//	graph.clear();
	//	graph.invalidate();

	//	tickCounter = 0;
	}
}

执行的界面图:

TOUCHGFX CANVAS WIDGET (划线)

 

相关标签: TOUCHGFX