Author Topic: Vector hatch pattern with opaque background  (Read 5069 times)

0 Members and 1 Guest are viewing this topic.

David.P

  • Full Member
  • ***
  • Posts: 116
Vector hatch pattern with opaque background
« on: November 19, 2009, 05:40:55 AM »
Hi Chris & forum,

for a long time I've been looking for a way to create a hatch pattern that is line based (other than the bitmap based hatchings included with Visio). Additionally, and that is the problem, the area between the hatch lines should be opaque.

It sort of works if I create a custom fill pattern like the following:



...where I placed a white rectangle behind the hatch line, the rectangle as well as the line being slightly larger than the drawing area in order for the fill pattern to tile seamlessly. (In the above picture, the white background rectangle has been assigned some transparency only in order to be able to see the size of the drawing area).

This pattern looks and works great in Visio, however if it is printed to PDF, the lines are not smooth and straight anymore, see below (enlarged) PDF screenshot:



The hatch lines are perfectly straight for a fill pattern with no background (top half of the screenshot), but there is problems with the lines inside the fill pattern with background (lower half of the screenshot). This seems due to the fact that the fill pattern with no background is rendered by Visio in one single vector piece when printing to PDF -- whereas the fill pattern with background is rendered in lots of little tiles that somehow don't align correctly inside the PDF.

Thus the question would be, what could I do to improve the rendering of the fill pattern with the white background? Maybe there is another way to assign an opaque background to a fill pattern, other than using a separate white background shape for that purpose?

Thanks HEAPS already for any brainwave anyone might have regarding this dogged little issue,

Cheers David.P

PS: Visio version is 2003
« Last Edit: November 19, 2009, 11:38:14 PM by wapperdude »

Get Visio Guy's new book!


wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1694
  • Ideas Visio-lized into solutions
Re: Vector hatch pattern with opaque background
« Reply #1 on: November 19, 2009, 11:11:31 PM »
Hi David --

I tried this using V2007, and the Publish as PDF option.  I didn't see the line issue that you are referring to.  I tried various widths for the diagonal line, from as wide as 10pt to this fine line in the attached documents.  The blue dashed lines are not part of the pattern, but reference lines.  With the fine line pattern, there looks to be some sort of artifact that repeats itself.  This is different than what you observed, and, if you zoom in, it disappears.  Could be a slight resolution / misalignment problem.  The "page size" for my pattern is 0.5 in square, and this anomaly does seem to repeat every 1/2 inch.  It's much less noticeable as the line width increases.  Final observation, if you change the fill pattern such that the line ends at the corners of the yellow square, and then set the line ends to "extended", this anomaly goes away or is very, very slight.  Plus, fat lines still look continuous.

I will try to repeat this on V2003 tomorrow.

Wapperdude
« Last Edit: November 19, 2009, 11:37:50 PM by wapperdude »

Visit the Visio Guy web site at www.visguy.com for hundreds more articles on Visio!


David.P

  • Full Member
  • ***
  • Posts: 116
Re: Vector hatch pattern with opaque background
« Reply #2 on: November 20, 2009, 04:22:51 AM »
Hi Wapper and thank you for your experiment & files.

Your example looks and behaves exactly the same in my copy of Visio 2003, also when printed to PDF with Adobe Acrobat Distiller 7.

This however seems due to the fact that my hatch pattern is rather fine (sorry for not having mentioned that initially).

Actually, the tile (=page) size of my hatch is 1.4 mm by 1.4 mm. It seems that only with such small hatches, the problem prevails (although the same size hatch with NO background color of course is still perfect, see my initial PDF screenshot).

Isn't it kind of strange that it seems there is no "proper" way in Visio to create a simple vector fill pattern with a background color -- given all the sophisticated ways in which to create those intelligent shapes...  :(

Thanks David

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1694
  • Ideas Visio-lized into solutions
Re: Vector hatch pattern with opaque background
« Reply #3 on: November 20, 2009, 10:06:08 AM »
Whoa!  That is mighty fine!  (Pun intended!   :o ).

Strange?  Perhaps, along with disappointing.  The custom fill and line pattern functionality has been one of those features that has been great to have but has some quirks.  Doing a custom line pattern on a "closed" shape is one of those issues.  Maintaining a fill pattern when drawing is exported --- well that's tough to anticipate all the needs when you consider all of the possible formats that a translator must handle.  When it comes to fill patterns, Visio and PDF have never quite seen "eye to eye"!  Depending upon whom you use to do the Adobe translation, V2003, and there are a lot of free ones out there, results do vary.

Wapperdude



David.P

  • Full Member
  • ***
  • Posts: 116
Re: Vector hatch pattern with opaque background
« Reply #4 on: November 30, 2009, 06:55:29 AM »
Thanks Wapperdude for your reply. Seems as if we'd have to live with this limitation for the moment.

Cheers David.P

David.P

  • Full Member
  • ***
  • Posts: 116
Re: Vector hatch pattern with opaque background
« Reply #5 on: July 07, 2014, 04:00:03 AM »
...still looking for a way to finally create opaque vector hatch patterns that don't look terrible in PDF....

My vector hatch patterns printed to PDF:


:-\

My current patterns are attached...


Yacine

  • Hero Member
  • *****
  • Posts: 1248
