Tag Info

Hot answers tagged textures

21

Here's a method based on creating a MeshRegion from the text: text = Style[HoldForm @ Sum[x^2, {x, 0, 10}], 100, Bold]; graphics = First[text ~ExportString~ "PDF" ~ImportString~ "PDF"]; region = DiscretizeGraphics[graphics, MaxCellMeasure -> 5]; image = ExampleData[{"ColorTexture", "Kingwood"}]; RegionPlot[region, Frame -> False, ...

19

perhaps: timg = ImageEffect[img, {"TornFrame"}]; tr[t_] := # + {5 10^-3 Cos[20 #[[2]] + 5 t], 5 10^-3 Sin[20 #[[1]] + 5 t]} & frames = Table[ImageTransformation[timg, tr[t]], {t, Subdivide[0, 2 Pi, 40]}]; ListAnimate @ frames

14

There is a PlotMarkers option in ListPlot: img = ExampleData[{"TestImage", "Lena"}]; ListPlot[Table[{Sin[n], Sin[2 n]}, {n, 50}], PlotMarkers -> Show[img, ImageSize -> 20]]

14

image = Import["http://i.stack.imgur.com/6YRfK.jpg"]; If you want to use your f, uRange and vRange as the arguments to ParamatricPlot3D, you need to wrap each with Evaluate: f = {u, Sin[v]*(u^3 + 2 u^2 - 2 u + 2)/5, Cos[v]*(u^3 + 2 u^2 - 2 u + 2)/5}; uRange = {u, -2.3, 1.3}; vRange = {v, 0, 2 Pi}; ParametricPlot3D[Evaluate@f, Evaluate@uRange, Evaluate@...

13

I think the "ugly thing" might be because texture is interpolated on triangles (demonstrated after), and a quadrangle is only divided into 2 triangles - up-left and down-right. So to solve the problem, we just need a triangulation network with much higher resolution. One way is to use ParametricPlot: ParametricPlot[ Evaluate[tr@{u, v}], {u, 0,...

13

This method seems to work quite well. Instead of changing the positions randomly, I rotate each vertex around in a small circle centered at each original vertex position. Every vertex starts at a randomly assigned phase so the polygons are not all in sync: img = ExampleData[{"TestImage", "House"}]; mesh = TriangulateMesh[Rectangle[{0, 0}, ...

12

I don't think you can control the interpolation used by Texture. One option might be to embed the image as a Raster primitive instead. Show[ParametricPlot[{20 + 1.4 x - 40 y, x}, {x, 0, 200}, {y, 0, 1}, BoundaryStyle -> Directive[Purple, Thick], PlotRange -> {{0, 201}, {0, 144}}, Prolog -> {Raster @ Reverse @ ImageData @ a}]] Zoomed in:

12

Perhaps something like this? p = Plot[x^3/9, {x, -3, 3}, PlotStyle -> Thickness[0.01], Filling -> Axis, AspectRatio -> 1, ImageSize -> 500, BaseStyle -> {FontFamily -> "Calibri", 30}, AxesStyle -> Thick]; With[{k = 3}, SphericalPlot3D[1, {theta, 0, Pi}, {phi, 0, 2 Pi}, Mesh -> None, Boxed -> False, Axes -> False, ...

11

It sounds like you might like to use a stereographic projection. xy[ϕ_, λ_] := 2 Tan[(π - ϕ)/2] {Cos[λ], Sin[λ]}; Here is a cubic with a free parameter (for fun): cubic[{x_, y_}, b_] := y^3 - b x y + 4 x^3; For the sphere, use SphericalPlot3D of course. Although you could resort to ParametricPlot3D for the cubic curve, it's automatic and much simpler to ...

11

You can set Texture before each polygon t = ImageResize[ExampleData@#, {100, 100}] & /@ ExampleData["ColorTexture"][[;; 6]]; vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; coords = {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}}, {{1, 1, 0}, {0, 1, 0}, {0,...

11

In general, I don't think it's possible to use Texture directly with the built-in primitives such as Sphere and Cylinder. See also Texture mapping and resizing a sphere primitive in Mathematica. So you have to write your own replacement for those primitives. Since you specifically mentioned the Cylinder, I added the ability to handle Texture to my answer ...

10

For some reason those lines are created during the rasterization of the thing inside Texture: Rasterize[ Style[ Column[{"in=" <> ToString@1, "out=" <> ToString@2}, Right, Background -> Green], Black, Bold ] ] As you can see, the lines are part of the rasterized image's background. Manually rasterizing the thing inside Texture ...

9

ImageAdd is your friend: image = Import["http://creativity103.com/collections/Graphic/rainbowbars.jpg"]; text = HoldForm @ Sum[x^2, {x, 0, 10}]; img2 = Image @ Rasterize @ Style[text, 100, Bold]; rainbow = image ~ImageResize~ ImageDimensions[img2] ~ImageAdd~ img2 With Pickett's extension for outlining: img3 = ColorNegate[img2] ~Dilation~ 2 // ...

9

Don't rasterize. I think Texture is doing its own rasterization, so you are seeing the results of a double rasterization. img = Texture[ Graphics[ Table[Disk[{j, i}, Sqrt[i]/6], {i, 25}, {j, 50}], PlotRange -> {{1, 50}, {-5, 25}}, ImageSize -> 600]]; SphericalPlot3D[1, {u, 0, Pi}, {v, 0, 2 Pi}, Mesh -> None, ...

9

The color is not quite right but the idea seems to work. Edit: much closer now. dp = DensityPlot[(x^2 + y^2) Exp[1 - x^2 - y^2], {x, -3, 3}, {y, -3, 3}, ColorFunction -> "Rainbow", PlotPoints -> 100]; sp = StreamPlot[ Evaluate[-D[(x^2 + y^2) Exp[1 - x^2 - y^2], {{x, y}}]], {x, -3, 3}, {y, -3, 3}, Frame -> None, ImageSize -> Large, ...

8

Whenever you have an object in a three-dimensional scene that needs to be displayed independently of the lighting conditions, it's a good idea to give that object a Glow. From the docs: Glow is a color component independent of simulated illumination. This is what I use in the definition of gr (last line before Show in the answer linked in the question): ...

8

The existing answers show how to perfectly generate small textures on top of the cuboids. Unfortunately, the resulting 3D scene it is quite slow when you try to rotate it (about one frame per second). I propose to use one GraphicsComplex object with only one texture (aka atlas) histogram[data_, cf_] := Module[{nx, ny}, {nx, ny} = Dimensions@data; {...

8

m_goldberg's solution jogged my memory and the problem is even a pitfall: Use Rasterize[..., "Image"] to avoid double rasterization Note that Rasterize[Grapphics[. . .]] is not an Image: gr2d = Graphics[Table[Disk[{j, i}, Sqrt[i]/6], {i, 25}, {j, 50}], PlotRange -> {{1, 50}, {-5, 25}}, ImageSize -> 1000]; Rasterize[gr2d] // Head Graphics ...

8

Update: In versions 12.1+ you can use the new directive PatternFilling BarChart[{5, 5}, ChartLayout -> "Stacked", ChartLegends -> SwatchLegend[{PatternFilling[{"Checkerboard", Black, LightGray}, ImageScaled[1]], PatternFilling[{"DiamondBox", LightGray, Black}, ImageScaled[1]]}, {"A", "B&...

8

You can use StreamDensityPlot (which accepts the ColorFunction option) to produce the texture: sdp = StreamDensityPlot[Evaluate[{-D[(x^2 + y^2) Exp[1 - x^2 - y^2], {{x, y}}], (x^2 + y^2) Exp[1 - x^2 - y^2]}], {x, -3, 3}, {y, -3, 3}, StreamStyle -> Black, ColorFunction -> "Rainbow", ColorFunctionScaling -> False, Frame -> False, ...

8

This is one way of doing it: pattern=Import["https://i.stack.imgur.com/l9iL8.jpg"]; Show[ ListLinePlot[PHB, PlotStyle->Directive[Red,Thickness[.007]], PlotTheme->"Detailed"], Graphics[{Texture[pattern],FilledCurve[{BezierCurve[PHB]}, VertexTextureCoordinates->Automatic]}] ]

8

Slightly changed last example from docs on GeoProjection. There are a few issues, for instance textures have different resolution. If I figure things out I'lll update the answer. But I thought this is a good start for you anyway. PolyhedronProjection[polyhedron_]:= Module[{pts3D,center,pts2D,proj,pts2Dprojected,geographics,plotrange,pts2Dscaled,rescale}, ...

7

A quick and dirty way to do this is to pad the image with pixels of some inoffensive color, so that the actual meaningful part of the image gets mapped to a smaller portion of the sphere: image = Import["ExampleData/ocelot.jpg"]; {width, height} = ImageMeasurements[image, "Dimensions"]; image = ImagePad[image, {{2 width, 2 width}, {height, height}}, White]; ...

7

Using Simon Woods' shadow package this is easy: text = Style[HoldForm@Sum[x^2, {x, 0, 10}], 100, Bold]; image = ImageResize[Import["http://creativity103.com/collections/Graphic/rainbowbars.jpg"], ImageDimensions@Rasterize@text]; shadow[image, text] In the example above I stretched the background to fit the image of the equation. If you want to tile the ...

7

Not too hard. a = Image[Table[If[EvenQ[x + y], 1, 0], {x, 50}, {y, 50}], ImageSize -> Large]; Graphics[{Texture[a], Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}, VertexTextureCoordinates -> {{1, 0}, {0.5, 1}, {0, 0}}]}]

7

u = {x, x^3, 0}; v = {0, 0, z2}; l = (u - v) t + v; w = l /. Solve[xs xs + ys ys + (zs - 1)^2 == 1 /. Thread[{xs, ys, zs} -> l], t][[2]]; Manipulate[Show[ ParametricPlot3D[{Cos[u] Sin[v], Sin[u] Sin[v], 1 - Cos[v]}, {v, ArcCos[1 - z1], 0}, {u, 0, 2 Pi}, PlotStyle -> {Opacity[.3], FaceForm[Red, Yellow]}, Mesh -> False, ...

7

I would use ParametricPlot[] for this: tex = Import["https://i.stack.imgur.com/kbuF9.jpg"] ParametricPlot[{t x, t Piecewise[{{Exp[-1/(1 - x^2)], Abs[x] < 1}, {0, Abs[x] >= 1}}]}, {t, 0, 1}, {x, -2, 2}, AspectRatio -> 1/GoldenRatio, Axes -> None, PlotStyle -> {Opacity[1], Texture[tex]}, ...

7

This happens because texturing is done triangle by triangle. Polygons with more sides are broken down into triangles, and each triangle is textured individually. I believe your example is effectively equivalent to pic = ExampleData[{"TestImage", "Mandrill"}]; Graphics[{Texture[pic], EdgeForm[Black], Polygon[{{0, 0}, {1, 0}, {2, 2}}, ...

7

Note first : it is recommended to read this answer after the two other ones (from Szabolcs and matheorem) Here is a tool intended to explore how VertexTextureCoordinates works. The texture is the image : The evaluation of the code at the end of the answer returns the following : A1,A2,A3 ..., B1,B2,B3 can be independently moved with the mouse (...

7

Rahul is correct in his comment. To map a texture to an object, you use VertexTextureCoordinates to specify where the texture is glued to the object. The problem is, that those few points are not enough because you need a color for every single position inside your polygon. When you know the coordinates of your polygon that are mapped to the texture corners,...

Only top voted, non community-wiki answers of a minimum length are eligible