3
$\begingroup$

I know about PolarPlot, and I've found a few questions here about wrapping text, but is there a way to do this with an image similarly to how Photoshop's polar-coordinate filter works?

I've looked in the Mathematica documentation for image filters, but none appear to do what I need.

$\endgroup$
8
  • $\begingroup$ For those of us who know Mathematica and don't know Photoshop, how does PhotoShop's polar-coordinate filter work? My first guess would be to start at TextureCoordinateFunction.... $\endgroup$ Commented May 28 at 17:11
  • $\begingroup$ See: mathematica.stackexchange.com/questions/157145/… $\endgroup$ Commented May 28 at 17:24
  • 1
    $\begingroup$ You didn't provide much information, so I don't know if this qualifies as an answer, but for example: ParametricPlot[{r Cos[t], r Sin[t]}, {t, 0, 2 Pi}, {r, 0, 3}, PlotStyle -> Texture[ImageReflect[Rasterize["hello world"]]]]. $\endgroup$ Commented May 28 at 17:56
  • $\begingroup$ @MichaelE2 I don't know either, since I don't use PhotoShop. I just found a lot of results about doing that in PhotoShop when I googled. $\endgroup$ Commented May 29 at 4:32
  • $\begingroup$ @DavidG.Stork Thanks for your answer. Not quite what I'm looking for, but it's nice that that can be done. $\endgroup$ Commented May 29 at 4:32

2 Answers 2

3
$\begingroup$

This is just an alternate that avoids using TextCoordinateFunction, since the default texture behavior is sufficient in this case.

Given an image,

textureimage = ExampleData[{"TestImage", "Marruecos"}] 

enter image description here

we can use ParametricPlot with two parameters, causing a 2D texture to fill the space in "alignment" with the two parameters:

ParametricPlot[ {r Cos[t], r Sin[t]}, {t, 0, 2 Pi}, {r, 0, 1}, PlotStyle -> {Opacity[1], Texture[textureimage]}, BoundaryStyle -> None, Frame -> None, Axes -> False] 

enter image description here

To get a different orientation of the texture, you have several options:

  • tweak the parameter specifications

    ParametricPlot[ {r Cos[t], r Sin[t]}, {t, 0, 2 Pi}, {r, 0, -1}, PlotStyle -> {Opacity[1], Texture[textureimage]}, BoundaryStyle -> None, Frame -> None, Axes -> False] 

enter image description here

  • reflect the image used as the texture

    ParametricPlot[ {r Cos[t], r Sin[t]}, {t, 0, 2 Pi}, {r, 0, 1}, PlotStyle -> {Opacity[1], Texture[ImageReflect[textureimage]]}, BoundaryStyle -> None, Frame -> None, Axes -> False] 

enter image description here

  • specify a TextureCoordinateFunction as shown by azerbajdzan

The texture also works with an annulus

ParametricPlot[ {r Cos[t], r Sin[t]}, {t, 0, 2 Pi}, {r, 1, 3}, PlotStyle -> {Opacity[1], Texture[ImageReflect[textureimage]]}, BoundaryStyle -> None, Frame -> None, Axes -> False] 

enter image description here

$\endgroup$
1
  • $\begingroup$ This is perfect, thank you! $\endgroup$ Commented Jun 1 at 7:18
12
$\begingroup$
im = ExampleData[{"ColorTexture", "Roof"}] ParametricPlot[{r Cos[t], r Sin[t]}, {t, 0, 2 Pi}, {r, 0, 1}, PlotRange -> All, PlotStyle -> {Opacity[1], Texture[im]}, TextureCoordinateFunction -> ({#3, -#4} &), BoundaryStyle -> None, Axes -> False, Frame -> False] ParametricPlot[{r Cos[t], r Sin[t]}, {t, 0, 2 Pi}, {r, 0.2, 1.2}, PlotRange -> All, PlotStyle -> {Opacity[1], Texture[im]}, TextureCoordinateFunction -> ({#3, -#4} &), BoundaryStyle -> None, Axes -> False, Frame -> False] 

enter image description here

Multiple wrapping (6 #3).

ParametricPlot[{r Cos[t], r Sin[t]}, {t, 0, 2 Pi}, {r, 0.2, 1.2}, PlotRange -> All, PlotStyle -> {Opacity[1], Texture[im]}, TextureCoordinateFunction -> ({6 #3, -#4} &), BoundaryStyle -> None, Axes -> False, Frame -> False] 

enter image description here

$\endgroup$
2
  • $\begingroup$ Thank you! This looks really nice. It's somewhat more complicated than lericr's suggestion, and it maps the bottom of the image to the upper bound of r rather than the other way around, but I do like that you provided examples for both a disc and an annulus. $\endgroup$ Commented May 29 at 4:39
  • $\begingroup$ @Rain You can manipulate the orientation of wrapping by TextureCoordinateFunction, you can choose between {#3, #4}, {-#3, #4}, {#3, -#4}, {-#3, -#4}... and similar. $\endgroup$ Commented May 29 at 9:10

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.