4
$\begingroup$

I wanna draw a picture like this enter image description here

This is my current work,First get the texture of picture

text = "不
  上
  班
  你
  咬
  我
  啊";
textimg = 
  Style[text, 70] // 
   Rasterize[#, "Image", Background -> Transparent, 
     ImageSize -> Large] &;
alphaback = 
 SetAlphaChannel[textimg, Binarize[textimg, 0.99] // ColorNegate]

enter image description here

img=ParametricPlot3D[{Cos[\[Theta]], Sin[\[Theta]], z}, {\[Theta], 0, 
  2 \[Pi]}, {z, 0, 0.5}, Mesh -> None, Boxed -> False, Axes -> False, 
 Background -> White, PlotStyle -> {Texture[alphaback]}, 
 TextureCoordinateFunction -> ({#1, #3} &), 
 TextureCoordinateScaling -> False]//Image

enter image description here

Get the shadow

shadow = ImageReflect[img, Top -> Bottom] // MeanFilter[#, 15] &

enter image description here

Then the result is

ImageAssemble[
 List /@ ConformImages[{img // ImageCrop, shadow}, {Max, Min}]]

enter image description here

How bad the work it is!And my import quetion is how can I control the parameter to attach the texture to the ring normally.Could anybody have a try to draw this picture?

$\endgroup$
  • $\begingroup$ Try giving {#4, #5} & (or the reverse) as the TextureCoordinateFunction. $\endgroup$ – J. M. will be back soon Dec 9 '15 at 22:39
  • $\begingroup$ @J.M. Thanks for your comment.But the change have doesn't work~ $\endgroup$ – yode Dec 10 '15 at 6:05
4
+50
$\begingroup$

To answer your question "how can I control the parameter to attach the texture to the ring?" - well it takes a bit of trial and error. There is some documentation on the TextureCoordinateFunction, and we can work the rest out ourselves.

We want the horizontal and vertical directions of the image to go with the z axis and the angular coordinate. These correspond to the two arguments of the parametric plot. Also, you definitely want to set TextureCoordinateScaling to True.

textimg = Import["http://i.stack.imgur.com/EBrNt.png"];
ParametricPlot3D[{Cos[θ], Sin[θ], z}, {θ, 
   0, 2 π}, {z, 0, 0.5}, Mesh -> None, Boxed -> False, 
  Axes -> False, Background -> White, PlotStyle -> {Texture[textimg]},
   TextureCoordinateFunction -> ({#5, #4} &), 
  TextureCoordinateScaling -> True]

Next I try to get the object oriented properly, I do this with my mouse, then I have this function to get the viewpoint I want,

viewpoint[graphics_] := 
 FilterRules[{AbsoluteOptions[graphics]}, {ViewPoint, ViewVertical, 
   ViewCenter}]

I rotate the image by hand, apply this function and get a viewpoint, so that in the future it always comes out right. I get this image now

enter image description here

But I want the characters to only show up on part of the circle, so I adjust the range of θ values to between $3\pi/5$ and $6\pi/5$

Here's what I came up with in the end, after adding in a couple circles for the ring, and the shadow

textimg = Import["http://i.stack.imgur.com/EBrNt.png"];

Module[{R = 1.4, innerring, outerring, textring, viewpoint, baseimg, 
  shadow},
 innerring = 
  ParametricPlot3D[{R Cos[θ], R Sin[θ], 0.5}, {θ,
     0, 2 π},
   Mesh -> None,
   Boxed -> False,
   Axes -> False,
   Background -> White,
   PlotStyle -> Black];
 outerring = 
  ParametricPlot3D[{R Cos[θ], R Sin[θ], 
    0.0}, {θ, -5 π/8, 2 π/5},
   PlotStyle -> Black];
 textring = 
  ParametricPlot3D[{R Cos[θ], R Sin[θ], z}, {θ, 
    3 π/5, 6 π/5}, {z, 0, 0.5}, Mesh -> None,
   PlotStyle -> {Texture[textimg]},
   TextureCoordinateFunction -> ({#5, #4} &),
   TextureCoordinateScaling -> True];
 viewpoint = {ViewCenter -> {0.5, 0.5, 0.5}, 
   ViewPoint -> {-3.2, 0.38, 1.44}, 
   ViewVertical -> {.23, -0.89, -0.57}};
 baseimg = Show[
   innerring,
   outerring,
   textring,
   viewpoint, ImageSize -> 500, PlotRange -> {All, All, {-1, 1}}];
 shadow = ImageReflect[baseimg, Top -> Bottom]~MeanFilter~5;
 GraphicsColumn[ImageCrop /@ {baseimg, shadow}]
 ]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.