<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: scale code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 06:35:49 GMT</pubDate>
    <description>DZone Snippets: scale code</description>
    <item>
      <title>Zoom into SVG</title>
      <link>http://snippets.dzone.com/posts/show/5336</link>
      <description>This code is a complete SVG document which can be copied and pasted into a file saved as an SVG document (eg. makeZoom.svg) and run locally within your SVG compliant web browser. When the user clicks on the yellow rectangle the shape will increase in size giving the appearance that the document has just been zoomed in.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;svg	xmlns="http://www.w3.org/2000/svg" width="100%"&lt;br /&gt;		xmlns:xlink="http://www.w3.org/1999/xlink" id="cont" viewBox="0 0 300 100"&gt;&lt;br /&gt;  &lt;g&gt;	&lt;br /&gt;    &lt;g id="sketch" class="sketch"&gt;&lt;br /&gt;      &lt;rect x="130"&lt;br /&gt;  y="6" width="20px" height="10px" fill="yellow" onclick="zoomIn()" /&gt;&lt;br /&gt;    &lt;/g&gt;&lt;br /&gt;  &lt;/g&gt;&lt;br /&gt;&lt;br /&gt;  &lt;script&gt;&lt;br /&gt;  &lt;![CDATA[&lt;br /&gt;  function zoomIn(){&lt;br /&gt;&lt;br /&gt;    document.getElementById('sketch').parentNode.setAttribute('transform','translate(-70  ,-6)')&lt;br /&gt;    document.getElementById('sketch').setAttribute('transform','scale(1.5)')&lt;br /&gt;  }&lt;br /&gt;  ]]&gt;&lt;br /&gt;  &lt;/script&gt;&lt;br /&gt;&lt;/svg&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;I started off experimenting with viewBox however for simplicity, transform seems better suited for zoom, and panning.&lt;br /&gt;&lt;br /&gt;Reference:&lt;br /&gt;&lt;a href="http://www.w3.org/TR/SVG11/coords.html"&gt;Coordinate Systems, Transformations and Units - SVG 1.1 - 20030114&lt;/a&gt; [w3.org]&lt;br /&gt;&lt;a href="http://www.carto.net/papers/svg/samples/viewbox.shtml"&gt;Example for viewbox control&lt;/a&gt; [carto.net]</description>
      <pubDate>Tue, 08 Apr 2008 15:31:05 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5336</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>J2ME - Rescale Image</title>
      <link>http://snippets.dzone.com/posts/show/3257</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;private Image rescaleImage(Image image, int width, int height)&lt;br /&gt;	{&lt;br /&gt;		int sourceWidth = image.getWidth();&lt;br /&gt;		int sourceHeight = image.getHeight();&lt;br /&gt;	&lt;br /&gt;		Image newImage = Image.createImage(width, height);&lt;br /&gt;		Graphics g = newImage.getGraphics();&lt;br /&gt;		&lt;br /&gt;		for(int y=0; y&lt;height; y++)&lt;br /&gt;		{&lt;br /&gt;			for(int x=0; x&lt;width; x++)&lt;br /&gt;			{&lt;br /&gt;				g.setClip(x, y, 1, 1);&lt;br /&gt;				int dx = x * sourceWidth / width;&lt;br /&gt;				int dy = y * sourceHeight / height;&lt;br /&gt;				g.drawImage(image, x-dx, y-dy, Graphics.LEFT | Graphics.TOP);&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;		&lt;br /&gt;		return Image.createImage(newImage);&lt;br /&gt;	}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 09 Jan 2007 02:08:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3257</guid>
      <author>whitetiger ()</author>
    </item>
    <item>
      <title>Image/canvas bliting</title>
      <link>http://snippets.dzone.com/posts/show/926</link>
      <description>I can't remember how to call the blit method.&lt;br /&gt;So, here's just a personal reminder.&lt;br /&gt;(BTW, the pys60 doc has a wrong order between target and source)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;app.body = c = Canvas()&lt;br /&gt;w,h = 20,20&lt;br /&gt;im = Image.new(size=(w,h))&lt;br /&gt;&lt;br /&gt;# here's prototype&lt;br /&gt;# blit(im, source=(0,0,w,h), target=(0,0), mask=None, scale=0)&lt;br /&gt;# here are examples&lt;br /&gt;c.blit(im)  # put entire image on top-left&lt;br /&gt;c.blit(im, target=(70,70)) # put it about mid-screen&lt;br /&gt;c.blit(im, (0,0,w/2,h/2))  # put a quater image on top-left&lt;br /&gt;&lt;br /&gt;# double the image size and put it about mid-screen&lt;br /&gt;c.blit(im, target=(60,60,100,100), scale=1)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;If scale is not specified and source &lt;&gt; target, the image&lt;br /&gt;will be clipped instead of resized.&lt;br /&gt;&lt;br /&gt;mask is a 1-bit image with the same size as image.&lt;br /&gt;&lt;code&gt;mask = Image.new((w,h),'1')&lt;/code&gt;&lt;br /&gt;Pixel on the image will be copied if the same pixel&lt;br /&gt;on the mask is 'white'.&lt;br /&gt;So we can use mask to make 'Sprite'.</description>
      <pubDate>Thu, 01 Dec 2005 20:57:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/926</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
