Re: Sneaky bug in jgraphics_pattern_create_radial() ???


Forums > Dev > Sneaky bug in jgraphics_pattern_create_radial() ???
November 25, 2012 | 1:16 pm

Here is another example with a scaled gradient:

void mygradientbug_paint(t_mygradientbug *x, t_object *patcherview)
{
	t_jgraphics *context;
    t_jpattern *pattern;
	t_rect rect;

    context = (t_jgraphics *)patcherview_get_jgraphics(patcherview);
	jbox_get_rect_for_view((t_object *)x, patcherview, &rect);

    // transform context so that center is at [0,0] and radius is 1
    jgraphics_scale(context, rect.width/2, rect.height/2);
    jgraphics_translate(context, 1, 1);

    // draw gradient
    jgraphics_scale(context, 0.1, 1.0);

    pattern = jgraphics_pattern_create_radial(0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
    jgraphics_pattern_add_color_stop_rgba(pattern, 0.0,
                                          x->gradientcolor.red,
                                          x->gradientcolor.green,
                                          x->gradientcolor.blue,
                                          x->gradientcolor.alpha);
    jgraphics_pattern_add_color_stop_rgba(pattern, 1.0,
                                          x->bgcolor.red,
                                          x->bgcolor.green,
                                          x->bgcolor.blue,
                                          x->bgcolor.alpha);
    jgraphics_set_source(context, pattern);
    jgraphics_pattern_destroy(pattern);
    jgraphics_paint(context);
}

[attachment=209039,4687]