Drawing Pixels
Prev | Chapter 14. The Drawing Area Widget | Next

## Drawing Pixels

You can draw individual pixels with the two methods `Gdk::Drawable::draw_point()` and `Gdk::Drawable::draw_points()`. All drawing methods take a `Gdk::GC` as their first argument, except where noted. The other two arguments to `draw_point()` are the x coordinate (horizontal position relative to the left edge of the widget, starting at 0), and the y coordinate (vertical position relative to the top of the widget, starting at 0). `draw_points()` takes two or three arguments, either a `Gdk::Points` or a `Gdk::Point` and a size. The first is of course the `Gdk::GC`. gtkmm gives you a variety of ways to construct a `Gdk::Points`, from using a `vector<Gdk::Point>` to a simple `Gdk::Point *` and a size. So for example `draw_point()` could be used like this:

    get_window().draw_point(some_gc, 20, 20);

But a `draw_points()` is a bit more complicated and might be used like this:

    Gdk::point *points_array=new Gdk::point[2];
    points_array[0]=Gdk::point(10, 10);
    points_array[1]=Gdk::point(20, 20);
    draw_points(some_gc, points_array, 2); //One way to draw the two points.

    Gdk::points some_points(points_array, 2);
    draw_points(some_gc, some_points); //The same drawing as the line above.

Prev | Up | Next
Chapter 14. The Drawing Area Widget | Home | Drawing Lines