当前位置: 首页 > news >正文

图形学实验(完整文件见上传)

CRect rect;
this->GetClientRect(rect);
pDC->Ellipse(rect);

// DDALineView.cpp : implementation of the CDDALineView class
//

#include “stdafx.h”
#include “DDALine.h”

#include “DDALineDoc.h”
#include “DDALineView.h”

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = FILE;
#endif

/
// CDDALineView

IMPLEMENT_DYNCREATE(CDDALineView, CView)

BEGIN_MESSAGE_MAP(CDDALineView, CView)
//{{AFX_MSG_MAP(CDDALineView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/
// CDDALineView construction/destruction

CDDALineView::CDDALineView()
{
// TODO: add construction code here

}

CDDALineView::~CDDALineView()
{
}

BOOL CDDALineView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return CView::PreCreateWindow(cs);

}

/
// CDDALineView drawing

void CDDALineView::OnDraw(CDC* pDC)
{
CDDALineDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}

/
// CDDALineView printing

BOOL CDDALineView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}

void CDDALineView::OnBeginPrinting(CDC* /pDC/, CPrintInfo* /pInfo/)
{
// TODO: add extra initialization before printing
}

void CDDALineView::OnEndPrinting(CDC* /pDC/, CPrintInfo* /pInfo/)
{
// TODO: add cleanup after printing
}

/
// CDDALineView diagnostics

#ifdef _DEBUG
void CDDALineView::AssertValid() const
{
CView::AssertValid();
}

void CDDALineView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}

CDDALineDoc* CDDALineView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDDALineDoc)));
return (CDDALineDoc*)m_pDocument;
}
#endif //_DEBUG

/
// CDDALineView message handlers

void CDDALineView::ddaline(CDC*pDC,int x0,int y0,int x1,int y1,COLORREF color)
{
int length,i;
double x,y,dx,dy;
length=abs(x1-x0);
if(abs(y1-y0)>length)
length=abs(y1-y0);
dx=(x1-x0)/length;
dy=(y1-y0)/length;
x=x0+0.5;y=y0+0.5;
for(i=1;i<=length;i++)
{
pDC->SetPixel((int)x,(int)y,color);
x=x+dx;y=y+dy;
}
}

void CDDALineView::OnDraw(CDC* pDC)
{
CDDALineDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
ddaline(pDC,100,100,400,100,RGB(255,0,0));
ddaline(pDC,400,100,400,400,RGB(0,255,0));
ddaline(pDC,400,400,100,400,RGB(0,0,255));
ddaline(pDC,100,400,100,100,RGB(255,255,0));
ddaline(pDC,100,100,400,400,RGB(255,0,255));
ddaline(pDC,100,400,400,100,RGB(0,255,255));
}

实验三
1.
void CMidPointCircleView::MidpointCircle(CDC pDC, int x0, int y0, int r, COLORREF color)
{
int x,y;
float d;
x=0,y=r,d=1.25-r;
CirPot(pDC,x0,y0,x,y,color);
while(x<=y)
{
if(d<0)
{
d+=2
x+3;x++;

}
else
{
d+=2*(x-y)+5;
x++;y--;
}
CirPot(pDC,x0,y0,x,y,color);
}

}

int CMidPointCircleView::CirPot(CDC *pDC, int x0, int y0, int x, int y, COLORREF color)
{
pDC->SetPixel((x0+x),(y0+y),color);
pDC->SetPixel((x0+y),(y0+x),color);
pDC->SetPixel((x0+y),(y0-x),color);
pDC->SetPixel((x0+x),(y0-y),color);
pDC->SetPixel((x0-x),(y0-y),color);
pDC->SetPixel((x0-y),(y0-x),color);
pDC->SetPixel((x0-y),(y0+x),color);
pDC->SetPixel((x0-x),(y0+y),color);
return 0;

}

void CMidPointCircleView::OnDraw(CDC* pDC)
{
CMidPointCircleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
MidpointCircle(pDC,100,100,10,RGB(255,0,0));
MidpointCircle(pDC,500,300,60,RGB(255,0,0));

}
在这里插入图片描述

http://www.lryc.cn/news/93322.html

相关文章:

  • Spark大数据处理学习笔记(3.2.1)掌握RDD算子
  • lammps初级:石墨烯、金属材料、纳米流体、热传导、多成分体系、金属、半导体材料的辐照、自建分子力场、MOFS、H2/CO2混合气体等模拟
  • 【MarkerDown】CSDN Markdown之时序图sequenceDiagram详解
  • ReentrantLock实现原理-公平锁
  • 掌握Scala数据结构(2)MAP、TUPLE、SET
  • flutter:文件系统目录、文件读写
  • 计算机提示“找不到vcruntime140.dll,无法继续执行代码可”以这样子修复
  • 深度学习pytorch实战五:基于ResNet34迁移学习的方法图像分类篇自建花数据集图像分类(5类)超详细代码
  • Rust in Action笔记 第五章 深入理解数据
  • Cocos creator实现飞机大战空中大战《战击长空》小游戏资源及代码
  • 2.4 逻辑代数的基本定理
  • 适用于 Linux 的 Windows 子系统wsl文档
  • C++特殊类的设计与类型转换
  • 如何通过关键词搜索API接口
  • 智驾域控新战争打响,谁在抢跑?
  • Android 13无源码应用去掉无资源ID的按钮
  • 【SCI征稿】中科院2区(TOP),正刊,SCIEEI双检,进化计算、模糊集和人工神经网络在数据不平衡中应用
  • Android Audio开发——AAudio基础(十五)
  • SDK接口远程调试【内网穿透】
  • Mybatis学习笔记二
  • 大屏数据可视化开源项目
  • 面试经典150题:数组/字符串合集
  • Java源文件的执行过程
  • 10个ai算法常用库java版
  • 怎么看服务器带宽大小 103.219.179.X
  • 图形编辑器开发:最基础但却复杂的选择工具
  • apk签名-signapk.jar
  • 【100个高大尚求职简历】简历模板+修改教程+行业分类简历模板 (涵盖各种行业) (简历模板+编辑指导+修改教程)
  • Nginx平滑升级版本或添加模块
  • 高阶复杂网络重建:从时间序列中重建高阶网络