Harbs / TLF-Table-Work

TLF Table Work
1 stars 0 forks source link

cell stroke tweaking #9

Open Harbs opened 10 years ago

Harbs commented 10 years ago

Currently, cell strokes are drawn within the cell bounds. If you have a cell which has a 1 pixel stroke, and the next cell also has a 1 pixel stoke, you will get a two pixel stroke between the two. This works well for strokes inside a table. The question remains, how to handle outside strokes. In that case, we need a method to draw a stroke outside the bounds of the cell.

Take a look at InDesign to see how things work there.

I currently have two ideas: 1) To figure out if a specific stroke is an external one, and draw it halfway outside the bounds if yes. 2) To add an "externalStrokeWidth" property which would be drawn if the stroke is an outside border of the table.

Any other ideas?

velara3 commented 10 years ago

I'm seeing different behavior. If two cells have a stroke the last one set overlaps the one next to it. I wasn't able to find a stroke location property. Do you have an INDD file showing what you are talking about or steps to reproduce?

screen shot 2014-05-28 at 12 56 42 am

Harbs commented 10 years ago

Sorry I was not clear.

InDesign does work differently. A cell stroke is halfway inside the cell, and halfway outside it. Each cell has stroke priorities to determine which stroke wins when there's a conflict.

In InDesign, if cell 1 has a 2 point stroke and cell 2 has a 2 point stroke, a single 2 point stroke will be drawn between the two cells, and the higher priority wins.

I'm proposing a different model. If cell one has a 2 pixel stroke and cell 2 has a 2 pixel stroke, BOTH strokes will be drawn side by side, so there's no conflict. It would be a bit of work converting between the InDesign model, and this one, but I think this is a more flexible model (cell spacing would have meaning), and requires less overhead tracking conflicts.

The problem with this model however, is how to handle edge cells. We need to draw half the stroke outside the cell bounds.

velara3 commented 10 years ago

Possible solutions (copied here for posterity)

Option 1 - Only allow strokes to grow on the inside of the cell or clip the content. For example, Photoshop has a stroke position that accepts centered (default for InDesign) or inside or outside.

photoshop_stroke_position

Example at 1pt: inner_stroke_1pt Example at 4pts: inner_stroke_4pt

Option 2 - Stroke overlap. When two edges compete draw the edges of both cells. In the following case the 4pt blue border of the first cell conflicts with the 1pt magenta border of the next cell. indesign_edge_conflict

In conflicting edges of different weights draw both cell edges.
strokes_overlap