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

I would like to produce rounded closed polygon like in the following uggly draw. This shape will be defined by giving positions of the vertex. This will be used on sudoku grids.

enter image description here

share|improve this question
    
In its current form, your question might not receive many answers. Please take a look at the How to Ask-page and try to improve your question according to the guidance found there. This may require you to show some effort on your part in terms of attempting a solution. If you have questions about what to do or if you don't quite understand what this means, please ask for clarification using the add comment function. –  Brent.Longborough Feb 11 '13 at 10:51
    
I've changed my question to be more precise. –  projetmbc Feb 11 '13 at 11:02
add comment

1 Answer 1

up vote 5 down vote accepted

Assuming you are using the Sudoku code of question TikZ - "Zig-Zag" arrows, for example, this code is drawn in such a way that each cell is 1 unit wide, so this makes very easy to draw this kind of shapes, since the vertex will have integer units.

Moreover, if you use relative coordinates (++ syntax) you can specify each point of the polygon as an increment of ++(1,0), ++(0,1), ++(-1,0) or ++(0,-1) with respect of the last drawn point, so you only need to give absolute coordinates for the first point of the path, and this kind of relative coordinates for the remaining ones.

So, for example, your shape would be (assuming that I guessed right the units from your distorted drawing):

\draw[ultra thick, red, rounded corners] (first point) --
  ++(1, 0) -- ++(0,-1) -- ++(1, 0)  -- ++(1,0) -- ++(0,-1) --
  ++(0,-1) -- ++(-1,0) -- ++(0,-1) -- ++(-1,0) -- ++(0, 1) --
  ++(-1,0) -- ++(0, 1) -- ++(0, 1) --  cycle;

Where (first point) can be for example (3,6) to give this:

Result

share|improve this answer
    
Thanks ! Is there a way to not draw on the line of the grids ? –  projetmbc Feb 11 '13 at 17:50
    
There is a strange behavior. I've tried (4, 2) instead of (3,6) and the output is not the one expected. No ? –  projetmbc Feb 11 '13 at 18:13
1  
I’d favour the polar-coordinate syntax, i.e. (3,6) -- ++(right:1) -- ++(down:1) -- ++(right:2) -- ++(down:2) …. That is probably a bit more intuitive than to deal with all the 1s and 0s. –  Qrrbrbirlbel Feb 11 '13 at 18:23
    
@projetmbc Yes, it is possible not to draw on the line of the grid: Don’t do it. Move the \drawing command before the grid or use layers (or maybe opacity?). (4, 2) looks right to me … –  Qrrbrbirlbel Feb 11 '13 at 18:25
    
For the coordinate, it is indeed logical. There is no problem. –  projetmbc Feb 11 '13 at 18:31
show 1 more comment

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.