Skip to content

Instantly share code, notes, and snippets.

@gelicia
Created August 28, 2013 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gelicia/6372039 to your computer and use it in GitHub Desktop.
Save gelicia/6372039 to your computer and use it in GitHub Desktop.
i dont know how filters work
{"description":"i dont know how filters work","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/LU9oS5s.png"}
var svg = d3.select('svg');
var defs = svg.append("defs");
var filter = defs.append("filter").attr({
id: 'xorFilter',
filterUnits : 'objectBoundingBox'
});
filter.append("feImage").attr({
'xlink:href' : "#circle1",
'result' : 'circle1'
});
filter.append("feImage").attr({
'xlink:href' : "#circle2",
'result' : 'circle2'
});
filter.append("feImage").attr({
'xlink:href' : "#circle3",
'result' : 'circle3'
});
filter.append("feComposite").attr({
"in": "circle1",
"in2": "circle2",
"operator": "xor"
});
/*filter.append("feComposite").attr({
"in": "circle2",
"in2": "circle3",
"operator": "xor"
});*/
var mainG = defs.append('g').attr({
id: 'mainG',
width: 500,
height: 500
});
var rad = 97;
mainG.append('circle').attr({
cx: 150,
cy: 150,
r: rad,
id: 'circle1'
});
mainG.append('circle').attr({
cx: 250,
cy: 150,
r: rad,
id: 'circle2'
});
mainG.append('circle').attr({
cx: 548,
cy: 150,
r: rad,
id: 'circle3'
});
svg.append("use").attr({
'xlink:href': '#mainG',
'style': 'filter: url(#xorFilter); width:1000px; height:1000px;' //h and w don't actually work
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment