Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. texturedShape[img_, shape_] :=
  2. Module[{g, p, ar, i}, g = Graphics[shape, PlotRangePadding -> 0];
  3. p = Polygon[AbsoluteOptions[g, PlotRange][[1, 2]] /.
  4. {{l_, r_}, {b_, t_}} :> {{l, b}, {l, t}, {r, t}, {r, b}},
  5. VertexTextureCoordinates -> {{0, 0}, {0, 1}, {1, 1}, {1, 0}}];
  6. ar = AbsoluteOptions[g, AspectRatio][[1, 2]];
  7. i = SetAlphaChannel[img, ColorNegate@Rasterize[g, ImageSize -> ImageDimensions@img]];
  8. {Texture[ImageData@i], p}]
  9.  
  10. With[{
  11. rect = Rectangle[{0, 0}, {2, 1}, RoundingRadius -> 0.2],
  12. tex = LinearGradientImage[{Top, Bottom} -> {Red, White}, {200, 100}]},
  13. Graphics[{
  14. (* inside *) texturedShape[tex, rect],
  15. (* outline *) FaceForm[None], EdgeForm[{Thickness[0.02], Black}], rect}]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement