forked from cyberbotics/webots
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplay.cpp
More file actions
115 lines (90 loc) · 3.35 KB
/
Display.cpp
File metadata and controls
115 lines (90 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright 1996-2023 Cyberbotics Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#define WB_ALLOW_MIXING_C_AND_CPP_API
#include <webots/display.h>
#include <webots/Camera.hpp>
#include <webots/Display.hpp>
using namespace std;
using namespace webots;
int Display::getWidth() const {
return wb_display_get_width(getTag());
}
int Display::getHeight() const {
return wb_display_get_height(getTag());
}
void Display::setColor(int color) {
wb_display_set_color(getTag(), color);
}
void Display::setAlpha(double alpha) {
wb_display_set_alpha(getTag(), alpha);
}
void Display::setOpacity(double opacity) {
wb_display_set_opacity(getTag(), opacity);
}
void Display::setFont(const std::string &font, int size, bool antiAliasing) {
wb_display_set_font(getTag(), font.c_str(), size, antiAliasing);
}
void Display::attachCamera(Camera *camera) {
wb_display_attach_camera(getTag(), camera->getTag());
}
void Display::detachCamera() {
wb_display_detach_camera(getTag());
}
void Display::drawPixel(int x, int y) {
wb_display_draw_pixel(getTag(), x, y);
}
void Display::drawLine(int x1, int y1, int x2, int y2) {
wb_display_draw_line(getTag(), x1, y1, x2, y2);
}
void Display::drawRectangle(int x, int y, int width, int height) {
wb_display_draw_rectangle(getTag(), x, y, width, height);
}
void Display::drawOval(int cx, int cy, int a, int b) {
wb_display_draw_oval(getTag(), cx, cy, a, b);
}
void Display::drawPolygon(const int *x, const int *y, int size) {
wb_display_draw_polygon(getTag(), x, y, size);
}
void Display::drawText(const std::string &txt, int x, int y) {
wb_display_draw_text(getTag(), txt.c_str(), x, y);
}
void Display::fillRectangle(int x, int y, int width, int height) {
wb_display_fill_rectangle(getTag(), x, y, width, height);
}
void Display::fillOval(int cx, int cy, int a, int b) {
wb_display_fill_oval(getTag(), cx, cy, a, b);
}
void Display::fillPolygon(const int *x, const int *y, int size) {
wb_display_fill_polygon(getTag(), x, y, size);
}
ImageRef *Display::imageCopy(int x, int y, int width, int height) const {
return new ImageRef(wb_display_image_copy(getTag(), x, y, width, height));
}
ImageRef *Display::imageNew(int width, int height, const void *data, int format) const {
return new ImageRef(wb_display_image_new(getTag(), width, height, data, format));
}
void Display::imagePaste(ImageRef *ir, int x, int y, bool blend) {
wb_display_image_paste(getTag(), ir->getImageRef(), x, y, blend);
}
ImageRef *Display::imageLoad(const std::string &filename) const {
return new ImageRef(wb_display_image_load(getTag(), filename.c_str()));
}
void Display::imageSave(ImageRef *ir, const std::string &filename) const {
wb_display_image_save(getTag(), ir ? ir->getImageRef() : NULL, filename.c_str());
}
void Display::imageDelete(ImageRef *ir) const {
wb_display_image_delete(getTag(), ir->getImageRef());
delete ir;
ir = 0;
}