void make_permute(int pos) { int i,j; if(pos==n) { for(i=0;i<n;i++) { printf("%d",arr[i]); } printf("\n"); } else { for(j=1;j<=n;j++) { if(no_repeat(pos,j)==1) { arr[pos]=j; make_permute(pos+1); } } } }
/** * ccss_cairo_background_fill: * * This function requires that a closed path exists, which is filled with * the background. The path is not modified. **/ void ccss_cairo_background_fill (ccss_background_attachment_t const *bg_attachment, ccss_color_t const *bg_color, ccss_background_image_t const *bg_image, ccss_background_position_t const *bg_position, ccss_background_repeat_t const *bg_repeat, ccss_background_size_t const *bg_size, cairo_t *cr, double x, double y, double width, double height) { cairo_status_t status; double dx; double dy; /* FIXME, we need "transparent" color g_return_if_fail (bg_color); */ cairo_save (cr); if (bg_color && bg_color->base.state == CCSS_PROPERTY_STATE_SET) { cairo_set_source_rgba (cr, bg_color->red, bg_color->green, bg_color->blue, bg_color->alpha); cairo_fill_preserve (cr); } if (bg_image && bg_image->base.state == CCSS_PROPERTY_STATE_SET) { ccss_cairo_image_t const *image; double tile_width; double tile_height; double xoff; double yoff; image = ccss_cairo_image_cache_fetch_image (bg_image->uri); g_return_if_fail (image); tile_width = bg_size ? ccss_position_get_hsize (&bg_size->width, width, height, image->width, image->height) : image->width; tile_height = bg_size ? ccss_position_get_vsize (&bg_size->height, width, height, image->width, image->height) : image->height; xoff = bg_position ? ccss_position_get_pos (&bg_position->hpos, width, tile_width) : 0; yoff = bg_position ? ccss_position_get_pos (&bg_position->vpos, height, tile_height) : 0; dx = tile_width / image->width; dy = tile_height / image->height; switch (bg_repeat ? bg_repeat->repeat : CCSS_BACKGROUND_REPEAT) { case CCSS_BACKGROUND_REPEAT: /* Normalise offsets, we don't create an infinite * background pattern. */ xoff = fmod (xoff, tile_width) - tile_width; yoff = fmod (yoff, tile_height) - tile_height; /* FIXME: not rounding can make the background edges * blurry, but when rounding we might be 1px off. cairo_translate (cr, x + lround (xoff), y + lround (yoff)); */ cairo_translate (cr, x + xoff, y + yoff); cairo_scale (cr, dx, dy); repeat (image, cr, width / dx, height / dy, tile_width / dx, tile_height / dy); break; case CCSS_BACKGROUND_REPEAT_X: /* Normalise vertical offset, we don't create an infinite * background pattern. */ xoff = fmod (xoff, tile_width) - tile_width; /* FIXME: not rounding can make the background edges * blurry, but when rounding we might be 1px off. cairo_translate (cr, x + lround (xoff), y + lround (yoff)); */ cairo_translate (cr, x + xoff, y + yoff); cairo_scale (cr, dx, dy); repeat_x (image, cr, width / dx, height / dy, tile_width / dx, tile_height / dy); break; case CCSS_BACKGROUND_REPEAT_Y: /* Normalise horizontal offset, we don't create an infinite * background pattern. */ yoff = fmod (yoff, tile_height) - tile_height; /* FIXME: not rounding can make the background edges * blurry, but when rounding we might be 1px off. cairo_translate (cr, x + lround (xoff), y + lround (yoff)); */ cairo_translate (cr, x + xoff, y + yoff); cairo_scale (cr, dx, dy); repeat_y (image, cr, width / dx, height / dy, tile_width / dx, tile_height / dy); break; case CCSS_BACKGROUND_NO_REPEAT: /* FIXME: not rounding can make the background edges * blurry, but when rounding we might be 1px off. cairo_translate (cr, x + lround (xoff), y + lround (yoff)); */ cairo_translate (cr, x + xoff, y + yoff); cairo_scale (cr, dx, dy); no_repeat (image, cr, width / dx, height / dy); break; default: g_assert_not_reached (); /* Need some code here when building w/o assertions. */ break; } status = cairo_status (cr); if (status != CAIRO_STATUS_SUCCESS) { g_warning ("%s", cairo_status_to_string (status)); } } cairo_restore (cr); }