改善直线绘图:追逐起点
程序代码:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
bool Drawing;
TPoint Origin;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
Drawing=true;
Canvas->MoveTo(X,Y);
Origin=Piont(X,Y);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{ Canvas->MoveTo(Origin.x,Origin.y);
Canvas->LineTo(X,Y);
Drawing=false;
}
//---------------------------------------------------------------------------
错误提示:
[C++ Error] Unit1.cpp(25): E2268 Call to undefined function 'Piont'
[C++ Error] Unit1.cpp(25): E2034 Cannot convert 'int' to 'TPoint'
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
bool Drawing;
TPoint Origin;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
Drawing=true;
Canvas->MoveTo(X,Y);
Origin=Piont(X,Y);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{ Canvas->MoveTo(Origin.x,Origin.y);
Canvas->LineTo(X,Y);
Drawing=false;
}
//---------------------------------------------------------------------------
错误提示:
[C++ Error] Unit1.cpp(25): E2268 Call to undefined function 'Piont'
[C++ Error] Unit1.cpp(25): E2034 Cannot convert 'int' to 'TPoint'
...全文
相关推荐
绘图直线C++编码
直线绘图的绘图编程 利用C++编程语言来绘制直线图像
LibreCAD实战:开源2D CAD如何轻松处理DXF/DWG图纸
在日常工程协作中,图纸文件打不开、格式不兼容、标注错乱是常见痛点,尤其是历史遗留的DXF文件。DXF作为一种公开的图形交换格式,其组码与值的配对结构决定了跨软件解析的可行性。LibreCAD作为一款基于Qt和C++11构建的开源2D CAD工具,凭借扎实的解析引擎实现了对DXF多版本及常见DWG文件的读写支持,同时保持轻量、启动快、跨平台一致性好等特点。它不仅能完成看图、绘图、标注等基础工作,还能通过命令行批处理、PDF/SVG矢量导出以及二次开发接口融入现有设计流水线,在机械配件、PCB检查、GIS数据处
C#带背景绘图,拖鼠标画矩形和直线
C#的pictureBox上绘图,带背景,有橡皮筋效果,实现画矩形和直线,图片可保存。 开发环境:Visual Studio 2012(.net framework 4.5)
直线绘图工具
初学之代码 直线绘图工具。可能是初学者的小帮助。
verlin:垂直线绘图。-matlab开发
在符号图中使用垂直线真的很困难,因此我创建了一个函数来绘制它。 在我的代码中,一个人可以确定线的 x 点、起点和终点。


