Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How to get sharp pixel boundaries with Texture? I'd like to have only black/white in the example below, no gray.

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

enter image description here

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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}}]}]

textured triangle

share|improve this answer
    
That's much better, thank you. On a PDF export, still have gray transitions, however. Do you know if this is avoidable? –  Frank May 18 '13 at 16:29
    
Ah, that I don't know about. Could you mention what version and OS are you on, to help with the diagnosis? –  J. M. May 18 '13 at 16:33
1  
Mathematica 9.0.1.0 on Windows 8, 64-bit –  Frank May 18 '13 at 16:34
    
Hmm... do you also get the gray transitions if you export a as a PDF? –  J. M. May 18 '13 at 16:36
1  
@bobthechemist: For B/W, yes, although I have not measured if now either black or white pixels appear larger. On color images, it does not work. I think, it's a fundamental issue with the way Texture is implemented. I'd love it if there was an option like Resampling -> "Nearest" in ImageResize for Texture. –  Frank May 18 '13 at 17:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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