Question

I want to print a text on a cylinder. The result should look like a can of coca cola.

I tried it similar to an example in the mathematica documentation: http://reference.wolfram.com/mathematica/ref/Texture.html > Scope > Texture Specification > Text Example

text = Style["Coca Cola", 128];
Graphics3D[{
   Texture[text],
   Red, Cylinder[{{0, 0, 0}, {0, 0, h}}, radius[h], VertexTextureCoordinates -> {...}],

}]

But the Cylinder doesn't recognize the VertexTextureCoordinates-option. What am I doing wrong?

Was it helpful?

Solution

You are doing nothing wrong, it just does not work with built-in primitives afaik. But you can surely write your own Cylinder function which is build from polygons where you can apply any texture you like:

text = Style["Cook a Cola", 128, White, Background -> Red];
Graphics3D[
 {Texture[text],
  Red, EdgeForm[],
  With[{dphi = Pi/35},
   Table[
    Polygon[{{Cos[phi], Sin[phi], 0}, {Cos[phi + dphi], 
       Sin[phi + dphi], 0}, {Cos[phi + dphi], Sin[phi + dphi], 
       1}, {Cos[phi], Sin[phi], 1}}, 
     VertexTextureCoordinates -> {{phi/Pi, 0}, {(phi + dphi)/Pi, 
        0}, {(phi + dphi)/Pi, 1}
       , {phi/Pi, 1}}],
    {phi, 0, 2 Pi - dphi, dphi}
    ]
   ]
  }
 ]

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top