<?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>REALbasic City &#187; canvas</title>
	<atom:link href="http://realbasic.tutspolis.com/tag/canvas/feed/" rel="self" type="application/rss+xml" />
	<link>http://realbasic.tutspolis.com</link>
	<description>Tutorials - Tutspolis.com</description>
	<lastBuildDate>Sat, 29 May 2010 23:10:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PM: Creating search control in REALbasic</title>
		<link>http://realbasic.tutspolis.com/tutorials/pm-creating-search-control-in-realbasic/</link>
		<comments>http://realbasic.tutspolis.com/tutorials/pm-creating-search-control-in-realbasic/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 22:03:02 +0000</pubDate>
		<dc:creator>Jakub Pawlak</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[realbasic]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[textedit]]></category>

		<guid isPermaLink="false">http://realbasic.tutspolis.com/?p=205</guid>
		<description><![CDATA[<!-- isPostPurchased ,postID 205, userID 0, combination 1 -->
			
				
			
		
This tutorial (for Premium Members) will show you how to create in REALbasic a round search control with focus option when it&#8217;s active. To get this effect we won&#8217;t use any declaration and this way we will have a crossplatform search field that looks cool not only on Mac OS. Watch it, learn it, enjoy [...]]]></description>
			<content:encoded><![CDATA[<!-- isPostPurchased ,postID 205, userID 0, combination 1 --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fpm-creating-search-control-in-realbasic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fpm-creating-search-control-in-realbasic%2F&amp;source=REALbasicCity&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>This tutorial (for Premium Members) will show you how to create in REALbasic a round search control with focus option when it&#8217;s active. To get this effect we won&#8217;t use any declaration and this way we will have a crossplatform search field that looks cool not only on Mac OS. Watch it, learn it, enjoy it!</p>
<p><span id="more-205"></span></p>
<div style="margin-left:19px;float:left">
<h2>Mac OS X Search Field</h2>
<p>Before we start this tutorial I like to show you a Class named Mac OS X Search Field. The Rounded Search field is a very standard user interface element in Mac OS X. This class brings the true HISearchField to REALbasic. Mac OS X Search Field Class supports the full range of search field features, such as live search, search menu, and cancel button, but there is one problem&#8230; it&#8217;s using Cocoa declarations and it&#8217;s only available for Mac users. If you like to try it you can visit <a href="http://www.thezaz.com/opensource/realbasic/macosx/searchfield/">The ZAZ Studios</a> website. </p>
<h2>Creating search control in REALbasic</h2>
<p>	<div class='ArePayPalContent'>
	<p class='ArePayPalTextToShowIfNotLogedIn'>If you see this message you probably want access special material for Premium Members (Source Files, Bonus Tutorials, free Classes and More). You can do this by subscribing REALbasic City site for 10 USD (access for 3 months). There is also a option to buy access only to this material. Login or register to get option to buy and support REALbasic City.</p>
	<a class='ArePayPalLoginButton' href='http://tutspolis.com/wp-login.php'>Log in</a>
	</div></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://realbasic.tutspolis.com/tutorials/pm-creating-search-control-in-realbasic/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating custom button in REALbasic</title>
		<link>http://realbasic.tutspolis.com/tutorials/creating-custom-button-in-realbasic/</link>
		<comments>http://realbasic.tutspolis.com/tutorials/creating-custom-button-in-realbasic/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 13:16:32 +0000</pubDate>
		<dc:creator>Jakub Pawlak</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[realbasic]]></category>

		<guid isPermaLink="false">http://realbasic.tutspolis.com/?p=203</guid>
		<description><![CDATA[<!-- isPostPurchased ,postID 203, userID 0, combination 1 -->
			
				
			
		
Today we will learn how can we create a custom Button Control (like on the screen) for REAlbasic application using Canvas Control. Hope you will find this tutorial useful.  Watch it, learn it, enjoy it!


Create Button Control for REALbasic
Before we start coding add to Window1 Class a Canvas Control and set in Width property [...]]]></description>
			<content:encoded><![CDATA[<!-- isPostPurchased ,postID 203, userID 0, combination 1 --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fcreating-custom-button-in-realbasic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fcreating-custom-button-in-realbasic%2F&amp;source=REALbasicCity&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Today we will learn how can we create a custom Button Control (like on the screen) for REAlbasic application using Canvas Control. Hope you will find this tutorial useful.  Watch it, learn it, enjoy it!</p>
<p><span id="more-203"></span></p>
<div style="margin-left:19px;float:left">
<h2>Create Button Control for REALbasic</h2>
<p>Before we start coding add to Window1 Class a Canvas Control and set in Width property to 61 and Height to 19. These values will give the button the best Mac like look. Now in it Sub Paint () event enter the code below</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">g.ForeColor = RGB(105,100,107) //<span style="color: #000080;">set</span> the color
g.DrawRoundRect (0,0,me.Width,me.Height,17,17) //draw the round rectangle
&nbsp;
g.ForeColor = &amp;c1E1E1E //<span style="color: #000080;">set</span> the color
g.FillRoundRect (1,1,me.Width-2,me.Height-2,17,17) //fill the rectangle
&nbsp;
g.ForeColor = &amp;cFFFFFF //<span style="color: #000080;">set</span> the color
g.TextSize = 10 //<span style="color: #000080;">set</span> text size
g.DrawString (<span style="color: #800000;">&quot;Backup&quot;</span>, 13, 13) //drawn the <span style="color: #000080;">string</span> <span style="color: #800000;">&quot;Backup&quot;</span> <span style="color: #000080;">on</span> X, Y position <span style="color: #000080;">in</span> Canvas <span style="color: #000080;">Control</span></pre></td></tr></table></div>

<p>This will draw our button when the application will start.</p>
<h2>Button Control click event</h2>
<p>It would be nice if the Button could visually change it color so the user will know that it was clicked (like the first button on the tutorial screen). There are few ways to doing that, and I will show you one of the easiest.  Add this code to Canvas1 Function MouseDown ().</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">//creating clicked style button
&nbsp;
Canvas1.Graphics.ForeColor = RGB(105,100,107) //<span style="color: #000080;">set</span> the color
Canvas1.Graphics.DrawRoundRect (0,0,Canvas1.Width,Canvas1.Height,17,17) 
&nbsp;
Canvas1.Graphics.ForeColor = RGB(79,75,80)
Canvas1.Graphics.FillRoundRect (1,1,Canvas1.Width-2,Canvas1.Height-2,17,17)
&nbsp;
Canvas1.Graphics.ForeColor = &amp;cFFFFFF //<span style="color: #000080;">set</span> the color
Canvas1.Graphics.TextSize = 10
Canvas1.Graphics.DrawString (<span style="color: #800000;">&quot;Backup&quot;</span>, 13, 13)
&nbsp;
App.DoEvents(180) //pause <span style="color: #000080;">for</span> 180 ms so the user can see the click
&nbsp;
//showing the default style of our custom button <span style="color: #000080;">control</span>
&nbsp;
Canvas1.Graphics.ForeColor = RGB(105,100,107) //<span style="color: #000080;">set</span> the color
Canvas1.Graphics.DrawRoundRect (0,0,Canvas1.Width,Canvas1.Height,17,17) 
&nbsp;
Canvas1.Graphics.ForeColor =  &amp;c1E1E1E
Canvas1.Graphics.FillRoundRect (1,1,Canvas1.Width-2,Canvas1.Height-2,17,17)
&nbsp;
Canvas1.Graphics.ForeColor = &amp;cFFFFFF //<span style="color: #000080;">set</span> the color
Canvas1.Graphics.TextSize = 10
Canvas1.Graphics.DrawString (<span style="color: #800000;">&quot;Backup&quot;</span>, 13, 13)</pre></td></tr></table></div>

<p>I also used in this tutorial a transparent window effect from my other tutorial <a href="http://realbasic.tutspolis.com/tutorials/transparent-window-in-realbasic/">Transparent Window in REALbasic</a>. If you like you can use it too&#8230; but change the percent of visibility to .90. </p>
<h3>Download</h3>
<p>	<div class='ArePayPalContent'>
	<p class='ArePayPalTextToShowIfNotLogedIn'>If you see this message you probably want access special material for Premium Members (Source Files, Bonus Tutorials, free Classes and More). You can do this by subscribing REALbasic City site for 10 USD (access for 3 months). There is also a option to buy access only to this material. Login or register to get option to buy and support REALbasic City.</p>
	<a class='ArePayPalLoginButton' href='http://tutspolis.com/wp-login.php'>Log in</a>
	</div></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://realbasic.tutspolis.com/tutorials/creating-custom-button-in-realbasic/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating custom progressbar in REALbasic</title>
		<link>http://realbasic.tutspolis.com/tutorials/creating-custom-progressbar-in-realbasic/</link>
		<comments>http://realbasic.tutspolis.com/tutorials/creating-custom-progressbar-in-realbasic/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 20:55:56 +0000</pubDate>
		<dc:creator>Jakub Pawlak</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[progressbar]]></category>
		<category><![CDATA[realbasic]]></category>

		<guid isPermaLink="false">http://realbasic.tutspolis.com/?p=197</guid>
		<description><![CDATA[<!-- isPostPurchased ,postID 197, userID 0, combination 1 -->
			
				
			
		
This tutorial will show you how can you create a custom Progressbar Control for REAlbasic application using Canvas Control. Watch it, learn it, enjoy it!


Creating ProgressBar for REALbasic
We will start this tutorial with adding to Window1 Class a Canvas Control. Now in it Sub Paint () event enter the code below. This will draw a [...]]]></description>
			<content:encoded><![CDATA[<!-- isPostPurchased ,postID 197, userID 0, combination 1 --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fcreating-custom-progressbar-in-realbasic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fcreating-custom-progressbar-in-realbasic%2F&amp;source=REALbasicCity&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>This tutorial will show you how can you create a custom Progressbar Control for REAlbasic application using Canvas Control. Watch it, learn it, enjoy it!</p>
<p><span id="more-197"></span></p>
<div style="margin-left:19px;float:left">
<h2>Creating ProgressBar for REALbasic</h2>
<p>We will start this tutorial with adding to Window1 Class a Canvas Control. Now in it Sub Paint () event enter the code below. This will draw a frame of our rectangle when the application will start.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">g.ForeColor = RGB(135,136,162) //<span style="color: #000080;">set</span> the color
g.DrawRect (0,0,me.Width,me.Height) //draw the frame</pre></td></tr></table></div>

<h2>Displaying the progress in our ProgressBar Control</h2>
<p>This is the most important part of Creating custom progressbar in REALbasic tutorial. We will display visually the progress in our progress bar control. Copy and paste this code for example to the Canvas1 Sub Open ().</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> i, v, progressvalue <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
<span style="color: #000080;">Dim</span> steep <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>
<span style="color: #000080;">Dim</span> g <span style="color: #000080;">As</span> Graphics
&nbsp;
v = 2000 //the final value of progress
steep = Canvas1.Width / v //getting the size of one steep
&nbsp;
<span style="color: #000080;">for</span> i = 0 <span style="color: #000080;">to</span> v //<span style="color: #000080;">get</span> the actual progress value
&nbsp;
    App.DoEvents(2) //pause <span style="color: #000080;">for</span> 2 ms
&nbsp;
    Canvas1.Graphics.ForeColor = RGB(237,237,237) // fixing a bug <span style="color: #000080;">with</span> wrong drawing <span style="color: #000080;">string</span>
    Canvas1.Graphics.FillRect (Canvas1.Width /2 - 10,1, 30, Canvas1.Height) //draw a fill rectangle <span style="color: #000080;">for</span> progress text
&nbsp;
    Canvas1.Graphics.ForeColor = RGB(231,121,23) //<span style="color: #000080;">set</span> the color
    Canvas1.Graphics.FillRect (0,2, (steep * i), Canvas1.Height-4)  //draw the progress
&nbsp;
    progressvalue = i * 100 / v //<span style="color: #000080;">get</span> the progress value <span style="color: #000080;">for</span> text display
    Canvas1.Graphics.ForeColor = RGB(50,50,50) //<span style="color: #000080;">set</span> the color
    Canvas1.Graphics.DrawString (Str(progressvalue) + <span style="color: #800000;">&quot; %&quot;</span>, Canvas1.Width /2 - 10,16) // drawing the progress <span style="color: #000080;">string</span> <span style="color: #000080;">in</span> center of ProgressBra <span style="color: #000080;">Control</span>
&nbsp;
    Canvas1.Graphics.ForeColor = RGB(135,136,162) //<span style="color: #000080;">set</span> the color
    Canvas1.Graphics.DrawRect (0,0,Canvas1.Width,Canvas1.Height) //draw the frame 
&nbsp;
<span style="color: #000080;">next</span></pre></td></tr></table></div>

<h3>Download</h3>
<p>	<div class='ArePayPalContent'>
	<p class='ArePayPalTextToShowIfNotLogedIn'>If you see this message you probably want access special material for Premium Members (Source Files, Bonus Tutorials, free Classes and More). You can do this by subscribing REALbasic City site for 10 USD (access for 3 months). There is also a option to buy access only to this material. Login or register to get option to buy and support REALbasic City.</p>
	<a class='ArePayPalLoginButton' href='http://tutspolis.com/wp-login.php'>Log in</a>
	</div></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://realbasic.tutspolis.com/tutorials/creating-custom-progressbar-in-realbasic/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Screen capture in REALbasic</title>
		<link>http://realbasic.tutspolis.com/tutorials/screen-capture-in-realbasic/</link>
		<comments>http://realbasic.tutspolis.com/tutorials/screen-capture-in-realbasic/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 00:29:49 +0000</pubDate>
		<dc:creator>Jakub Pawlak</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[realbasic]]></category>
		<category><![CDATA[screencapture]]></category>

		<guid isPermaLink="false">http://realbasic.tutspolis.com/?p=190</guid>
		<description><![CDATA[<!-- isPostPurchased ,postID 190, userID 0, combination 1 -->
			
				
			
		
In this tutorial we will learn how to create a screen capture application in REALbasic. We will discover three different methods to grab the screen form Mac OS, Windows or Linux desktop and load it to Canvas Control. Watch it, learn it, enjoy it!


Screencapture on Mac using REALbasic
Before we will learn to the universal way [...]]]></description>
			<content:encoded><![CDATA[<!-- isPostPurchased ,postID 190, userID 0, combination 1 --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fscreen-capture-in-realbasic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fscreen-capture-in-realbasic%2F&amp;source=REALbasicCity&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In this tutorial we will learn how to create a screen capture application in REALbasic. We will discover three different methods to grab the screen form Mac OS, Windows or Linux desktop and load it to Canvas Control. Watch it, learn it, enjoy it!</p>
<p><span id="more-190"></span></p>
<div style="margin-left:19px;float:left">
<h2>Screencapture on Mac using REALbasic</h2>
<p>Before we will learn to the universal way (cross platform) to grab the screen and load it into Canvas Control in REALbasic we will look at screencapture, a Terminal  command used to invoke the screen capture feature in Mac OS X. Using Shell Class we will execute a command that will capture the screen and save it on our system desktop. Add a PushButton to Window1 and in it Sub Action () enter:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> s <span style="color: #000080;">As</span> <span style="color: #000080;">New</span> Shell
&nbsp;
s.Execute (<span style="color: #800000;">&quot;screencapture -S -x ~/Desktop/screenshot.jpg&quot;</span>)</pre></td></tr></table></div>

<p>The screencapture utility is not very well documented to date. A list of options follows.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">-S      <span style="color: #000080;">In</span> window capture mode, capture the screen instead of the window.
-W      Start interaction <span style="color: #000080;">in</span> window selection mode.
-c      Force screen capture <span style="color: #000080;">to</span> go <span style="color: #000080;">to</span> the clipboard.
-i      Capture screen interactively, by selection <span style="color: #000080;">or</span> window. The <span style="color: #000080;">control</span>
        key will cause the screen shot <span style="color: #000080;">to</span> go <span style="color: #000080;">to</span> the clipboard. The space key 
        will toggle between mouse selection <span style="color: #000080;">and</span> window selection
        modes.  The escape key will cancel the interactive screen shot.
-m      Only capture the main monitor, undefined <span style="color: #000080;">if</span> -i <span style="color: #000080;">is</span> <span style="color: #000080;">set</span>.
-s      Only allow mouse selection mode.
-w      Only allow window selection mode.
-x      <span style="color: #000080;">Do</span> <span style="color: #000080;">not</span> play sounds.
-C      Capture the cursor <span style="color: #000080;">as</span> well <span style="color: #000080;">as</span> the screen.  Only allowed <span style="color: #000080;">in</span> non-interactive modes.
-t      Image format <span style="color: #000080;">to</span> create, default <span style="color: #000080;">is</span> png.
file    where <span style="color: #000080;">to</span> save the screen capture</pre></td></tr></table></div>

<h2>Screencapture on Windows using REALbasic</h2>
<p>We can also try to grab the screen by simulating PrtSc key click. Add to Window1 a PushButton Control and Canvas Control. Now in PushButton Sub Action () enter:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> c <span style="color: #000080;">As</span> <span style="color: #000080;">New</span> Clipboard
&nbsp;
<span style="color: #000080;">Declare</span> <span style="color: #000080;">Sub</span> keybd_event <span style="color: #000080;">Lib</span> <span style="color: #800000;">&quot;User32&quot;</span> ( keyCode <span style="color: #000080;">as</span> <span style="color: #000080;">Integer</span>, scanCode <span style="color: #000080;">as</span> <span style="color: #000080;">Integer</span>, flags <span style="color: #000080;">as</span> <span style="color: #000080;">Integer</span>, extraData <span style="color: #000080;">as</span> <span style="color: #000080;">Integer</span> )
&nbsp;
keybd_event( &amp;h2C, 0, 0, 0 ) //simulate pressing the PrtSc key
&nbsp;
<span style="color: #000080;">if</span> c.PictureAvailable <span style="color: #000080;">then</span> Canvas1.Backdrop = c.Picture //load picture <span style="color: #000080;">to</span> Canvas <span style="color: #000080;">Control</span></pre></td></tr></table></div>

<h2>Screencapture on Linux using REALbasic</h2>
<p>This method will work on Linux, Mac and Windows. Add to Window1 a PushButton Control and Canvas Control. Now in PushButton Sub Action () enter:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> r <span style="color: #000080;">As</span> RGBSurface
<span style="color: #000080;">Dim</span> screenshot <span style="color: #000080;">As</span> Picture
&nbsp;
screenshot = <span style="color: #000080;">New</span> Picture (Canvas1.Width, Canvas1.Height, 32)
&nbsp;
r = screenshot.RGBSurface
&nbsp;
<span style="color: #000080;">for</span> i <span style="color: #000080;">as</span> <span style="color: #000080;">integer</span> = 0 <span style="color: #000080;">to</span> width
  <span style="color: #000080;">for</span> j <span style="color: #000080;">as</span> <span style="color: #000080;">integer</span> = 0 <span style="color: #000080;">to</span> height
    r.pixel(i, j) = system.pixel(i, j)
  <span style="color: #000080;">next</span>
<span style="color: #000080;">next</span>
&nbsp;
Canvas1.Graphics.Drawpicture screenshot, 0, 0</pre></td></tr></table></div>

<h2>Image manipulation in REALbasic</h2>
<p>If you are creating a screen capture application in REALbasic you probably like to know how to open a image, how to fit graphic to canvas, how to crop the picture or display scaled image. In my earlier tutorial &#8220;<a href="http://realbasic.tutspolis.com/tutorials/creating-imageviewer-in-realbasic/">Creating ImageViewer in REALbasic</a>&#8221; you can find all answers on these questions.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://realbasic.tutspolis.com/tutorials/screen-capture-in-realbasic/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hex Color Picker in REALbasic</title>
		<link>http://realbasic.tutspolis.com/tutorials/hex-color-picker-in-realbasic/</link>
		<comments>http://realbasic.tutspolis.com/tutorials/hex-color-picker-in-realbasic/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 11:52:18 +0000</pubDate>
		<dc:creator>Jakub Pawlak</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[color picker]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[picture]]></category>
		<category><![CDATA[realbasic]]></category>

		<guid isPermaLink="false">http://realbasic.tutspolis.com/?p=111</guid>
		<description><![CDATA[<!-- isPostPurchased ,postID 111, userID 0, combination 1 -->
			
				
			
		
Weekend is almost over and I promised some tutorials for you folks. So to keep my word we will learn today how can we create a Hex Color Picker in REALbasic. This will be a very fun tutorial so watch it , learn it, enjoy it!


Creating the GUI
We will use today Rectangle Control, StaticText Control, [...]]]></description>
			<content:encoded><![CDATA[<!-- isPostPurchased ,postID 111, userID 0, combination 1 --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fhex-color-picker-in-realbasic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fhex-color-picker-in-realbasic%2F&amp;source=REALbasicCity&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Weekend is almost over and I promised some tutorials for you folks. So to keep my word we will learn today how can we create a Hex Color Picker in REALbasic. This will be a very fun tutorial so watch it , learn it, enjoy it!</p>
<p><span id="more-111"></span></p>
<div style="margin-left:19px;float:left">
<h2>Creating the GUI</h2>
<p>We will use today Rectangle Control, StaticText Control, TextField Control and Canvas Control. Try to put them in similar positions and sizes like on the screenshot. In StaticText Control property Text enter Color name then add to Project Tab a picture (vacations) and for the Backdrop property for Canvas1 select our image. For the end add in Code Editor Tab a new Property Declaration mycolor As Color.</p>
<p><img src="http://realbasic.tutspolis.com/files/tutorials/hexcolorpicker.jpg" alt="Hex Color Picker in REALbasic" /></p>
<h3>Color Picker from Canvas</h3>
<p>To get the color from our Canvas1 we must go to the code editor Canvas1 Function MouseDown (). When we enter this code this tutorial is over but I will give you some other tips.  First when you enter this code for example in Event Handlers Function MouseDown () you will get every color available in app Window (StaticText Control, Window BackColor).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">myColor = System.Pixel(System.MouseX, System.MouseY) //<span style="color: #000080;">get</span> the pixel color under the mouse
&nbsp;
Rectangle1.FillColor = mycolor //change the color <span style="color: #000080;">in</span> Rectangle <span style="color: #000080;">Control</span>
StaticText1.Text = Str(mycolor) //<span style="color: #000080;">get</span> the color name <span style="color: #000080;">in</span> <span style="color: #000080;">string</span></pre></td></tr></table></div>

<h2>Converting color to Hexadecimal</h2>
<p>Our color picker in REALbasic give us a color in format &amp;hffffff (white). We can simply convert this to web color by replacing &amp;h with #. In this way we can use the name of color immediate in our web pages, css files or graphics software.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">me.Text = Replace(me.Text, <span style="color: #800000;">&quot;&amp;amp;h&quot;</span>, <span style="color: #800000;">&quot;#&quot;</span>)</pre></td></tr></table></div>

<h2>Changing the cursor in REALbasic</h2>
<p>It can be also nice when we can display a other cursor for picking the color from our picture. To do this we can go to Canvas1 Sub MouseEnter () and display a new cursor. On Canvas1 Sub MouseExit () we can then change it to default.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">App.MouseCursor = System.Cursors.MagnifyLarger</pre></td></tr></table></div>

</div>
]]></content:encoded>
			<wfw:commentRss>http://realbasic.tutspolis.com/tutorials/hex-color-picker-in-realbasic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drag and drop images, text, controls in REALbasic</title>
		<link>http://realbasic.tutspolis.com/tutorials/drag-and-drop-images-text-controls-in-realbasic/</link>
		<comments>http://realbasic.tutspolis.com/tutorials/drag-and-drop-images-text-controls-in-realbasic/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 16:16:02 +0000</pubDate>
		<dc:creator>Jakub Pawlak</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[controls]]></category>
		<category><![CDATA[drag and drop]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[realbasic]]></category>
		<category><![CDATA[statictext]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[textarea]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://realbasic.tutspolis.com/?p=100</guid>
		<description><![CDATA[<!-- isPostPurchased ,postID 100, userID 0, combination 1 -->
			
				
			
		
In this tutorial we learn how to drag and drop images and text files from desktop to our application, and how to drag and drop controls inside Window in REALbasic. Watch it, learn it, enjoy it!


Creating the GUI
We will use today a StaticText, TextArea and Canvas control to create our GUI. Simply drag and drop [...]]]></description>
			<content:encoded><![CDATA[<!-- isPostPurchased ,postID 100, userID 0, combination 1 --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fdrag-and-drop-images-text-controls-in-realbasic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fdrag-and-drop-images-text-controls-in-realbasic%2F&amp;source=REALbasicCity&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In this tutorial we learn how to drag and drop images and text files from desktop to our application, and how to drag and drop controls inside Window in REALbasic. Watch it, learn it, enjoy it!</p>
<p><span id="more-100"></span></p>
<div style="margin-left:19px;float:left">
<h2>Creating the GUI</h2>
<p>We will use today a StaticText, TextArea and Canvas control to create our GUI. Simply drag and drop this controls to Window1 so they will be placed to something similar to the picture below.</p>
<p><img src="http://realbasic.tutspolis.com/files/tutorials/draganddrop/draganddrop.png" alt="Drag and drop in REALbasic" /></p>
<h2>Drag and drop controls</h2>
<p>The firs thing we will do in this tutorial is dragging a StaticText control to TextArea control and displaying in it StaticText1.Text. To do this go to StaticText1 Function MouseDown () and use this code.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> d <span style="color: #000080;">As</span> DragItem
&nbsp;
d = NewDragItem(me.left,me.top,me.width,me.height)
d.text = me.text
d.drag</pre></td></tr></table></div>

<p>Now you can drag and drop StaticText to TextArea control. Isn&#8217;t this easy or what?</p>
<h2>Drag and drop text file from desktop into TextArea</h2>
<p>In this part of tutorial we will learn how can we drag and drop text file from desktop to our REALbasic application. In this case we will use TextArea control as a object into we will drag and drop text file and display all content in it available.  Firs go to Project tab and add new File type set and as Display Name type special/any.</p>
<p><img src="http://realbasic.tutspolis.com/files/tutorials/draganddrop/filetypeset.png" alt="File type set in REALbasic" /></p>
<p>Next go to code editor and in TextArea1 Sub Open () enter code&#8230; Of course you can be more detailed by allowing only a specify format for drag and drop in this control.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">me.AcceptFileDrop(<span style="color: #800000;">&quot;special/any&quot;</span>)</pre></td></tr></table></div>

<p>We will create a Drag and drop event in TextArea1 Sub DropObject ()</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> text <span style="color: #000080;">As</span> TextInputStream
<span style="color: #000080;">Dim</span> f <span style="color: #000080;">As</span> FolderItem
&nbsp;
<span style="color: #000080;">do</span>
   <span style="color: #000080;">if</span> obj.FolderItemAvailable <span style="color: #000080;">then</span>
&nbsp;
    f = obj.FolderItem
&nbsp;
      <span style="color: #000080;">if</span> f &lt; &gt;  Nil <span style="color: #000080;">then</span> // f various Nil
        text =  f.OpenAsTextFile
        TextArea1.Text = text.ReadAll
        text.<span style="color: #000080;">close</span>
    <span style="color: #000080;">else</span>
        //User Cancelled
    <span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
&nbsp;
  <span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
<span style="color: #000080;">loop</span> <span style="color: #000080;">until</span> <span style="color: #000080;">not</span> obj.NextItem</pre></td></tr></table></div>

<p>As you can imagine if you will now drag and drop a text file to this control it will read and display the text inside the text file.</p>
<h2>Drag and drop image file from desktop into Canvas</h2>
<p>Getting a picture or graphic from desktop (or should say from hard drive) into Canvas using drag and drop method is similar to previous paragraph. Go to code editor and in Canvas1 Sub Open () enter code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">me.AcceptFileDrop(<span style="color: #800000;">&quot;special/any&quot;</span>)</pre></td></tr></table></div>

<p>Create a Drag and drop event in Canvas1 Sub DropObject ()</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> f <span style="color: #000080;">As</span> FolderItem
<span style="color: #000080;">Dim</span> p <span style="color: #000080;">As</span> Picture
&nbsp;
<span style="color: #000080;">do</span>
  <span style="color: #000080;">if</span> obj.FolderItemAvailable <span style="color: #000080;">then</span>
    f = obj.FolderItem
&nbsp;
    <span style="color: #000080;">if</span> f &lt; &gt;  Nil <span style="color: #000080;">then</span> // f various Nil
        p = f.OpenAsPicture  // load picture <span style="color: #000080;">to</span> memory
        Canvas1.Backdrop = p // load image from memory <span style="color: #000080;">to</span> canvas
    <span style="color: #000080;">else</span>
        //User Cancelled
    <span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
&nbsp;
  <span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
<span style="color: #000080;">loop</span> <span style="color: #000080;">until</span> <span style="color: #000080;">not</span> obj.NextItem</pre></td></tr></table></div>

<p>If you like you can add to this project some image manipulation techniques like fit to canvas, crop etc. from tutorial <a href="http://realbasic.tutspolis.com/tutorials/creating-imageviewer-in-realbasic/">Creating ImageViewer in REALbasic</a>.  See you next time!</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://realbasic.tutspolis.com/tutorials/drag-and-drop-images-text-controls-in-realbasic/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating ImageViewer in REALbasic</title>
		<link>http://realbasic.tutspolis.com/tutorials/creating-imageviewer-in-realbasic/</link>
		<comments>http://realbasic.tutspolis.com/tutorials/creating-imageviewer-in-realbasic/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 11:38:18 +0000</pubDate>
		<dc:creator>Jakub Pawlak</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[crop image]]></category>
		<category><![CDATA[drawpicture]]></category>
		<category><![CDATA[fit to canvas]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[imageviewer]]></category>
		<category><![CDATA[realbasic]]></category>
		<category><![CDATA[scale]]></category>

		<guid isPermaLink="false">http://realbasic.tutspolis.com/?p=97</guid>
		<description><![CDATA[<!-- isPostPurchased ,postID 97, userID 0, combination 1 -->
			
				
			
		
This tutorial will show you how can we create a simple image viewer with REALbasic using Canvas control. We will learn how can we open a image, how can we fit graphic to canvas, how can we crop the picture or display scaled image. Watch it, learn it, enjoy it!


Creating the GUI
Put on Window 3x [...]]]></description>
			<content:encoded><![CDATA[<!-- isPostPurchased ,postID 97, userID 0, combination 1 --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fcreating-imageviewer-in-realbasic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fcreating-imageviewer-in-realbasic%2F&amp;source=REALbasicCity&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>This tutorial will show you how can we create a simple image viewer with REALbasic using Canvas control. We will learn how can we open a image, how can we fit graphic to canvas, how can we crop the picture or display scaled image. Watch it, learn it, enjoy it!</p>
<p><span id="more-97"></span></p>
<div style="margin-left:19px;float:left">
<h2>Creating the GUI</h2>
<p>Put on Window 3x PushButton controls (open image, crop image, 50% size) and activate for each LockBottom and LockRight property. Add a CheckBox control (fit to canvas) and  activate LockBottom and LockLeft property. On finish insert on Window Canvas control and lock it to bottom, left, right and top.</p>
<p><img src="http://realbasic.tutspolis.com/files/tutorials/imageviewer/imageviewer-realbasic.jpg" alt="ImageViewer in REALbasic" /></p>
<h2>Load image from file to Canvas</h2>
<p>Double click on PushButton1 (Open image) and use this code to select and load a image to canvas. As you can see in this example we give as a option to load only a PNG file format. Of course it can be changed to other formats like JPG or BMP. Add now two New Properties &#8211; Declaration f As FolderItem and Declaration p As Picture.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> pngType <span style="color: #000080;">As</span> <span style="color: #000080;">New</span> FileType
&nbsp;
pngType.Name = <span style="color: #800000;">&quot;image/png&quot;</span>
pngType.MacType = <span style="color: #800000;">&quot;PNG &quot;</span>
pngType.Extensions = <span style="color: #800000;">&quot;png&quot;</span>
&nbsp;
f =GetOpenFolderItem(pngType)
&nbsp;
<span style="color: #000080;">if</span> f  &lt; &gt; Nil <span style="color: #000080;">then</span> // f various Nil
   p = f.OpenAsPicture  // load file <span style="color: #000080;">to</span> memory
   Canvas1.Backdrop = p // load image from memory <span style="color: #000080;">to</span> canvas
 <span style="color: #000080;">else</span>
    //User Cancelled
<span style="color: #000080;">end</span> <span style="color: #000080;">if</span></pre></td></tr></table></div>

<h2>Crop image</h2>
<p>Double click on PushButton2 (Crop image) control and fill the free space with code available below. We will now crop the full image size to 100&#215;100 by position x = 0 y = 0. The effect &#8211; we will simply crop the left top corner of our picture. If you like you can make for example a control to select a specify region of image to crop it.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">Canvas1.Refresh
&nbsp;
p = <span style="color: #000080;">New</span> Picture (p.Width,p.Height,32) //creating <span style="color: #000080;">new</span> picture (width, height, depth)
&nbsp;
p.Graphics.DrawPicture(f.OpenAsPicture,0,0,100,100,0,0,100,100)
&nbsp;
Canvas1.Backdrop = p // loading the picture from memory <span style="color: #000080;">to</span> Canvas1</pre></td></tr></table></div>

<h2>50% scaled image</h2>
<p>Double click on PushButton3 (50% Size). When the user will click on this button he will see on Canvas control scaled image by 50%. We get this effect by changing  picture width and picture height to 1/2 using * 0.5.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">Canvas1.Refresh
&nbsp;
p = <span style="color: #000080;">New</span> Picture (p.Width,p.Height,32) //creating <span style="color: #000080;">new</span> picture (width, height, depth)
&nbsp;
p.Graphics.DrawPicture(f.OpenAsPicture,0,0,p.Width * 0.5 ,p.Height * 0.5,0,0,p.Width,p.Height)
&nbsp;
Canvas1.Backdrop = p // loading the picture from memory <span style="color: #000080;">to</span> Canvas1</pre></td></tr></table></div>

<h2>Image fit to Canvas</h2>
<p>Our CheckBox1 control will be responsible for auto fitting the picture into Canvas. Add to Window1 Event Handlers Sub Resizing () our code. Now if our CheckBox1 i checked then when the user will resize the Window the image will allways fil into canvas in real time. You can also add this kind of code to CheckBox1 Sub Action () so the effect will be visible immediately when the user will click on this control.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">if</span> CheckBox1.value <span style="color: #000080;">then</span>
&nbsp;
Canvas1.Refresh
&nbsp;
p = <span style="color: #000080;">New</span> Picture (p.Width,p.Height,32) //creating <span style="color: #000080;">new</span> picture (width, height, depth)
&nbsp;
p.Graphics.DrawPicture(f.OpenAsPicture,0,0,Canvas1.Width,Canvas1.Height,0,0,p.Width,p.Height)
&nbsp;
Canvas1.Backdrop = p // loading the picture from memory <span style="color: #000080;">to</span> Canvas1
&nbsp;
 <span style="color: #000080;">else</span>
<span style="color: #000080;">end</span> <span style="color: #000080;">if</span></pre></td></tr></table></div>

<h2>Graphics.DrawPicture</h2>
<p>The last thing that we will learn in this tutorial is getting know what is going on in  Picture.Graphics.DrawPicture.  So, we have got here few parameters in  Graphics.DrawPicture (image, image x position on canvas, image y position on canvas, picture width to display, picture height to display, x position inside picture displayed on canvas, y position inside picture displayed on canvas, picture width to manipulate, picture height to manipulate). I hope that when you have not understand what is going on in p.Graphics.DrawPicture now it is clear.</p>
<h3>Download</h3>
<p>	<div class='ArePayPalContent'>
	<p class='ArePayPalTextToShowIfNotLogedIn'>If you see this message you probably want access special material for Premium Members (Source Files, Bonus Tutorials, free Classes and More). You can do this by subscribing REALbasic City site for 10 USD (access for 3 months). There is also a option to buy access only to this material. Login or register to get option to buy and support REALbasic City.</p>
	<a class='ArePayPalLoginButton' href='http://tutspolis.com/wp-login.php'>Log in</a>
	</div></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://realbasic.tutspolis.com/tutorials/creating-imageviewer-in-realbasic/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Drop Shadow effect in REALbasic</title>
		<link>http://realbasic.tutspolis.com/tutorials/drop-shadow-effect-in-realbasic/</link>
		<comments>http://realbasic.tutspolis.com/tutorials/drop-shadow-effect-in-realbasic/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 23:08:37 +0000</pubDate>
		<dc:creator>Jakub Pawlak</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[blending options]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[drop shadow]]></category>
		<category><![CDATA[picture]]></category>
		<category><![CDATA[realbasic]]></category>
		<category><![CDATA[save picture]]></category>
		<category><![CDATA[saveasjpeg]]></category>

		<guid isPermaLink="false">http://realbasic.tutspolis.com/?p=84</guid>
		<description><![CDATA[<!-- isPostPurchased ,postID 84, userID 0, combination 1 -->
			
				
			
		
This tutorial will teach you how can you create a simply drop shadow effect similar to Photoshop Blending Options called Drop Shadow. Of course its not the same technic but it will show you some ideas how can you make this effect. Watch it, learn it, enjoy it!


Creating the GUI
As usually we start creating our [...]]]></description>
			<content:encoded><![CDATA[<!-- isPostPurchased ,postID 84, userID 0, combination 1 --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fdrop-shadow-effect-in-realbasic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fdrop-shadow-effect-in-realbasic%2F&amp;source=REALbasicCity&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>This tutorial will teach you how can you create a simply drop shadow effect similar to Photoshop Blending Options called Drop Shadow. Of course its not the same technic but it will show you some ideas how can you make this effect. Watch it, learn it, enjoy it!</p>
<p><span id="more-84"></span></p>
<div style="margin-left:19px;float:left">
<h2>Creating the GUI</h2>
<p>As usually we start creating our application from building the graphic interface in REAlbasic. Try to get something similar to picture below. If you have some problems please find on our site tutorial called REALbasic – Learning the interface on Mac, Windows and Linux and come back letter.</p>
<p><img src="http://realbasic.tutspolis.com/files/tutorials/blendingoptions/dropshadow.png" alt="canvas drop shadow" /></p>
<p>We have here 4 StaticText controls (Text, Shadow X position, Shadow Y position, Shadow Opacity), 1 TextField control, 3 Slider controls, 1 Canvas control (the white field) and 1 PushButton &#8211; Save file.</p>
<p>In Slider1, Slider2 and Slider3 change in Property panel LiveScroll option to active, and in Initial State enter this values: Minimum: -10, Value: 20, Maximum: 50.</p>
<h3>Displaying the text in Canvas</h3>
<p>First add a New Property (create a global declaration) and type in Declaration p and in As Picture. Now go to TextField1 Sub TextChange() and insert this code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">Canvas1.Refresh // refreshing Canvas when typing
&nbsp;
p = <span style="color: #000080;">New</span> Picture (400,400,32) //creating <span style="color: #000080;">new</span> picture (width, height, depth)
p.Graphics.ForeColor = RGB(1,1,1) //making text color <span style="color: #000080;">to</span> black
p.Graphics.DrawString (TextField1.text,20,20,400) //drawing text
&nbsp;
Canvas1.Backdrop = p // loading the picture from memory <span style="color: #000080;">to</span> Canvas1</pre></td></tr></table></div>

<p>Now when we will put something in our Text field the Canvas1 will show in real time the result.</p>
<h2>Creating drop shadow effect</h2>
<p>On Wikipedia you can find information that shadow is an area where direct light from a light source cannot reach due to obstruction by an object. It occupies all of the space behind an opaque object with light in front of it. The cross section of a shadow is a two-dimensional silhouette, or reverse projection of the object blocking the light.</p>
<p>We can say simplifying that shadow or drop shadow effect is a reflect of a object, in our case reflect of some text. The way to get this kind of effect is duplicating the object and putting it in other X and Y position. Of course if we wont have more realistic results we should create other opacity for the shadow too. Opacity can be simply other hue of the original color.</p>
<p>On Slider1 at Shadow X position go to Sub ValueChanger () in Code Editor and insert the code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">Canvas1.Refresh  //refreshing Canvas when changing value
&nbsp;
p = <span style="color: #000080;">New</span> Picture (400,400,32)
p.Graphics.ForeColor = RGB(Slider3.Value+126,Slider3.Value+126,Slider3.Value+126) 
//generating color <span style="color: #000080;">for</span> shadow text (silver <span style="color: #000080;">like</span> color)
p.Graphics.DrawString (TextField1.Text,Slider1.Value,Slider2.Value,400)
//drawing shadow text beneath the text (text <span style="color: #000080;">string</span>, X position, Y position, width)
p.Graphics.ForeColor = RGB(1,1,1)
p.Graphics.DrawString (TextField1.text,20,20,220) //drawing text
&nbsp;
Canvas1.Backdrop = p //displaying the text <span style="color: #000080;">with</span> shadow</pre></td></tr></table></div>

<p>Duplicate the code in Slider 2 (Shadow Y position) and Slider 3 (Shadow opacity) too (Sub ValueChanger ()). The opacity goes smaller when the Slider3.Value goes right. In our example the difference between the min a max opacity values isn&#8217;t so big. Try to experiment with the min a max values to see better changes. PS. If you like you can make a method, we have learned this earlier, and call it in only one line in our slider controls. In this way you code can be smaller for some 18 lines.</p>
<h2>Saving Picture (Canvas) to JPEG file</h2>
<p>The last thing we will make today is saving our graphics displayed in Canvas or better say kept in memory Picture to a JPG file on our Desktop. We can do this in 3 lines&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"> <span style="color: #000080;">Dim</span> f <span style="color: #000080;">As</span> FolderItem //class objects represent files, applications, <span style="color: #000080;">or</span> folders
&nbsp;
 f=SpecialFolder.Desktop.Child(<span style="color: #800000;">&quot;test.jpg&quot;</span>) //getting info where <span style="color: #000080;">is</span> our desktop <span style="color: #000080;">and</span> indicate the file <span style="color: #000080;">to</span> save
 f.SaveAsJPEG p //saving the file <span style="color: #000080;">to</span> JPEG format</pre></td></tr></table></div>

<h2>Like this tutorial?</h2>
<p>If you like this or other tutorials please write a comment or simply click on retweet button and share it with others. Please have in mind that when our community will grow REALbasic City will offer more and better tutorials for everyone for free!</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://realbasic.tutspolis.com/tutorials/drop-shadow-effect-in-realbasic/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
