2 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
source | link

Using a tweaked version of my answer herehere and a graphics expression which draws the rectangle outline separately:

texturedShape[img_, shape_] := 
 Module[{g, p, ar, i}, g = Graphics[shape, PlotRangePadding -> 0];
  p = Polygon[AbsoluteOptions[g, PlotRange][[1, 2]] /.
    {{l_, r_}, {b_, t_}} :> {{l, b}, {l, t}, {r, t}, {r, b}},
    VertexTextureCoordinates -> {{0, 0}, {0, 1}, {1, 1}, {1, 0}}];
  ar = AbsoluteOptions[g, AspectRatio][[1, 2]];
  i = SetAlphaChannel[img, ColorNegate@Rasterize[g, ImageSize -> ImageDimensions@img]];
  {Texture[ImageData@i], p}]

With[{
  rect = Rectangle[{0, 0}, {2, 1}, RoundingRadius -> 0.2],
  tex = LinearGradientImage[{Top, Bottom} -> {Red, White}, {200, 100}]},
 Graphics[{
   (* inside  *) texturedShape[tex, rect],
   (* outline *) FaceForm[None], EdgeForm[{Thickness[0.02], Black}], rect}]]

enter image description here

Using a tweaked version of my answer here and a graphics expression which draws the rectangle outline separately:

texturedShape[img_, shape_] := 
 Module[{g, p, ar, i}, g = Graphics[shape, PlotRangePadding -> 0];
  p = Polygon[AbsoluteOptions[g, PlotRange][[1, 2]] /.
    {{l_, r_}, {b_, t_}} :> {{l, b}, {l, t}, {r, t}, {r, b}},
    VertexTextureCoordinates -> {{0, 0}, {0, 1}, {1, 1}, {1, 0}}];
  ar = AbsoluteOptions[g, AspectRatio][[1, 2]];
  i = SetAlphaChannel[img, ColorNegate@Rasterize[g, ImageSize -> ImageDimensions@img]];
  {Texture[ImageData@i], p}]

With[{
  rect = Rectangle[{0, 0}, {2, 1}, RoundingRadius -> 0.2],
  tex = LinearGradientImage[{Top, Bottom} -> {Red, White}, {200, 100}]},
 Graphics[{
   (* inside  *) texturedShape[tex, rect],
   (* outline *) FaceForm[None], EdgeForm[{Thickness[0.02], Black}], rect}]]

enter image description here

Using a tweaked version of my answer here and a graphics expression which draws the rectangle outline separately:

texturedShape[img_, shape_] := 
 Module[{g, p, ar, i}, g = Graphics[shape, PlotRangePadding -> 0];
  p = Polygon[AbsoluteOptions[g, PlotRange][[1, 2]] /.
    {{l_, r_}, {b_, t_}} :> {{l, b}, {l, t}, {r, t}, {r, b}},
    VertexTextureCoordinates -> {{0, 0}, {0, 1}, {1, 1}, {1, 0}}];
  ar = AbsoluteOptions[g, AspectRatio][[1, 2]];
  i = SetAlphaChannel[img, ColorNegate@Rasterize[g, ImageSize -> ImageDimensions@img]];
  {Texture[ImageData@i], p}]

With[{
  rect = Rectangle[{0, 0}, {2, 1}, RoundingRadius -> 0.2],
  tex = LinearGradientImage[{Top, Bottom} -> {Red, White}, {200, 100}]},
 Graphics[{
   (* inside  *) texturedShape[tex, rect],
   (* outline *) FaceForm[None], EdgeForm[{Thickness[0.02], Black}], rect}]]

enter image description here

1
source | link

Using a tweaked version of my answer here and a graphics expression which draws the rectangle outline separately:

texturedShape[img_, shape_] := 
 Module[{g, p, ar, i}, g = Graphics[shape, PlotRangePadding -> 0];
  p = Polygon[AbsoluteOptions[g, PlotRange][[1, 2]] /.
    {{l_, r_}, {b_, t_}} :> {{l, b}, {l, t}, {r, t}, {r, b}},
    VertexTextureCoordinates -> {{0, 0}, {0, 1}, {1, 1}, {1, 0}}];
  ar = AbsoluteOptions[g, AspectRatio][[1, 2]];
  i = SetAlphaChannel[img, ColorNegate@Rasterize[g, ImageSize -> ImageDimensions@img]];
  {Texture[ImageData@i], p}]

With[{
  rect = Rectangle[{0, 0}, {2, 1}, RoundingRadius -> 0.2],
  tex = LinearGradientImage[{Top, Bottom} -> {Red, White}, {200, 100}]},
 Graphics[{
   (* inside  *) texturedShape[tex, rect],
   (* outline *) FaceForm[None], EdgeForm[{Thickness[0.02], Black}], rect}]]

enter image description here