-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cpp
More file actions
24 lines (22 loc) · 883 Bytes
/
Copy pathutils.cpp
File metadata and controls
24 lines (22 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "utils.h"
#include <cmath>
// 绘制菱形函数
void drawDiamond(sf::RenderTarget& target, float x, float y, float size, const sf::Color& color) {
sf::ConvexShape diamond;
diamond.setPointCount(4);
diamond.setPoint(0, sf::Vector2f(0, -size / 2));
diamond.setPoint(1, sf::Vector2f(size / 2, 0));
diamond.setPoint(2, sf::Vector2f(0, size / 2));
diamond.setPoint(3, sf::Vector2f(-size / 2, 0));
diamond.setFillColor(color);
diamond.setPosition(x, y);
target.draw(diamond);
}
// 创建带圆角的矩形(简化版)
sf::RectangleShape createRoundedRect(float width, float height, float radius, const sf::Color& color) {
sf::RectangleShape rect(sf::Vector2f(width, height));
rect.setFillColor(color);
// 注意:SFML本身不支持圆角矩形,这里用普通矩形代替
// 如果需要真正的圆角,需要使用顶点数组或纹理
return rect;
}