graphicbase.h

来自「采用拉格朗日和泰勒展开的方法对SinX进行数值的函数拟合。本代码用VC++ .n」· C头文件 代码 · 共 90 行

H
90
字号
#pragma once

namespace GP{
	using namespace System::Drawing;
	ref class Canvus
	{
	public:
		int  picWidth;
		int  picHeight;
		System::Drawing::Point ct;
		double yscale;
		double xscale;
	public:
		Canvus(int w,int h,Point c,double xs,double ys)
		{
			picWidth=w;
			picHeight=h;
			ct=c;
			xscale=xs;
			yscale=ys;
		}
		//int xtoX(double x)
		//{
		//	double X=(x*this->xscale)+this->ct.X;
		//	return X;
		//}
		//int ytoY(double y)
		//{
		//	double Y=(y*this->yscale)+this->ct.Y;
		//	return Y;
		//}
		double Xtox(int X)
		{
			double x=(X-this->ct.X)/this->xscale;
			return x;
		}
		double Ytoy(int Y)
		{
			double y=(this->ct.Y-Y)/this->yscale;
			return y;
		}

	};

	ref class GraphicPoint
	{
	public:
		static GraphicPoint^ From(double x,double y,Canvus^ cvs)
		{
			GraphicPoint^ g=gcnew GraphicPoint();
			g->x=x; g->y=y;
			g->cvs=cvs;
			return g;
		}
	public:

		double x;
		double y;
		Canvus ^ cvs;
	public:
		int  X()
		{
			double t=cvs->ct.X+x*cvs->xscale;
			return t;
		}
		int  Y()
		{	
			double t=cvs->ct.Y-y*cvs->yscale;
			return t;
		}


		Point P()
		{
			Point p=Point(X(),Y());
			return p;
		}
		void Set_xy(int X,int Y)
		{
			x=(X-cvs->ct.X)/cvs->xscale;
			y=(cvs->ct.Y-Y)/cvs->yscale;
		}
		void Set_xy(Point P )
		{
			x=(P.X-cvs->ct.X)/cvs->xscale;
			y=(cvs->ct.Y-P.Y)/cvs->yscale;
		}

	};
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?