Golf a Venn Diagram generator Golf a Venn Diagram generator



In order to properly celebrate John Venn's 180th birthday, today your task will be creating a program that outputs a Venn Diagram!

Input:

A positive integer N that will define the range of numbers appearing in the diagram (From zero to N) and three sets of positive integers.

Output:

A 3 set Venn diagram showing all integers from 0 to N and the relationships of the sets by displaying them in the proper regions of the diagram, similar to this one.

Notes


Use stdin (or whatever your language's equivalent is) to get the
values.
You can define the input format for the sets and for N (Separated by comma, slash or whatever works best for you).
Numbers that do not appear in any of the sets but are within the specified range must appear on the diagram, just not inside any region.
The sets don't need to be named.
The output can be a drawing or ascii-art. 
The diagram can have any shape as long as the boundaries are unambiguously distinguishable (if you chose ASCII art, using + (or similar) for crossing boundaries is essential, for example). 
The regions may but don't have to be shaded.
Any built-in functions or third party libraries that generate Venn Diagrams are disallowed. 
Standard loopholes apply.


This is code-golf, so the shortest code, in bytes, wins.
Ruby, 654 590 566 542 505 bytes

This was fun. I used ASCII. I wasn't able to test every possible combination yet, so if you find a glitchy test case, please let me know.

require'set'
u=(0..gets.to_i).to_set
a,b,c=eval(gets).map &amp;:to_set
i=' '
m,M,n,N,o,O,p,P,q,Q,r,R,s,S=[a-b-c,b-a-c,c-a-b,a&amp;b-c,b&amp;c-a,a&amp;c-b,a&amp;b&amp;c].map{|u|[t=u.to_a*i,t.size]}.flatten
H,V,X=?─,?│,?┼
puts'┌'+H*(A=[1+M+[P,S].max,1+R].max)+?┐+(u-a-b-c).to_a*i,V+i*M+?┌+(b=H*(T=-M+U=A-1)+X+H*(B=[N,Q].max))+?┐,V+m+V+p+i*(T-P)+V+n+i*(B-N)+V,'│┌'+H*(K=M-1)+X+b+X+H*(C=[O-B-1,0].max)+?┐,(v=V*2+i*K)+V+s+i*(T-S)+V+q+i*(B-Q)+V+i*C+V,v+?└+b+?┘+i*C+V,V*2+r+i*(U-R)+V+o+i*(-O+D=B+C+1)+V,'└┼'+H*U+?┘+i*D+V,' └'+H*(A+D)+?┘


It expects the input on STDIN in the following format

10
[[1,2,3,4,5,9],[1,2,3,6,8],[7,2,9]]


And will then reward you with this beauty

┌───────┐0 10
│   ┌───┼───┐
│4 5│1 3│6 8│
│┌──┼───┼───┼┐
││  │2  │   ││
││  └───┼───┘│
││9     │7   │
└┼──────┘    │
 └───────────┘


I don't think I can be bothered to add an ungolfed version. Please have a look at the original version in the edit history for a somewhat more readable version.

This could certainly be golfed further by making the set boundaries less tight or even keeping them fixed like some of the graphical ones do, but I prefer that it looks nice and is done "properly" despite being golfed.