Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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}]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement