<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>base42.nl &#187; Slice</title>
	<atom:link href="http://blog.base42.nl/tag/slice/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.base42.nl</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 19:40:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Slice images with a Matrix</title>
		<link>http://blog.base42.nl/2009/slice-images-with-a-matrix/</link>
		<comments>http://blog.base42.nl/2009/slice-images-with-a-matrix/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 08:43:58 +0000</pubDate>
		<dc:creator>jankees</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[Slice]]></category>

		<guid isPermaLink="false">http://blog.base42.nl/?p=716</guid>
		<description><![CDATA[For my current project I needed something to slice an image easily, first I tried to slice the image with a mask, but I soon found out that this much heavier than my current solution. Below is the end result I needed to have (the triangle is a big mask). // image = a MovieClip [...]]]></description>
			<content:encoded><![CDATA[<p>For my current project I needed something to slice an image easily, first I tried to slice the image with a mask, but I soon found out that this much heavier than my current solution.</p>
<p>Below is the end result I needed to have (the triangle is a big mask).<img class="alignnone size-full wp-image-719" title="Lukx Image Slice Example" src="http://blog.base42.nl/wp-content/uploads/lukxexample.jpg" alt="Lukx Image Slice Example" width="650" height="402" /></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">// image = a MovieClip with an image</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// upper part</span>
<span style="color: #6699cc; font-weight: bold;">var</span> upperBitmapData<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>image<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span>image<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
upperBitmapData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>image<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
mUpperBitmap = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span>upperBitmapData<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>mUpperBitmap<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//lowerpart</span>
<span style="color: #6699cc; font-weight: bold;">var</span> lowerMatrix<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Matrix</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Matrix</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
lowerMatrix<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ty</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000;">&#40;</span>image<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> 
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> lowerBitmapData<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>image<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span>image<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
lowerBitmapData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>image<span style="color: #000066; font-weight: bold;">,</span>lowerMatrix<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
mLowerBitmap = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span>lowerBitmapData<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
mLowerBitmap<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = ContentClip<span style="color: #000066; font-weight: bold;">.</span>MASK_HEIGHT <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>mLowerBitmap<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
image = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.base42.nl/2009/slice-images-with-a-matrix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

