{"id":129,"date":"2010-07-22T16:06:55","date_gmt":"2010-07-22T16:06:55","guid":{"rendered":"http:\/\/patternweaver.com\/blog\/?p=129"},"modified":"2010-07-22T16:23:34","modified_gmt":"2010-07-22T16:23:34","slug":"splatterplot-1-1-adding-images-into-the-mix","status":"publish","type":"post","link":"http:\/\/patternweaver.com\/blog\/2010\/07\/splatterplot-1-1-adding-images-into-the-mix\/","title":{"rendered":"SplatterPlot 1.1 Adding Images into the Mix"},"content":{"rendered":"<p>So I was asked a few times if the splatter plot could support images, and I&#8217;d explain how you could extend the node class to do that, but my guess is people would find it useful if it did that out of the box. SVG&#8217;s Image rendering uses really poor pixel resampling algorithms, so scaled imaged don&#8217;t look as good. In fact I found SVG scaling seems to break down as the draw buffer becomes much larger than your view pane, so it&#8217;s a hugely terrible idea to just zoom\/scale to infinity in a complex SVG without hand occluding elements offscreen. So now that I&#8217;ve fully chastised you for your vector sins, onto the example:<\/p>\n<p>so let&#8217;s create 10 instances of 1 of 4 (random) pngs we have laying around.<\/p>\n<pre><code>window.addEvent('domready', function(){\r\n    \r\n    var plot = new SplatterPlot(\r\n        'panel_one', \r\n        Window.getSize().x-30, \r\n        Window.getSize().y-40, \r\n        200\r\n    );\r\n    plot.nodeX = 70;\r\n    plot.nodeY = 70;\r\n    plot.seed = 120;\r\n    plot.buffer = 0;\r\n    plot.nonSequentialDistributionMode = false;\r\n    plot.expansionFactor = 0.7;\r\n    \r\n    \r\n    for(var lcv=0; lcv &lt; 10; lcv++){\r\n        plot.addNode(buildNode($random(1,4)));\r\n    }\r\n});<\/code><\/pre>\n<p>Now lets write the function to set up each node:<\/p>\n<pre><code>function buildNode(id, title){\r\n    var node = new SplatterImageNode('images\/masked\/'+id+'.png');\r\n    var root  = new Element('div', {'id': id});\r\n    root.inject(document.body);\r\n    node.click = function(){\r\n        \r\n    }\r\n    node.mouseover= function(){\r\n        this.shape.toFront();\r\n        this.shape.animate({\r\n            scale: 1.5\r\n        }, 300, '&lt;&gt;');\r\n    }\r\n    node.mouseout= function(){\r\n        this.shape.animate({\r\n            scale: 0.60\r\n        }, 300, '&lt;&gt;');\r\n    }\r\n    return node;\r\n}<\/code><\/pre>\n<p>And now we <a href=\"http:\/\/PatternWeaver.com\/SplatterPlot\/splat.php\">glare at our results<\/a>&#8230;<\/p>\n<p>And now you can <a href=\"http:\/\/PatternWeaver.com\/Downloads\/SplatterPlot-1.1.zip\">grab it<\/a> for your own enjoyment.<\/p>\n<p>enjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I was asked a few times if the splatter plot could support images, and I&#8217;d explain how you could extend the node class to do that, but my guess is people would find it useful if it did that out of the box. SVG&#8217;s Image rendering uses really poor pixel resampling algorithms, so scaled [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-129","post","type-post","status-publish","format-standard","hentry","category-js"],"_links":{"self":[{"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/comments?post=129"}],"version-history":[{"count":0,"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/posts\/129\/revisions"}],"wp:attachment":[{"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/media?parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/categories?post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/patternweaver.com\/blog\/wp-json\/wp\/v2\/tags?post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}