#include <xtd/drawing/basic_colors>
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/random>
 
 
namespace draw_point_example {
  class form1 : 
public form {
 
    struct colored_point {
      int width = 0;
      
      bool operator ==(
const colored_point& rhs) 
const noexcept {
return location == rhs.location && 
color == rhs.color && width == rhs.width;}
 
    };
    
  public:
    form1() {
      text("Draw point example");
      
      generate_colored_points_timer.interval(200_ms);
      generate_colored_points_timer.tick += 
event_handler {*
this, &form1::generate_colored_points};
 
      generate_colored_points_timer.start();
    }
    
  protected:
      form::on_paint(e);
      e.graphics().clear(color::black);
      for (auto colored_point : colored_points)
        e.graphics().draw_point(
pen(colored_point.color, as<float>(colored_point.width)), colored_point.location);
 
    }
    
  private:
    void generate_colored_points() {
      static auto colors = basic_colors::get_colors();
 
      colored_points.resize(
random.
next(height() * width() / 800, height() * width() / 400));
 
      for (auto& colored_point : colored_points)
      invalidate();
    }
    
    timer generate_colored_points_timer;
 
  };
}
 
auto main() -> int {
  application::run(draw_point_example::form1 {});
}
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:71
 
Represents an ARGB (alpha, red, green, blue) color.
Definition color.hpp:49
 
colors for all the standard colors. This class cannot be inherited.
Definition colors.hpp:26
 
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition pen.hpp:35
 
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.hpp:54
 
Represents a pseudo-random number generator, a device that produces a sequence of numbers that meet c...
Definition random.hpp:40
 
virtual int32 next() const
Returns a nonnegative random number.
 
generic_event_handler<> event_handler
Represents the method that will handle an event that has no event data.
Definition event_handler.hpp:32
 
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:15
 
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition brush.hpp:18
 
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10