How to draw in xtd
?
#238
-
For example, I want to plot the sine wave. Please give me complete sample code. Thank you. |
Beta Was this translation helpful? Give feedback.
Answered by
gammasoft71
Oct 6, 2023
Replies: 1 comment 3 replies
-
The following example shows how to draw a sine wave on a form. #include <xtd/drawing/pen>
#include <xtd/forms/application>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::forms;
auto main()->int {
const auto sins = std::vector<point> {{10, 110}, {20, 148}, {30, 181}, {40, 202}, {50, 210}, {60, 202}, {70, 181}, {80, 148}, {90, 110}, {100, 72}, {110, 39}, {120, 18}, {130, 10}, {140, 18}, {150, 39}, {160, 72}, {170, 110}, {180, 148}, {190, 181}, {200, 202}, {210, 210}, {220, 202}, {230, 181}, {240, 148}, {250, 110}, {260, 72}, {270, 39}, {280, 18}, {290, 10}, {300, 18}, {310, 39}, {320, 72}};
auto form1 = form::create("Sine wave");
form1.client_size({330, 220});
form1.paint += [&](object& sender, paint_event_args& e) {
e.graphics().draw_curve(pen(color::dodger_blue, 4), sins);
};
xtd::forms::application::run(form1);
}
|
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
gammasoft71
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following example shows how to draw a sine wave on a form.