Since I don't speak Russian, I have replaced the names and supplemented the existing functions so that a graphic is displayed at the calculated positions.
-- snip CDrawStarView.cpp --
point calcPoint(int currentPoint, int totalPoints)
{
double theta = ((M_PI * 2) / totalPoints);
double angle = (theta * currentPoint);
const int radius = 100;
point rt;
rt.x = cos(angle);
rt.y = sin(angle);
return rt;
}
void CDrawStarView::OnDraw(CDC* pDC)
{
CDrawStarDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
point pt;
for (int i = 0; i < 12; i++) {
pt = calcPoint(i, 12);
m_bitmap_star.Draw(pDC, (int)(pt.x*m_r + m_ofs), (int)(pt.y*m_r + m_ofs));
}
}
-- /snip --
-- snip CDrawStarView.h --
#pragma once
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include "MyBitmap.h"
typedef struct { double x, y; } point;
class CDrawStarView : public CView
{
protected: CDrawStarView();
DECLARE_DYNCREATE(CDrawStarView)
public:
virtual ~CDrawStarView();
CDrawStarDoc* GetDocument() const;
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnDraw(CDC* pDC);
protected:
CMyBitmap m_bitmap_star; int m_r = 100, m_ofs = 120;
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnSize(UINT nType, int cx, int cy);
};
In order to achieve the running effect, a timer can be built in, which selects a point at regular points in time, which is left out when drawing and causes everything to be redrawn.
Since the CBitmap class unfortunately does not contain a drawing function, the class has been extended by a function with the usual code.
class CMyBitmap : public CBitmap
{
public:
CMyBitmap();
virtual ~CMyBitmap();
void Draw(CDC* pDC, int x, int y);
};