Holger
1
As far as I can find it, the 3 part of “Paths in GTK” has not yet been released.
Therefore here is my question:
With which function I can render the following triangle from Part 1:
builder = gsk_path_builder_new ();
gsk_path_builder_move_to (builder, 0, 50);
gsk_path_builder_line_to (builder, 100, 50);
gsk_path_builder_line_to (builder, 50, 0);
gsk_path_builder_close (builder);
path = gsk_path_builder_free_to_path (builder);
So far, I could only use the function gtk_snapshot_append_fill (...)
find. But these then fills the whole area.
Holger
2
After some experimentation, I came on it myself.
void graphic_snapshot(GtkSnapshot *snapshot,
const GdkRGBA *foreground,
const GdkRGBA *background,
double width,
double height)
{
gtk_snapshot_append_color(snapshot,
background,
&GRAPHENE_RECT_INIT (0, 0, width, height));
double size;
size = MIN(width,height);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT(0.0,0.0));
gtk_snapshot_scale (snapshot, size, size);
GskPathBuilder *builder;
GskPath *path;
GskStroke *stroke;
stroke = gsk_stroke_new(0.01);
builder = gsk_path_builder_new ();
gsk_path_builder_move_to (builder, 0.1, 0.1);
gsk_path_builder_line_to (builder, 0.1, 0.9);
gsk_path_builder_line_to (builder, 0.9, 0.5);
gsk_path_builder_close (builder);
path = gsk_path_builder_free_to_path (builder);
gtk_snapshot_append_stroke (snapshot, path, stroke, foreground);
gsk_path_unref(path);
gsk_stroke_free(stroke);
}
The question that remains for me is now:
Do the parameters always have to be =< 1?
ebassi
(Emmanuele Bassi)
4
You called gtk_snapshot_scale()
and normalised the coordinate space in the [0, 1] range (0 = 0, 1 = size) on both axes.