Re: Vector hatch pattern with opaque background
« Reply #6 on: July 07, 2014, 12:42:48 PM »
didn't you like the solution I posted here?
http://visguy.com/vgforum/index.php?topic=5608.msg22250#msg22250

It's not perfect but viable.
Yacine

David.P

  • Full Member
  • ***
  • Posts: 116
Re: Vector hatch pattern with opaque background
« Reply #7 on: July 07, 2014, 01:35:07 PM »
Thank you Yacine, I had completely missed that thread.

Your hatch pattern unfortunately has similar problems like mine use to have:

Background is shining through:


Lines are interrupted or partially covered up at the seams of the tiles:


However, I think I shall try wapperdude's idea (group lines with background square but extend the lines over the group boundary):

After some additional consideration to the 1st post Yacine recalled, I believe there is a solution to the little glitches that were noticed.

Draw the initial hatch fill per usual.  See attached Visio file.  I drew equally spaced diagonal lines.  Added another shape behind it to include a fill background.  Also, made the line color around that 2nd shape the same as the fill color.  These shapes were grouped together.  Open the shapesheet of the group, and under Protection section set LocCalcWH to 1.  Then, extend the lines beyond the alignment box.  That should do it.

What this does, when the fill pattern is applied, the patterns butt together along the alignment boxes.  Because the filled shape has a border line around it as the same color as the fill, there is no obvious transition from fill pattern to fill pattern.  Also, because the lines extend beyond the alignment box, there are no gaps or glitches in the line pattern

I had tried something similar with my above attached example, but it didn't entirely work.

I will report back.

Regards David.P

David.P

  • Full Member
  • ***
  • Posts: 116
Re: Vector hatch pattern with opaque background
« Reply #8 on: July 10, 2014, 02:10:08 AM »
Ok, the group trick did not help either, because this way, the hatch pattern still will not look seamless when tiled to fill a shape, at least not if the hatch lines are inclined to the left which is always problematic because of the way Visio puts the tiles together like this:


.       How Visio tiles fill patterns

However it seems that I have found a way to create an opaque vector hatch that works, even for a small pitch and when inclined to the left.

The trick is to draw the fill pattern like this:



The border of the white background square (that of course also must be white) has been colored in order to better see the square. The trick is to simply nudge the square right and up a little.

This way, the white square afterwards still covers the entire shape with a white background, while the black line creates the hatch, but both don't interfere with each other at the overlapping tiles' borders.

This fill pattern also looks perfect when printed to PDF (~almost, depending on the PDF printer and viewer that is used, because inevitably, vector hatch patterns will always consist of line segments)

Can't believe that it literally took me ten years of fiddling with non-working hatch patterns to finally find this solution.
« Last Edit: July 14, 2014, 02:31:51 AM by David.P »

Yacine

  • Hero Member
  • *****
  • Posts: 1248
Re: Vector hatch pattern with opaque background
« Reply #9 on: July 10, 2014, 12:16:12 PM »
Nice job.
Yacine

David.P

  • Full Member
  • ***
  • Posts: 116
Re: Vector hatch pattern with opaque background
« Reply #10 on: July 14, 2014, 02:20:22 AM »
Thank you Yacine.

In the meantime, I've found a pattern that is even better:


In the image, the pattern background that normally is solid white, has been coloured in transparent orange in order to better show its shape.

The characteristics are:
  • Instead of moving the entire background up and right, the corner at the bottom left is cut off in order to not cover the hatch line when the pattern gets tiled. This is better than the shape as it was before since this way, only one tiny corner at the bottom left of any shape filled with this pattern will be transparent (and only if the outline of that hatch-filled shape is very thin).
  • The line of the white background shape has been removed, in order for better and faster PDF display across different PDF readers.
  • The black hatch line has the line end property "extended".

Best regards
David.P
« Last Edit: July 23, 2014, 04:03:29 AM by David.P »

radek.cervajz

  • Newbie
  • *
  • Posts: 5
Re: Vector hatch pattern with opaque background
« Reply #11 on: July 23, 2014, 03:17:26 AM »
Hi guys,

thanks a lot for solving out troubles with hatching. A works really great to PDF. I found an another problem, because would need this in .SVG file, bud hatchs do not appear ins svg.
I have no idea why. Could anybody help?

Regards,
Radek.

David.P

  • Full Member
  • ***
  • Posts: 116
Re: Vector hatch pattern with opaque background
« Reply #12 on: July 23, 2014, 04:00:55 AM »
True, vector fill patterns generally don't seem to turn up in SVG files created from Visio. Probably the reason for this is the fact that Visio doesn't create or support "proper" vector hatch fills. Instead, with the present trick, a vector hatch fill is simulated by drawing lots of small matching rectangles and lines all over the place. On the other hand, I'm not sure whether the SVG specification supports vector fill patterns at all.

Therefore I wouldn't be able to tell how such fill patterns could be made to turn up in SVG. If possible at all, probably an external program would be needed.

For example, the hatch patterns are exported correctly if the Visio file is saved as *.emf. Either from this, or from a PDF file printed from Visio, your drawing program of choice (possibly) could create an SVG file that shows the hatch pattern.

Hope that helps
Regards
David

radek.cervajz

  • Newbie
  • *
  • Posts: 5
Re: Vector hatch pattern with opaque background
« Reply #13 on: July 23, 2014, 04:50:57 AM »
Yes, thank you for inspiration. The way like this works, unfortunatelly it takes more time, but works.

R.