<?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>BolducPress, a web design blog &#187; Tutorials</title>
	<atom:link href="http://www.bolducpress.com/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bolducpress.com</link>
	<description>BolducPress is the blog of Joshua Bolduc, founder of the company - Part Digital Design</description>
	<lastBuildDate>Mon, 12 Apr 2010 16:13:31 +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>Using MySQL with the Command Line Client</title>
		<link>http://www.bolducpress.com/tutorials/using-mysql-with-the-command-line-client/</link>
		<comments>http://www.bolducpress.com/tutorials/using-mysql-with-the-command-line-client/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 04:01:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bolducpress.com/?p=992</guid>
		<description><![CDATA[The command line client is one of those tools this is used heavily by professionals and often neglected by beginners. Here is a great primer to get you familiar with the client and impress your friends :)]]></description>
			<content:encoded><![CDATA[<h2 class = "first">What you will need</h2>
<ul>
<li>A computer</li>
<li><a href = "http://www.wampserver.com/en/" target = "_blank">WAMP</a></li>
<li><a href='http://www.bolducpress.com/wp-content/uploads/2009/11/tutorial_db.zip'>A Sample Database</a></li>
</ul>
<h2>What is the command line client?</h2>
<p><img src="http://www.bolducpress.com/wp-content/uploads/2009/10/command_line.jpg" alt="Command Line Client" title="Command Line Client" width="601" height="346" class="alignnone size-full wp-image-993 img" /></p>
<p>The command line client is a program that allows you to work with your operating system via the use of scripts. You can use it to do practically anything in the operating environment including creating files and folders, executing programs and running MySQL scripts <img src='http://www.bolducpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<h2>Why use it?</h2>
<p>The client liberates you from your dependence on a graphical user interface (such as PHPMyAdmin) and gives you much more flexibility to work. Also, in a production environment you might not always have access to PHPMyAdmin so it&#8217;s very useful when you need to work with the SQL</p>
<h2>Setup the Server</h2>
<p>I use windows as my primary production environment, therefore I&#8217;m not going to show you how to setup a server on Mac or Linux.  Fortunately, the concept applies to all three operating systems with small variations in the syntax and procedure. Please do a search in google for more information about those platforms.</p>
<h3>Download and Install WAMP</h3>
<p>There are two great prepackaged builds for implementing your own development server, WAMP and XXAMP. I&#8217;ve tried them both over the years and prefer WAMP.  Feel free to use what you like though. </p>
<p>1. <a href = "http://www.wampserver.com/en/" target = "_blank">Download the WAMP Server Here</a></p>
<p>2. Double click the downloaded file and install the server. It should be pretty straightforward. </p>
<h3>Configure the environment variables</h3>
<p>Now with your server installed we&#8217;re going to configure the environment variables so it&#8217;s easy to access your MySQL server in the client. </p>
<p>If we didn&#8217;t do this we would have to go through these two steps before we can start using the server. </p>
<ul>
<li>We would first have to use the <strong>cd</strong> command to change to the server location of my mysql install. </li>
<li>Then we could finally start using the <strong>mysql</strong> to start using the server.</li>
</ul>
<p>Here&#8217;s what it would look like in the client. </p>
<p><img src="http://www.bolducpress.com/wp-content/uploads/2009/10/cmd_line_without_env.jpg" alt="Command Line Client Without Environment Variables" title="Command Line Client Without Environment Variables" width="600" height="346" class="alignnone size-full wp-image-995 img" /></p>
<p>I don&#8217;t know about you but I&#8217;m not going to be able to remember that path every time I log in. </p>
<p>So let&#8217;s make it a little easier. . .</p>
<p>1. In Windows go to <strong>Control Panel</strong> &gt; <strong>System and Security</strong> &gt; <strong>System</strong> &gt; <strong>Advanced System Settings</strong></p>
<p>2. On the <strong>Advanced</strong> tab, click the <strong>Environment Variables</strong> button.</p>
<p><img src="http://www.bolducpress.com/wp-content/uploads/2009/10/environment_vars_button.jpg" alt="environment_vars_button" title="environment_vars_button" width="431" height="478" class="img alignnone size-full wp-image-997" /></p>
<p>3. Select <strong>Path</strong> from the list of System Variables</p>
<p>4. Click </strong>Edit&#8230;</strong> you will see the following pop up. </p>
<p><img src="http://www.bolducpress.com/wp-content/uploads/2009/11/environment-variables.jpg" alt="Environment Variables" title="Environment Variables" width="600" height="448" class="img alignnone size-full wp-image-998" /></p>
<p>5. At the end of the string in <strong>Variable Value</strong> add the path to the mysql bin where you installed your MySQL server. </p>
<p>For example, I would add: </p>
<pre class="brush: sql;">
C:\Server\bin\mysql\mysql5.1.36\bin
</pre>
<p><strong>note:</strong> Be sure and separate each entry with a semicolon (<strong>;</strong>). And don&#8217;t add a space between them!</p>
<p>If done correctly that variable should look similar to this: </p>
<pre class="brush: sql;">
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Server\bin\mysql\mysql5.1.36\bin
</pre>
<p>6. Press <strong>Ok</strong> until you exit out of all the windows. </p>
<p>Your environment variables are set up!</p>
<h3>Create a shortcut on your desktop</h3>
<p>Next we&#8217;re going to create a convenient way to start the client and begin using MySQL right away!</p>
<p>1. Create a shortcut to the client by searching for <strong>cms</strong> in the Start Menu, and right clicking it. </p>
<p><img src="http://www.bolducpress.com/wp-content/uploads/2009/11/create-shortcut.jpg" alt="create-shortcut" title="create-shortcut" width="600" height="529" class="imgalignnone size-full wp-image-999 img" /></p>
<p>2. With the shortcut created on your desktop, right click it and choose <strong>Properties</strong></p>
<p>3. From the <strong>Shortcut</strong> tab change the <strong>Start in:</strong> string to the directory where you serve your web files. </p>
<p><img src="http://www.bolducpress.com/wp-content/uploads/2009/11/start-in.jpg" alt="start-in" title="start-in" width="387" height="530" class="alignnone size-full wp-image-1000 img" /></p>
<p>The <strong>Start In</strong> variable makes it much easier to work with files on your web server. All files that you access are in relation to that directory.  </p>
<p>4. Next go to the <strong>layout</strong> tab and apply the following settings. It makes it easier to work with the client from this size. </p>
<p><img src="http://www.bolducpress.com/wp-content/uploads/2009/11/window-size.jpg" alt="Window Size" title="Window Size" width="387" height="530" class="alignnone size-full wp-image-1001 img" /></p>
<p>5. Press <strong>OK</strong></p>
<p>The client is configured and ready to go!</p>
<p>Now lets do some SQL . .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolducpress.com/tutorials/using-mysql-with-the-command-line-client/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>From Photoshop to HTML</title>
		<link>http://www.bolducpress.com/tutorials/from-photoshop-to-html/</link>
		<comments>http://www.bolducpress.com/tutorials/from-photoshop-to-html/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 04:01:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bolducpress.com/?p=885</guid>
		<description><![CDATA[Learn how the professionals convert their designs from Photoshop to CSS and HTML  ]]></description>
			<content:encoded><![CDATA[<p><!--<a href = "http://www.psd2html.com/order-now.html" title = "PSD to HTML services" target = "_blank"><img src = "/wp-content/themes/bolducpress/images/p2h_ad.jpg" alt = "PSD to HTML Services" /></a>--></p>
<h2 class="first">Demos</h2>
<ul>
<li><a href="http://www.bolducpress.com/demos/photoshoptohtml/index.htm" target="_blank">Home Page</a></li>
<li><a href="http://www.bolducpress.com/demos/photoshoptohtml/about.htm" target="_blank">About Page</a></li>
<li><a href="http://www.bolducpress.com/demos/photoshoptohtml/styles.htm" target="_blank">CSS Styles Page</a></li>
</ul>
<h2>What you will need</h2>
<ul>
<li>Adobe Photoshop</li>
<li>Adobe Dreamweaver or another similar software package</li>
</ul>
<h2>Source Files</h2>
<ul>
<li><a href="http://www.bolducpress.com/wp-content/uploads/2009/08/psdtohtml-psd.zip">Download the PSD Files</a></li>
<li><a href="http://www.bolducpress.com/wp-content/uploads/2009/08/psdtohtml-html.zip">Download the HTML, CSS and image files</a></li>
</ul>
<h2>What we will make</h2>
<p>I will show you how to make a generic business template from the Photoshop file that is included with this tutorial.</p>
<h3>We aren&#8217;t making a website</h3>
<p>There is no one &#8220;right way&#8221; to  make a website. You can build it using basic html, CGI scripts or server scripting languages such as PHP or ASP.  In turn, each of these technologies can implemented in an almost infinite number of ways.<br />
Therefore, I decided to just teach you how to make a web template and leave it up to you to develop a working website. The good news though, is that as soon as you&#8217;re done this tutorial, you&#8217;ll be able to build your website anyway you want!</p>
<h3>Screen Shots</h3>
<h3><a href="http://www.bolducpress.com/wp-content/uploads/2009/08/screen01.jpg" target="_blank"><img class="alignnone size-full wp-image-889 img" title="Home Page Thumb" src="http://www.bolducpress.com/wp-content/uploads/2009/08/screen01_thumb.jpg" alt="Home Page Thumb" width="600" height="450" /></a></h3>
<h3><a href="http://www.bolducpress.com/wp-content/uploads/2009/08/screen02.jpg" target="_blank"><img class="alignnone size-full wp-image-890 img" title="About Page Thumb" src="http://www.bolducpress.com/wp-content/uploads/2009/08/screen02_thumb.jpg" alt="About Page Thumb" width="600" height="450" /></a></h3>
<h3><a href="http://www.bolducpress.com/wp-content/uploads/2009/08/screen03.jpg" target="_blank"><img class="alignnone size-full wp-image-891 img" title="Styles Page Thumb" src="http://www.bolducpress.com/wp-content/uploads/2009/08/screen03_thumb.jpg" alt="Styles Page Thumb" width="600" height="450" /></a></h3>
<h2>Let me know if anything is confusing</h2>
<p>Converting a Photoshop design to HTML is usually a very organic process, ie. I don&#8217;t follow a particular order of steps.  For the sake of this tutorial however, I&#8217;m going to keep everything very organized so that it&#8217;s easier to follow along. If you&#8217;re ever confused, please let me know in the comments and I&#8217;ll do what I can to make it more clear.</p>
<h2>We will not be using the design view</h2>
<p>This might disappoint a few people but I&#8217;m never going to use the design view. I&#8217;m only going to use the code view in Dreamweaver. Don&#8217;t worry though, it&#8217;s not as hard as you might think.</p>
<p>Ok now let&#8217;s get started!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolducpress.com/tutorials/from-photoshop-to-html/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>PHP Templates and why they will change your life.</title>
		<link>http://www.bolducpress.com/tutorials/php-templates-and-why-they-will-change-your-life/</link>
		<comments>http://www.bolducpress.com/tutorials/php-templates-and-why-they-will-change-your-life/#comments</comments>
		<pubDate>Wed, 01 Aug 2007 16:37:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bolducpress.com/?p=278</guid>
		<description><![CDATA[Templates are what separate the beginners from the pros. Learn how to build a basic template system here!]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h2>What you will need</h2>
<ul>
<li>A server with php installed.</li>
<li>A pure text editor. I like <a href="http://notepad-plus.sourceforge.net/uk/site.htm" target="_new">Notepad++</a>.</li>
</ul>
<h2>The Source</h2>
<p><a href="http://www.bolducpress.com/wp-content/uploads/2007/08/bolducpress-tutorial13.zip">Download the PHP Template Source Code</a></p>
<h2>Part One: What is a template system?.</h2>
<p>So exactly what is a template? Well according to the American Heritage dictionary, a template is . . .<br />
<em>&#8220;A document or file having a preset format, used as a starting point for a particular application so that the format does not have to be recreated each time it is used.&#8221;</em></p>
<p>You know what? They&#8217;re just about right!</p>
<p>So basically, a template system separates your HTML from your PHP. Let me say that again. <strong>A TEMPLATE SYSTEM SEPARATES YOUR HTML FROM YOUR PHP!</strong></p>
<p>Imagine the implications of this. You no longer have to use includes to add content to your website. You can<br />
create different skins and let the visitor choose what they want. You can generate lists and never<br />
have to write HTML like this . . .</p>
<pre class="brush: php;">$html = &quot;
&lt;ul&gt;
&lt;li&gt;Item 1&lt;/li&gt;
&lt;li&gt;Item 2&lt;/li&gt;
&lt;li&gt;Item 3&lt;/li&gt;
&lt;/ul&gt;&quot;;</pre>
<p>The possibilities are endless!</p>
<p>There is no better way to learn about template systems then to create your own so let&#8217;s get started!</p>
<h2>Part Two: Building your own template system.</h2>
<p>If you&#8217;ve read my other php tutorials, you probably have seen the code can be rather complex. Well I&#8217;ve got<br />
good news for you. . . this code is EXTREMELY easy.</p>
<p>Here is the concept behind how it works.</p>
<ul>
<li>Open a file and save the contents into a string.</li>
<li>Replace a string pattern (such as {VAR}) with a value.</li>
<li>Output it.</li>
</ul>
<p>There are only 81 lines of code for this script (and half of that is comments so get ready <img src='http://www.bolducpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
<p>Create a new file and name it <strong>template.php</strong></p>
<p>Copy and paste the following code into <strong>template.php</strong> please refer to the comments for explanation.</p>
<p><strong>Note:</strong> If you have never used Object Oriented Programming before I encourage you to read up on it<br />
and then come back. You can find a good tutorial <a href="http://www.onlamp.com/pub/a/php/2005/07/28/oo_php.html" target="_blank">here</a></p>
<pre class="brush: php;">class template
{
/*********************************************************************
VARIABLES
Setting our variables
*********************************************************************/
var $template; 			//The template name
var $template_string;    	//The template string will be stored here
var $prefix    = &quot;{&quot;; 		//The variable prefix character.
var $suffix    = &quot;}&quot;; 		//The variable suffix character.
var $var_array = array(); 	//The values of your variables will be stored here

/*********************************************************************
SET TEMPLATE
This function sets the file that we are going to be grabbing our
html from
*********************************************************************/
function set_template($filename)
{
$this-&gt;template = $filename;
}
/*********************************************************************
SET VARS
This function sets a value for a variable
*********************************************************************/
function set_var($name, $value)
{
//storing our variable and its value into an array
$this-&gt;var_array[$name] = $value;
}
/*********************************************************************
LOAD FILE
This function loads the contents of the template
file into a string.
*********************************************************************/
function load_file()
{
//saving its contents into a string
$this-&gt;template_string = file_get_contents($this-&gt;template);
}
/*********************************************************************
REPLACE VARS
This function replaces the variables with
it's corresponding values
*********************************************************************/
function replace_vars()
{
//The foreach loop is very useful when we want to loop through
//associative arrays.
foreach($this-&gt;var_array as $assoc =&gt; $value)
{
//appending the variable prefixes to match. ex: {VAR_NAME}
$var_name = $this-&gt;prefix.$assoc.$this-&gt;suffix;

//replacing every instance of the variable with it's corresponding value.
//so {VAR_NAME} becomes &quot;this is my variable&quot;
$this-&gt;template_string = str_replace($var_name, $value, $this-&gt;template_string);
}
}
/*********************************************************************
PARSE
This function calls the actions and outputs the
final result.
*********************************************************************/
function parse()
{
//loading the file
$this-&gt;load_file();

//setting the variables
$this-&gt;replace_vars();

//outputting the newly parsed template <img src='http://www.bolducpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
return $this-&gt;template_string;
}
}//end of class</pre>
<p>And that&#8217;s our whole template class!</p>
<h2>Part Three: Using your new template class.</h2>
<p>Ok. . . your new template class is done and ready to go. . . but how do you use it? By itself the class doesn&#8217;t seem all that remarkable. But trust me, it is.</p>
<p>To demonstrate we&#8217;re going to create a basic personal profile page.</p>
<p>Create a new file and name it <strong>interface.htm</strong> copy and paste the following code into <strong>interface.htm</strong></p>
<pre class="brush: xml;">
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
&quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
&lt;head&gt;
&lt;title&gt;{PAGE_TITLE}&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div style = &quot;margin:auto; width:800px; height:600px; border:solid 1px #808080&quot;&gt;
&lt;div style = &quot;height:70px; background:#c6c6c6; padding:5px&quot;&gt;
{PAGE_TITLE}
&lt;/div&gt;
&lt;div style = &quot;padding:5px&quot;&gt;{CONTENT}&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Do you notice {PAGE_TITLE} and {CONTENT}? Guess what. . . .those are variables! That&#8217;s right! With a template systemyou can embed variables right into HTML! Are you starting see what I&#8217;m getting at? <img src='http://www.bolducpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Open up <strong>interface.htm</strong> in a browser, it should look something like this.</p>
<p><img class="size-full wp-image-307 clear aligncenter img" title="Screenshot of File" src="http://www.bolducpress.com/wp-content/uploads/2007/08/001.jpg" alt="Screenshot of File" width="450" height="336" /></p>
<p>Create a new php file and name it <strong>index.php</strong>, save it in the same directory as<strong>template.php</strong>.</p>
<p>Take a look at the code below.</p>
<pre class="brush: php;">//This loads template.php into memory
//(you can also use include, they both do the same thing)
require_once(&quot;template.php&quot;);

/*******************************************
INTERFACE
*******************************************/
//creating a new instance of our template class
$interface = new template;

//setting the template file that I want to grab html from
$interface-&gt;set_template(&quot;interface.htm&quot;);

//outputting the interface
print $interface-&gt;parse(); </pre>
<p>Open up <strong>index.php</strong> in your browser. See any difference? You shouldn&#8217;t. Take a look at the source code, it&#8217;s<br />
exactly the same as  <strong>template.htm</strong> You&#8217;re grabbing the content inside template.htm, saving it as a string<br />
and then printing it.</p>
<p>Ok let&#8217;s make one more template.</p>
<p>Make a new file and name it <strong>profile.htm</strong> Copy and paste the following code into your new file.</p>
<pre class="brush: xml;">
&lt;div style = &quot;margin-bottom:10px&quot;&gt;
This is the profile for {NAME}
&lt;/div&gt;

&lt;table width = &quot;100%&quot;&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;img src = &quot;{PROFILE_PIC}&quot; /&gt;
&lt;/td&gt;
&lt;td&gt;
Name:{NAME}
&lt;br /&gt;Birthday: {BIRTHDAY}
&lt;br /&gt;Phone: {PHONE}
&lt;br /&gt;E-Email:{EMAIL}
&lt;br /&gt;Bio: {BIO}
&lt;/td&gt;
&lt;/table&gt;
</pre>
<p>Notice the omission of the html, head and body tags.</p>
<p>Open up <strong>profile.htm</strong> in your browser, it should look something like this.</p>
<p><img class="size-full wp-image-308 aligncenter img" title="Screen Shot of Template Profile" src="http://www.bolducpress.com/wp-content/uploads/2007/08/003.jpg" alt="Screen Shot of Template Profile" width="450" height="230" /></p>
<p>Grab any image you like and name it <strong>pic.jpg</strong> save it in the same directory.</p>
<p>Your directory should look like this.</p>
<p><img class="size-full wp-image-309 aligncenter img" title="Screenshot of folders" src="http://www.bolducpress.com/wp-content/uploads/2007/08/002.jpg" alt="Screenshot of folders" width="450" height="389" /></p>
<p><strong>Note:</strong> Given the nature of operating systems your icons may not resemble mine.</p>
<p>All right, let&#8217;s put these two templates together.</p>
<p>Open up <strong>index.php</strong> again and right above where you created a new instance of your interface class write this code.</p>
<pre class="brush: php;">/*******************************************
PROFILE
*******************************************/
$profile = new template;
$profile-&gt;set_template(&quot;profile.htm&quot;);

//setting the variable values
$profile-&gt;set_var('PROFILE_PIC', &quot;pic.jpg&quot;);
$profile-&gt;set_var('NAME',        &quot;Josh&quot;);
$profile-&gt;set_var('BIRTHDAY',    &quot;08/03/1985&quot;);
$profile-&gt;set_var('EMAIL',       &quot;joshua.bolduc@gmail.com&quot;);
$profile-&gt;set_var('PHONE',       &quot;555-555-3452&quot;);
$profile-&gt;set_var('BIO', 	 &quot;This is some kind of dynamically generated bio&quot;);

//compiling the information and saving the string into a variable
$content    = $profile-&gt;parse();

//setting the page title
$page_title = &quot;Personal Profile&quot;;</pre>
<p><strong>index.php</strong> should look like this.</p>
<pre class="brush: php;">//This loads template.php into memory (you can also use include, they both do the same thing)
require_once(&quot;template.php&quot;);

/*******************************************
PROFILE
*******************************************/
$profile = new template;
$profile-&gt;set_template(&quot;profile.htm&quot;);

//setting the variable values
$profile-&gt;set_var('PROFILE_PIC', &quot;pic.jpg&quot;);
$profile-&gt;set_var('NAME',        &quot;Josh&quot;);
$profile-&gt;set_var('BIRTHDAY',    &quot;08/03/1985&quot;);
$profile-&gt;set_var('EMAIL',       &quot;joshua.bolduc@gmail.com&quot;);
$profile-&gt;set_var('PHONE',       &quot;555-555-3452&quot;);
$profile-&gt;set_var('BIO', 	 &quot;This is some kind of dynamically generated bio&quot;);

//compiling the information and saving the string into a variable
//see where this variable goes in the $interface template?
$content    = $profile-&gt;parse();

//setting the page title
//see where this variable goes in the $interface template?
$page_title = &quot;Personal Profile&quot;;

/*******************************************
INTERFACE
*******************************************/
//creating a new instance of our template class
$interface = new template;

//setting the template file that I want to grab html from
$interface-&gt;set_template(&quot;interface.htm&quot;);

//setting the variables for the interface
$interface-&gt;set_var('CONTENT',    $content);
$interface-&gt;set_var('PAGE_TITLE', $page_title);

//outputting the interface
print $interface-&gt;parse();</pre>
<p>Do you notice above I&#8217;m not actually doing a lot of &#8220;coding?&#8221;. I&#8217;m just setting values and then outputting. Nothing</p>
<p>could be easier!</p>
<p>Open up <strong>index.php</strong> in your browser, it should look like something like this.</p>
<p><a href="http://www.bolducpress.com/wp-content/uploads/2007/08/17_004.jpg"><img class="aligncenter size-full wp-image-427 img" title="17_004" src="http://www.bolducpress.com/wp-content/uploads/2007/08/17_004.jpg" alt="17_004" width="450" height="336" /></a></p>
<p>So do you see the advantages of this technique? By keeping the interface separate from the content (such as the profile) we can make one change to the interface and it will change for everything! no need to touch any other files. That&#8217;s what makes skinning possible!</p>
<h2>Conclusion</h2>
<p>Templates open up a whole new world of possibilities in php. Learn it well!</p>
<p>I hope this was helpful, if you have any questions or suggestions feel free post in my comments.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolducpress.com/tutorials/php-templates-and-why-they-will-change-your-life/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>How to make custom avatars with PHP</title>
		<link>http://www.bolducpress.com/tutorials/how-to-make-custom-avatars-with-php/</link>
		<comments>http://www.bolducpress.com/tutorials/how-to-make-custom-avatars-with-php/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 14:37:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bolducpress.com/?p=214</guid>
		<description><![CDATA[Learn how to use php to make a customizable avatar. A great and unique feature for any website! ]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h2>Introduction</h2>
<p>In this tutorial I&#8217;m going to show you how to create customizable avatar icons with php. This is a great feature that isn&#8217;t seen that<br />
often around the internet and I think should be used more. So let&#8217;s get started.</p>
<h2>What you will need</h2>
<ul>
<li>Adobe Photoshop.</li>
<li>A pure text editor. I like <a href="http://notepad-plus.sourceforge.net/uk/site.htm" target="_new">Notepad++</a>.</li>
</ul>
<h2>The Source Files</h2>
<p><a href="http://www.bolducpress.com/wp-content/uploads/2007/07/bolducpress-tutorial12.zip">Download the PHP and Photoshop Files</a></p>
<h2>Part One: Creating the images.</h2>
<p>Before we begin coding let&#8217;s open up Photoshop and play around with our image for a bit. There are few things you need<br />
to remember when you&#8217;re creating images for this project.</p>
<ul>
<li>Every image MUST have the same dimensions.</li>
<li>The background MUST be transparent.</li>
<li>Each image MUST be saved in <strong>24 bit .png</strong> format.</li>
</ul>
<p>Open up your image in photoshop, (for the sake of this tutorial I&#8217;m going to assume you used the picture<br />
of Brian from Family Guy.  It&#8217;s called <strong>original.jpg</strong> and it&#8217;s included in the zip file.).</p>
<p><img class="aligncenter size-full wp-image-437 img" title="12_001" src="http://www.bolducpress.com/wp-content/uploads/2007/07/12_001.jpg" alt="12_001" width="209" height="300" /></p>
<p>This step is all about creativity. As I was looking at this image I was thinking to myself. &#8220;Ok what<br />
can I do to change this picture up a little bit? I can give him some pants, some shoes, a hat, I can change<br />
his martini. . . &#8221; There were many things I could do with it.</p>
<p>I will quickly show you my workflow for creating accessories.</p>
<p>I grabbed the original image and used the magic wand tool to select and delete the background. I also removed Seth McFarlane&#8217;s (a genius by the way) signature.</p>
<p><img class="aligncenter size-full wp-image-438 img" title="12_002" src="http://www.bolducpress.com/wp-content/uploads/2007/07/12_002.jpg" alt="12_002" width="414" height="295" /></p>
<p>I created a new layer above the base layer and named it <strong>hat</strong>.</p>
<p><img class="aligncenter size-full wp-image-439 img" title="12_003" src="http://www.bolducpress.com/wp-content/uploads/2007/07/12_003.jpg" alt="12_003" width="216" height="361" /></p>
<p>Using my <a href="http://www.wacom.com/intuos/medium.php">Wacom Tablet</a>, I drew a baseball cap on his head. I could hide and show it using the layers palette. (Make sure that you draw your accessories on separate layers, this is what makes customization possible.)</p>
<p><img class="aligncenter size-full wp-image-440 img" title="12_004" src="http://www.bolducpress.com/wp-content/uploads/2007/07/12_004.jpg" alt="12_004" width="404" height="299" /></p>
<p>Once I was happy with the hat I hid it and saved the image of brian as <strong>Base.png</strong>.</p>
<p>It&#8217;s crucial that you save the image as 24 bit png image. If you don&#8217;t the image won&#8217;t look right. Make sure that transparency is selected as well..</p>
<p><img class="aligncenter size-full wp-image-441 img" title="12_005" src="http://www.bolducpress.com/wp-content/uploads/2007/07/12_005.jpg" alt="12_005" width="233" height="240" /></p>
<p>Then I saved the hat image as <strong>hat.png</strong> keeping the same settings as before.</p>
<p><img class="aligncenter size-full wp-image-442 img" title="12_006" src="http://www.bolducpress.com/wp-content/uploads/2007/07/12_006.jpg" alt="12_006" width="202" height="299" /></p>
<p>That&#8217;s the basic process that I went through. Pretty straight forward. I repeated this process for additional accessories. If you like, add some of your own unique ideas, perhaps a scarf or a tie. You may also use the images that I&#8217;ve included.</p>
<p>Now let&#8217;s start playing with some code. . .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolducpress.com/tutorials/how-to-make-custom-avatars-with-php/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>From PSD to HTML</title>
		<link>http://www.bolducpress.com/tutorials/from-psd-to-html/</link>
		<comments>http://www.bolducpress.com/tutorials/from-psd-to-html/#comments</comments>
		<pubDate>Fri, 06 Jul 2007 15:52:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bolducpress.com/?p=290</guid>
		<description><![CDATA[Learn how to slice up your design and then use CSS and HTML to turn it into a powerful web interface.]]></description>
			<content:encoded><![CDATA[<p><!--<a href = "http://www.psd2html.com/order-now.html" title = "PSD to HTML services" target = "_blank"><img src = "/wp-content/themes/bolducpress/images/p2h_ad.jpg" alt = "PSD to HTML Services" /></a>--></p>
<div class = "post-featured">
<h2 class = "first">Check out my new Photoshop to HTML tutorial!</h2>
<p>I&#8217;ve released a new tutorial that goes into more depth and creates a better final result!</p>
<p>Check it out: <a href = "http://www.bolducpress.com/tutorials/from-photoshop-to-html/">From Photoshop to HTML</a>
</div>
<h2>What we will make</h2>
<p>In this tutorial I&#8217;m going to show you how to take the design created for my <a href="/tutorials/fundamentals-of-interface-design/"><br />
Fundamentals of Interface Design</a> tutorial and turn that into a usable web interface.</p>
<h2>What you will need</h2>
<ul>
<li>Adobe Photoshop.</li>
<li>The PSD File which can be downloaded below</li>
<li>A pure text editor. I like <a href="http://notepad-plus.sourceforge.net/uk/site.htm" target="_new">Notepad++</a>.</li>
</ul>
<h2>The Source</h2>
<p><a href="http://www.bolducpress.com/wp-content/uploads/2007/07/bolducpress-tutorial11.zip">Download the PSD and HTML files</a></p>
<h2>A Note about WYSIWYG Editors</h2>
<p>I don&#8217;t use WYSIWG editors like Adobe Dreamweaver.  Therefore don&#8217;t be surprised if you find yourself doing a bit of coding. Don&#8217;t worry though, it won&#8217;t hurt too much <img src='http://www.bolducpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>Part One: Visualizing the CSS and HTML.</h2>
<p>Before I begin anything I take an objective look at my interface. What can I create using CSS/HTML? What do I need to slice? This saves me time and often gets me the cleanest results.</p>
<p><img class="aligncenter size-full wp-image-453 img" title="11_001" src="http://www.bolducpress.com/wp-content/uploads/2007/07/11_001.jpg" alt="11_001" width="450" height="338" /></p>
<p>What sections do you see?</p>
<p>This is what I&#8217;m thinking to myself as I do this.</p>
<p>The following can be achieved with CSS</p>
<ul>
<li>The interface size and placement.</li>
<li>The text and link colors, size, etc.</li>
<li>The panel placement, size, border and background color.</li>
<li>The borders on the icons.</li>
<li>The Horizontel line between sections in the body.</li>
</ul>
<p>The following will need to be sliced up.</p>
<ul>
<li>The header icons (including the active page icon).</li>
<li>The header graphics, including logo and &#8220;Part Digital Designs&#8221; text.</li>
<li>the header background color.</li>
<li>The Background gradient.</li>
<li>The gradient color of the panel headers.</li>
<li>The footer.</li>
<li>One of the navigation triangles.</li>
</ul>
<h2>Part Two: Slicing the interface.</h2>
<p>I work simultaneously between slicing and CSS/HTML. This is fastest method I&#8217;ve found when working on a personal project. However if you are working in a group it&#8217;s best to keep each step separate.</p>
<p><strong>Note:</strong> For the sake of this tutorial I&#8217;m going to stick with Photoshop. However, if you have it, I highly recommend Adobe Image Ready or Adobe Fireworks for slicing up your images.</p>
<p>Ok let&#8217;s get started.</p>
<p>Open the file that I&#8217;ve included for this tutorial.</p>
<h3>Your First Slice</h3>
<p>Press <strong>K</strong> to select the slice tool and draw a box around the logo and title as shown.</p>
<p><img class="aligncenter size-full wp-image-454 img" title="11_002" src="http://www.bolducpress.com/wp-content/uploads/2007/07/11_002.jpg" alt="11_002" width="400" height="120" /></p>
<p>Right click this slice and click <strong>Edit Slice Options</strong>. Name it <strong>header_title</strong> and click <strong>OK</strong>.</p>
<p><img class="aligncenter size-full wp-image-455 img" title="11_003" src="http://www.bolducpress.com/wp-content/uploads/2007/07/11_003.jpg" alt="11_003" width="351" height="224" /></p>
<p>Remember these two steps as we slice up the interface because from now on I&#8217;m not going to be as detailed<br />
in my explanations.</p>
<p>Create another slice near the one you just made that is <strong>1</strong> pixel wide and name it <strong>header_bg</strong>. It should look like the image below.</p>
<p><img class="aligncenter size-full wp-image-456 img" title="11_004" src="http://www.bolducpress.com/wp-content/uploads/2007/07/11_004.jpg" alt="11_004" width="450" height="284" /></p>
<p>Create a slice around the home icon (including the selcted graphic) and name it <strong>icon_home</strong>. Make sure it has a width of <strong>60</strong> pixels and a height of<strong> 54</strong> pixels.</p>
<p><img class="aligncenter size-full wp-image-458 img" title="11_006" src="http://www.bolducpress.com/wp-content/uploads/2007/07/11_006.jpg" alt="11_006" width="450" height="269" /></p>
<p>Repeat the process for the remaining icons.</p>
<p>Create a slice at the home panel header that is <strong>1</strong> pixel wide and <strong>19</strong> pixels high. Name it <strong>panel_bg</strong></p>
<p><img class="aligncenter size-full wp-image-459 img" title="11_007" src="http://www.bolducpress.com/wp-content/uploads/2007/07/11_007.jpg" alt="11_007" width="450" height="242" /></p>
<p>Create a slice around one of the triangles and name it <strong>triangle-idle</strong>. Give it a width and height of <strong>13</strong> pixels.<br />
<strong>Quick Tip:</strong> Hold down <strong>Shift</strong> as you draw the slice and it will make a perfect square.</p>
<p><img class="aligncenter size-full wp-image-460 img" title="11_008" src="http://www.bolducpress.com/wp-content/uploads/2007/07/11_008.jpg" alt="11_008" width="250" height="139" /></p>
<p>Create a slice around the entire footer and name it <strong>footer</strong></p>
<p><img class="aligncenter size-full wp-image-461 img" title="11_009" src="http://www.bolducpress.com/wp-content/uploads/2007/07/11_009.jpg" alt="11_009" width="450" height="340" /></p>
<p>Go to <strong>File &gt; Save for web or devices</strong>.</p>
<div id="attachment_462" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.bolducpress.com/wp-content/uploads/2007/07/11_010-big.jpg" target="_blank"><img class="size-full wp-image-462" title="11_010" src="http://www.bolducpress.com/wp-content/uploads/2007/07/11_010.jpg" alt="11_010" width="450" height="347" /></a><p class="wp-caption-text">Click for a larger view</p></div>
<p>Make sure that the image type is set to <strong>GIF</strong></p>
<p>Click <strong>Save</strong> and make sure your settings match these.</p>
<p><img class="aligncenter size-full wp-image-464 img" title="11_011" src="http://www.bolducpress.com/wp-content/uploads/2007/07/11_011.jpg" alt="11_011" width="450" height="122" /></p>
<p>Click <strong>Save</strong></p>
<p>OK, we haven&#8217;t sliced up everything yet, but we have enough to get started. So minimize Photoshop for now and open up your favorite pure text editor.</p>
<p>Now let&#8217;s start to build the interface in HTMl. . .</p>
<p><!--<a href = "http://www.psd2html.com/order-now.html" title = "PSD to HTML services" target = "_blank"><img src = "/wp-content/themes/bolducpress/images/p2h_ad.jpg" alt = "PSD to HTML Services" /></a>--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolducpress.com/tutorials/from-psd-to-html/feed/</wfw:commentRss>
		<slash:comments>120</slash:comments>
		</item>
		<item>
		<title>Fundamentals of Interface Design</title>
		<link>http://www.bolducpress.com/tutorials/fundamentals-of-interface-design/</link>
		<comments>http://www.bolducpress.com/tutorials/fundamentals-of-interface-design/#comments</comments>
		<pubDate>Tue, 26 Jun 2007 00:54:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bolducpress.com/?p=180</guid>
		<description><![CDATA[Learn the fundamentals of interface design in this simple, straightforward tutorial.]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>In this tutorial I&#8217;m going to show you how to design a portfolio website and also introduce you to some of the<br />
major issues that every web designer has to consider.</p>
<p>note: I&#8217;m not going to cover every detail bit by bit. It&#8217;s assumed that you have at least a basic understanding<br />
of photoshop.</p>
<div class="tutorials">
<h2>What you will need</h2>
<ul>
<li>A paper and pencil.</li>
<li>Adobe Photoshop.</li>
</ul>
<h2>Part One: Conceptualization.</h2>
<h3>What kind of website is it?</h3>
<p>Ok so you want to make a website. . .but what is it going to be about? If you don&#8217;t know then making a website is impossible. Take out a piece of paper and a pencil and jot down a few ideas. Also think about what additional sections might be needed. For instance if you do a portfolio website, you&#8217;ll also need a contact page, and maybe even a news section.</p>
<h3>Will your website grow?</h3>
<p>Will this be a big website? If so, you need to consider the implications of growth. You&#8217;ll need to design it so that many people can access a wealth of information quickly and easily. You&#8217;ll also want to make it easy to add sections (while not affecting the content).</p>
<h3>Branding</h3>
<p>What about theme and branding? What impression do you want people to get from this? Do you want your website to be immediatly recognizable just from the look alone? Branding is a widely used stragegy in business, for instance the Apple computer company is recognizable in all their products by their elegant use of glossy white and smooth edges.</p>
<p><img class="aligncenter size-full wp-image-508 img" title="07_001" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_001.jpg" alt="07_001" width="450" height="243" /></p>
<p>Also notice that they both share a similar name &#8220;iMac and iPod.&#8221; So not only are they branded through appearence but by name as well. Through this ingenius strategy they&#8217;re one of the most recognizable companies on the planet.</p>
<h3>Who will be my audience?</h3>
<p>What kind of people are going to be using your website? If you make a tutorial website like<br />
<a href="http://www.pixel2life.com">pixel2life.com</a> then it&#8217;s a fair chance that the majority of users will have larger monitors with modern browsers. In this case you could design your website to be larger and have some more advanced features (such as AJAX).</p>
<p>Take all these into consideration as you write down ideas for your website, it will make design and development much easier.</p>
<h2>Part Two: What will your layout be?</h2>
<p>In the web development world there a select few layout designs that have been considered the standard</p>
<div class="alignleft">
<h3>One Column Layout</h3>
<p><img class="size-full wp-image-509 img alignleft" title="07_002" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_002.jpg" alt="07_002" width="250" height="300" /></p>
<div class="alignleft width-50">
<h4>Advantages:</h4>
<p>This is good at putting a lot of emphasis on one particular article or image. As a result this is best suited for galleries of images.</p>
<h4>Disadvantages</h4>
<p>This isn&#8217;t necessarily the best layout for a lot of information. If you have just a few pages in your website<br />
then it&#8217;s fine but if it starts to grow and you get more sections then the limitations quickly become apparent.</p></div>
</div>
<div class="clear">
<h3>Two Column Layout</h3>
<p><img class="size-full wp-image-510 img alignleft" title="07_003" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_003.jpg" alt="07_003" width="250" height="300" /></p>
<div class="alignleft width-50">
<h4>Advantages:</h4>
<p>This layout is frequently seen throughout the internet, and rightly so, it&#8217;s an elegant solution for small to medium sized websites. With the navigation on the top and side it offers more opportunity for growth.</p>
<h4>Disadvantages</h4>
<p>There are still a few limitations however. Especially when you get into subsections. This layout only allows a maximum of 2 levels of depth. You also sacrifice real estate for your navigation.</p></div>
</div>
<div class="clear">
<h3>Three Column Layout</h3>
<p><img class="size-full wp-image-511 img alignleft" title="07_004" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_004.jpg" alt="07_004" width="250" height="300" /></p>
<div class="alignleft width-50">
<h4>Advantages:</h4>
<p>This is the most frequently seen layout in the web. With three different places for navigation, growth is almost<br />
seamless. You can easily have up to three levels of navigation (which is the most you want anyway) and your eye easily drifts from one section to another.</p>
<h4>Disadvantages</h4>
<p>The biggest disadvantage of this however is things can get very cramped, very fast (depending on the size of your website).</p></div>
</div>
<h3 class="clear">Other Layouts</h3>
<p>Obviously these aren&#8217;t the only layouts, try playing with four column layouts or something wild and crazy in flash.</p>
<h3>Fluid or Fixed?</h3>
<p>What kind of layout will this be? Fluid or Fixed? A fluid layout can adjust its size for any screen but has certain graphic limitations. A fixed layout is stuck at a certain resolution and my not be viewable on certain screens, but is much easier to design for. Think of your audience when you&#8217;re deciding this.</p>
<h2 class="clear">Part Three: Visualizing the Layout</h2>
<p>Before I begin any work on a computer I sketch out some ideas on paper. This step is extremely important as it&#8217;s all about creativity. By sketching things out you don&#8217;t have to worry about any technical challenges beyond using a pencil. (If a pencil is a challege for you, you may want to try another tutorial first :p).</p>
<h3>Sketch #1</h3>
<p>This is my first sketch for the interface. I know I wanted a three column layout so I immediatly started with that. I liked the number of panels that I had but it still felt a bit off.</p>
<p><img class="aligncenter size-full wp-image-512 img" title="07_005" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_005.jpg" alt="07_005" width="450" height="339" /></p>
<h3>Sketch #2</h3>
<p>I kept working with that sketch to see if it developed into something I liked. The more I worked with it the more I liked the placement of the panels but the less I liked the rounded edges. I also felt that the portfolio section could be improved.</p>
<p><img class="aligncenter size-full wp-image-513 img" title="07_006" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_006.jpg" alt="07_006" width="450" height="339" /></p>
<h3>Sketch #3</h3>
<p>I started over on my sketch and finally came up with something I felt had potential. The portfolio section was greatly simplified and I sharpened the edges of the panels.</p>
<p><img class="aligncenter size-full wp-image-514 img" title="07_007" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_007.jpg" alt="07_007" width="450" height="339" /></p>
<h3>Sketch #4</h3>
<p>Then I started to play with color composition. I hadn&#8217;t done much with light blue for a while so I decided to use that as my base.<br />
<img class="aligncenter size-full wp-image-515 img" title="07_008" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_008.jpg" alt="07_008" width="450" height="339" /></p>
<p>Notice that these sketches are very loose and there isn&#8217;t that much detail at all. All these are is a tool to get ideas flowing in my head. As I was doing this I was already making final decisions about how I wanted the final website to look.</p>
<p>OK, now let&#8217;s open Photoshop. . .</p>
<h2>Part Four: The Body</h2>
<p>Open up photoshop and make a new document. Set its size to the standard <strong>800 x 600</strong> pixels.</p>
<p>Press <strong>U</strong> to select the rectangle tool, make sure that the <strong>Rounded Rectangle Tool</strong> is selected. Set the radius to <strong>10px</strong>.</p>
<p>Draw a rectangle from the top left hand corner of the canvas to the bottom right of the canvas. Don&#8217;t worry about the color, we&#8217;ll adjust that later.</p>
<p><img class="aligncenter size-full wp-image-528 img" title="07_021" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_021.jpg" alt="07_021" width="300" height="230" /></p>
<p>Change the <strong>Rounded Rectangle Tool</strong> to the <strong>Rectangle Tool</strong>. Click <strong>+</strong> on the keyboard (or click<strong> Add to Shape Area</strong>).Draw a rectangle at the top to remove the round corner. Note that the change of color is for demonstration purposes and yours will not look like that.</p>
<p><img class="aligncenter size-full wp-image-529 img" title="07_022" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_022.jpg" alt="07_022" width="300" height="230" /></p>
<p>You should have a shape with round corners at the bottom and sharp corners at the top.</p>
<p>With the shape layer selected click the little <strong>F</strong> at the bottom of the layers palette to bring up the layer effects dialog. Click <strong>Gradient Overlay</strong> and apply these settings.</p>
<p><img class="aligncenter size-full wp-image-530 img" title="07_023" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_023.jpg" alt="07_023" width="320" height="379" /></p>
<p>Click <strong>Stroke</strong> in the layer effect dialog and apply these settings.</p>
<p><img class="aligncenter size-full wp-image-531 img" title="07_024" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_024.jpg" alt="07_024" width="324" height="220" /></p>
<p>It should look something like this.</p>
<p><img class="aligncenter size-full wp-image-532 img" title="07_025" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_025.jpg" alt="07_025" width="350" height="263" /></p>
<p>Ok now lets add a footer.</p>
<h2>Part Five: The Footer</h2>
<p>Create a new Group in the layers palette, name it <strong>Footer</strong>.</p>
<p>Create a new layer in that group, name it <strong>Base</strong>.</p>
<p>With <strong>Base</strong> selected, <strong>Ctrl-Left Click</strong> the shape mask in the layers pallette to make a selection. Hold down <strong>Alt</strong> and drag a box to deselect to top portion of the shape. Fill that selection with <strong>3c4549</strong>.</p>
<p>Draw a thin white rectangle shape over <strong>Base</strong>.</p>
<p>It should look something like this.</p>
<p><img class="aligncenter size-full wp-image-533 img" title="07_026" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_026.jpg" alt="07_026" width="350" height="263" /></p>
<h2>Part Six: The Header</h2>
<p>For the header I wanted to make a slightly futuristic feel but also keep the feel of my current website.</p>
<p>Draw a rectangle at the top of the canvas and apply these layer effects.</p>
<p><img class="aligncenter size-full wp-image-534 img" title="07_027" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_027.jpg" alt="07_027" width="320" height="372" /></p>
<p>Then draw a thin white rectangle and set its opacity to <strong>28%</strong> It should look something like this</p>
<p><img class="aligncenter size-full wp-image-535 img" title="07_028" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_028.jpg" alt="07_028" width="350" height="264" /></p>
<h3>The Icons</h3>
<p>I&#8217;m not going to cover how I made every single icon, instead I&#8217;ll show you my technique I used for one and then you can use that to make your own <img src='http://www.bolducpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>I started with a sketch first.<br />
<img class="aligncenter size-full wp-image-518 img" title="07_011" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_011.jpg" alt="07_011" width="260" height="260" /></p>
<p>Then I added paths in photoshop.</p>
<p><img class="aligncenter size-full wp-image-519 img" title="07_012" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_012.jpg" alt="07_012" width="260" height="260" /></p>
<p>I pasted the image onto the header bar and added an outer glow filter.</p>
<p><img class="aligncenter size-full wp-image-520 img" title="07_013" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_013.jpg" alt="07_013" width="260" height="260" /></p>
<p>With all the icons and text, it should look something like this.</p>
<p><img class="aligncenter size-full wp-image-536 img" title="07_029" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_029.jpg" alt="07_029" width="450" height="339" /></p>
<p>The selected icon graphic was very simple, I just made a rectangle shape and applied these settings.<br />
<img class="aligncenter size-full wp-image-537 img" title="07_030" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_030.jpg" alt="07_030" width="320" height="328" /></p>
<p>Then I drew a white shape on top of that rectangle and set its opacity to <strong>14%</strong></p>
<p>And this is what it looks like.</p>
<p><img class="aligncenter size-full wp-image-538 img" title="07_031" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_031.jpg" alt="07_031" width="375" height="92" /></p>
<p>For the logo I already had the one that I made for my first website so I just grabbed that and resized it.</p>
<p>The font for the text was Arial. I also applied a light gradient to it. I&#8217;m going to leave this up to you. Have fun! <img src='http://www.bolducpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Your interface should look something like this now.</p>
<p><img class="aligncenter size-full wp-image-539 img" title="07_032" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_032.jpg" alt="07_032" width="450" height="338" /></p>
<h2>Part Seven: The Portfolio Menu</h2>
<p>The portfolio menu is pretty straight forward. I wanted to differentiate the portfolio navigation from the rest of the site. I wanted the visitor to get the impression that this was a special navigation, separate from the rest of the site. I also wanted to keep it simple so that the user already knew how it worked.<br />
<img class="aligncenter size-full wp-image-522 img" title="07_015" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_015.jpg" alt="07_015" width="135" height="177" /></p>
<p>With the portfolio menu it should look like this.</p>
<p><img class="aligncenter size-full wp-image-540 img" title="07_033" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_033.jpg" alt="07_033" width="450" height="338" /></p>
<p><!-- ************** PART 8*********************** --></p>
<h2>Part Eight: The Content.</h2>
<p>Create a new rectangle in the middle of your interface. Fill it with <strong>effaff</strong> and name it <strong>Panel Base</strong>.</p>
<p>Give it a <strong>1 pixel stroke</strong> with a color <strong>869ca4</strong> Set its position to <strong>Inside</strong>.</p>
<p><img class="aligncenter size-full wp-image-541 img" title="07_034" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_034.jpg" alt="07_034" width="350" height="263" /></p>
<p>Create another rectangle.</p>
<p><img class="aligncenter size-full wp-image-542 img" title="07_035" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_035.jpg" alt="07_035" width="450" height="338" /></p>
<p>Give it these settings.</p>
<p><img class="aligncenter size-full wp-image-543 img" title="07_036" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_036.jpg" alt="07_036" width="410" height="138" /></p>
<p>Add the text for this panel and then duplicate and resize it to match the picture below.</p>
<p><img class="aligncenter size-full wp-image-544 img" title="07_037" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_037.jpg" alt="07_037" width="450" height="339" /></p>
<p>The content is what really needs to stand out from the rest. So in this case I made the natural decision to make the content the largest portion of the layout. I also put the largest and most colorful images in this section. Notice that the icon images for my projects are not only bigger but also have a slightly different design from my tutorial icons. This says discreetly &#8220;hey. . my tutorials are cool but what I really want you to do is check out my portfolio.&#8221;</p>
<p><img class="aligncenter size-full wp-image-525 img" title="07_018" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_018.jpg" alt="07_018" width="450" height="485" /></p>
<p>I really wanted the welcome section to stand out and I felt that text just wouldn&#8217;t do it by itself. So I made a globe surrounded by a wireframe to give it that &#8220;internet&#8221; feel.</p>
<h3>A note about color</h3>
<p>A good rule of thumb is to keep the color palette very limited. 4 or 5 colors maximum. I tend to pick a color theme (in this case blue) and use different saturations and brightnesses (is that a word?) of that color. If you&#8217;re lost as to what color scheme you&#8217;re going to use check out<a href="http://www.colorschemer.com" target="_blank"> www.colorschemer.com</a> he has great color schemes for you to play with.</p>
<h2>Part Nine: The News Panel.</h2>
<p>The News panel is very simple as you can tell. Just make sure that the date and the description are easily distinguishable. If you have any links in there, separate them out with a different color. I used orange. Isn&#8217;t it pretty?<br />
<img class="aligncenter size-full wp-image-523 img" title="07_016" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_016.jpg" alt="07_016" width="178" height="222" /></p>
<h2>Part Ten: The Tutorials Panel.</h2>
<p>Another simple panel. I merely grabbed the tutorial icons that I made for my website and placed them inside the panel with their corresponding descriptions. When you have stock images like this it&#8217;s a good idea to create an icon template with all the styles saved so that you can simply apply it to the new image.<br />
<img class="aligncenter size-full wp-image-524 img" title="07_017" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_017.jpg" alt="07_017" width="177" height="292" /></p>
<h3>Icon Template</h3>
<p>I created a PSD file with all my styles and graphics that I wanted applied to my icons. Then is was just a matter of applying it to my icons.</p>
<p><img class="aligncenter size-full wp-image-521 img" title="07_014" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_014.jpg" alt="07_014" width="450" height="277" /></p>
<h2>Part Eleven: The Result</h2>
<p>Put all these parts together and you get this!</p>
<div id="attachment_516" class="wp-caption aligncenter" style="width: 460px"><a title="Click for a larger view" href="http://www.bolducpress.com/wp-content/uploads/2007/06/07_020.jpg"><img class="size-full wp-image-516 img" title="07_009" src="http://www.bolducpress.com/wp-content/uploads/2007/06/07_009.jpg" alt="07_009" width="450" height="339" /></a><p class="wp-caption-text">Click for a larger view</p></div>
<h2>Conclusion.</h2>
<p>I hope this tutorial was helpful, feel free to post any comments or questions. (Or contact me directly).</p>
<p>Also I&#8217;m accepting requests. If any of you have a question about Photoshop or PHP and would like to see a tutorial, <a title="Contact Joshua Bolduc" href="http://www.bolducpress.com/contact/" target="_blank">send me an email</a>. Make sure that you put &#8220;request&#8221; in the subject.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bolducpress.com/tutorials/fundamentals-of-interface-design/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>How to create a grid quickly and easily with Photoshop</title>
		<link>http://www.bolducpress.com/tutorials/how-to-create-a-grid-quickly-and-easily-with-photoshop/</link>
		<comments>http://www.bolducpress.com/tutorials/how-to-create-a-grid-quickly-and-easily-with-photoshop/#comments</comments>
		<pubDate>Tue, 19 Jun 2007 12:55:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bolducpress.com/?p=190</guid>
		<description><![CDATA[Here is a quick technique for creating a grid. This was written for digital painting but it can be used for anything.]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><strong>Note:</strong> This tutorial is meant as a supplement to my <a href="/tutorials/portrait/">digital painting tutorial.</a></p>
<h2>What you will need</h2>
<ul>
<li>Adobe Photoshop.</li>
<li>A reference photograph.</li>
</ul>
<h2>Why not use the grid tool?</h2>
<p>Photoshop can&#8217;t currently create proportional grids with the grid tool, it&#8217;s a global setting that gets applied to every document. So while it might be great for guides it&#8217;s not good for creating reference grids.</p>
<h3>Here is an example:</h3>
<p>In the grid below I created a 2&#215;2 inch square and created a gridline every 1 inches, note the four squares
<p>
<img src="http://www.bolducpress.com/wp-content/uploads/2007/06/smallgrid.jpg" alt="" title="Small Grid" width="143" height="143" class="alignnone size-full wp-image-1062" /></p>
<p>I want to create an image that is twice the size of this while also having four squares (a gridline every 2 inches). If I simply create a 4&#215;4 inch square canvas I will get the following. </p>
<p><img src="http://www.bolducpress.com/wp-content/uploads/2007/06/largegrid.jpg" alt="" title="Large Grid" width="287" height="287" class="alignnone size-full wp-image-1061" /></p>
<p>Notice that this has 16 squares whereas the other one only has 4!</p>
<p>At the moment there is no way to set a different grid for each document. So until Adobe changes that you will need to use the technique illustrated below to create your proportional grids.</p>
<h2>Part One: Preparing a grid for your reference photo.</h2>
<h3>Find the width of your reference image</h3>
<p>First thing you need to do is find the width of your reference image. In my case it&#8217;s 1024px.</p>
<p><img class="aligncenter size-full wp-image-485 img" title="10_001" src="http://www.bolducpress.com/wp-content/uploads/2007/06/10_001.jpg" alt="10_001" width="450" height="362" /></p>
<h3>Find the width of each square in your grid</h3>
<p>Because I wanted 10 squares in my grid I divided that number by 10. Find the number of squares that&#8217;s appropriate for you. Generally a good range is between 8 and 12.</p>
<p><strong>1024px/10 = 102.4px</strong></p>
<p>Because you can&#8217;t have .4 pixels I rounded this down to 102.</p>
<h3>Create the square pattern.</h3>
<p>Open  a new document and set the width and height to <strong>102</strong> pixels.</p>
<p>Unlock the background layer by double clicking it. Click the little <strong>Fx</strong> at the bottom of the layers palette to open the layer style window. Apply these settings.</p>
<p><a href="http://www.bolducpress.com/wp-content/uploads/2007/06/10_002.jpg"><img class="aligncenter size-full wp-image-486 img" title="10_002" src="http://www.bolducpress.com/wp-content/uploads/2007/06/10_002.jpg" alt="10_002" width="450" height="302" /></a></p>
<p>Next go to <strong>Edit &gt; Define Pattern</strong>. Give it the name <strong>Grid</strong> and click <strong>OK</strong></p>
<h3>Create the grid channel.<strong><br />
</strong></h3>
<p>Go to your reference image.</p>
<p>Click <strong>Window &gt; Channels</strong> To bring up the channels tab. Create a new channel and name it Grid.</p>
<p>Type <strong>Shift &#8211; F5</strong> to bring up the fill dialog.</p>
<p>Select <strong>Pattern</strong> from the drop down menu and then select<strong> Grid</strong> (the one you just created).</p>
<p>Click <strong>Ok</strong></p>
<p>It should look something like this.</p>
<p><img class="aligncenter size-full wp-image-487 img" title="10_003" src="http://www.bolducpress.com/wp-content/uploads/2007/06/10_003.jpg" alt="10_003" width="450" height="263" /></p>
<h3>Fill the grid lines with black</h3>
<p>Go back to the layers palette and create a new layer on top of your reference photo, name this layer <strong>Grid</strong>.</p>
<p>Go to <strong>Select &gt; Load Selection</strong>. Select <strong>Grid</strong> from the drop down menu and click ok.</p>
<p>You should see a selection mask.</p>
<p>Go to <strong>Select &gt; Inverse</strong> to invert the selection.</p>
<p>Press <strong>Shift &#8211; F5</strong> and select <strong>Black</strong> From the drop down list.</p>
<p>Presto! You have a grid!</p>
<p><img class="aligncenter size-full wp-image-488 img" title="10_004" src="http://www.bolducpress.com/wp-content/uploads/2007/06/10_004.jpg" alt="10_004" width="450" height="338" /></p>
<h2>Part Two: Preparing a grid for your canvas.</h2>
<p>Create a new canvas the same size as your reference photo. In my case it was 1024 x 768 pixels.</p>
<p>Create a new layer above the background layer, name this <strong>Grid</strong></p>
<p>Like before, go to the channels palette and create a new channel and name it <strong>Grid</strong>, with the<br />
new channel selected, press <strong>Shift &#8211; F5</strong> and select your pattern.</p>
<p>Go back to the layers palette select the grid layer and go to <strong>Select &gt; Load Selection</strong>. Select<br />
<strong>Grid</strong> from the drop down menu and click <strong>Ok</strong>.</p>
<p>Invert the selection mask and fill it with black.</p>
<p>It should look like this.</p>
<p><img class="aligncenter size-full wp-image-489 img" title="10_005" src="http://www.bolducpress.com/wp-content/uploads/2007/06/10_005.jpg" alt="10_005" width="450" height="372" /></p>
<h3>Make the canvas larger than the reference</h3>
<p>If you&#8217;re making this grid for the portrait, it&#8217;s a good idea to make the canvas larger than the image source.</p>
<p>Go to <strong>Image &gt; Image Size</strong> and apply these settings.</p>
<p><img class="aligncenter size-full wp-image-490 img" title="10_006" src="http://www.bolducpress.com/wp-content/uploads/2007/06/10_006.jpg" alt="10_006" width="305" height="226" /></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolducpress.com/tutorials/how-to-create-a-grid-quickly-and-easily-with-photoshop/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>How to draw a digital portrait</title>
		<link>http://www.bolducpress.com/tutorials/how-to-draw-a-digital-portrait/</link>
		<comments>http://www.bolducpress.com/tutorials/how-to-draw-a-digital-portrait/#comments</comments>
		<pubDate>Mon, 18 Jun 2007 06:29:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bolducpress.com/?p=186</guid>
		<description><![CDATA[In this tutorial I will explain how I created this portrait of the gorgeous Scarlett Johansson.
]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h2>Final Result:</h2>
<p><img class="aligncenter size-full wp-image-580 img" title="09_017" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_017.jpg" alt="09_017" width="450" height="338" /></p>
<h2>What you will need</h2>
<ul>
<li>Adobe Photoshop.</li>
<li>A reference photograph.</li>
</ul>
<h2>A Few things first. . .</h2>
<h3>A note about using grids:</h3>
<p>I really recommend using a grid for beginning artists. You&#8217;ll find that your work will improve dramatically, and that&#8217;s always encouraging <img src='http://www.bolducpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . I also encourage you to try drawing without a grid. I used the grid  in the beginning (to check proportions, placement etc) and then later hid the grid while I was working with color.</p>
<p>You can read my tutorial: <a href="/tutorials/how-to-create-a-grid-quickly-and-easily-with-photoshop/">How to create a grid quickly and easily with Photoshop</a></p>
<h3>A note about brushes:</h3>
<p>Until the last part of the portrait I only used basic photoshop brushes with their hardness normally set to 0%. I tended to alternate between either 100% or 30% opacity.</p>
<h2>Part One: Blocking out the shapes</h2>
<p>Believe it or not the hardest part of drawing isn&#8217;t the details. It&#8217;s blocking out the shape. I can&#8217;t stress how important this step is, as it sets the foundation for your entire image. I don&#8217;t care how good your details are if your foundation isn&#8217;t solid your piece will suffer.</p>
<p>It&#8217;s important to stay loose while drawing so go ahead and scribble in shapes, keep an eye on the grid as you do this but don&#8217;t be overly concerned about getting it perfect, this will come later.</p>
<p>This is about 45 minutes of work, notice that I don&#8217;t have that many details, I was primarily concerned about the placement of forms. I used the basic brush with an opacity around 30%.</p>
<p><img class="aligncenter size-full wp-image-570 img" title="09_007" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_007.jpg" alt="09_007" width="450" height="338" /></p>
<p>Then I started working on the face. In portraits the face and hands are CRUCIAL. This is what sells the piece. Keep that in mind as you are working. In order to achieve a believable likeness you must keep facial proportions in consideration.</p>
<h3>Use facial proportions:</h3>
<p>Even though every face is different, they all follow the same facial proportions. Don&#8217;t forget these.</p>
<p>Here are some of the most useful.</p>
<p><img class="aligncenter size-full wp-image-582 img" title="09_019" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_019.jpg" alt="09_019" width="350" height="350" /></p>
<p>Looking at this picture face-on all these lines would be straight, I had to compensate for the slight angle.</p>
<p>Don&#8217;t obsess about them yet though, notice that the details aren&#8217;t perfect, I just put in some nose, mouth and eye shapes to get the general proportions right.</p>
<p><img class="aligncenter size-full wp-image-571 img" title="09_008" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_008.jpg" alt="09_008" width="450" height="340" /></p>
<p>As I started to gain confidence in my strokes I started to zoom in and refine them. I also added more detail to the face.</p>
<p><img class="aligncenter size-full wp-image-572 img" title="09_009" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_009.jpg" alt="09_009" width="450" height="338" /></p>
<h3>Periodically flip the canvas</h3>
<p>While drawing, it&#8217;s a good idea to constantly flip the canvas. It helps you get a fresh perspective. I frequently notice things that I wouldn&#8217;t have otherwise.</p>
<p>Take a minute and look the image below, are some details easier to see than others?</p>
<p><img class="aligncenter size-full wp-image-581 img" title="09_018" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_018.jpg" alt="09_018" width="438" height="224" /></p>
<p>Don&#8217;t be concerned at this point if the portrait doesn&#8217;t look like the person. That comes next <img src='http://www.bolducpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<h2>Part Two: Adding depth through chiaroscuro (shading)</h2>
<p>Lines can only give a piece so much depth so let&#8217;s add some shading to make it pop out.</p>
<p>Generally it&#8217;s a good idea to apply shading evenly across the picture but sometimes you can just get lost in a particular spot (especially if you&#8217;re working on a face.)</p>
<p><img class="aligncenter size-full wp-image-573 img" title="09_010" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_010.jpg" alt="09_010" width="450" height="338" /></p>
<p>In the next step I continued to block out the tones. Getting my darkest darks and my lightest lights. I also hid the grid.</p>
<p><img class="aligncenter size-full wp-image-574 img" title="09_011" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_011.jpg" alt="09_011" width="450" height="338" /></p>
<h2>Part Three: Adding color</h2>
<p>This was my first attempt at color. I made a new layer above my figure layer and set its blending style to <strong>Multiply.</strong> This preserves the black lines and lets you paint over it (like a coloring book). This technique is great for graphic novels but I wasn&#8217;t satisfied with it for this piece.</p>
<p><img class="aligncenter size-full wp-image-575 img" title="09_012" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_012.jpg" alt="09_012" width="450" height="338" /></p>
<p>One thing that I want to point out is I rarely use the eraser tool. Instead I tend to favor the brush. If I have a black spot that I want to make white I don&#8217;t erase it, I replace it with white.</p>
<p>With that said, in the following instance I did remove the color and start over again. This time I played with the Curves panel. This actually changed the colors of my lines which was much more realistic.</p>
<p><img class="aligncenter size-full wp-image-576 img" title="09_013" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_013.jpg" alt="09_013" width="450" height="338" /></p>
<p>At this point the base figure is done, now comes the fun part. . .</p>
<h2>Part Three: Tweaking!</h2>
<p>Art is 10% construction and 90% tweaking. (At least it is for me). The thing about tweaking though is that it won&#8217;t work if you don&#8217;t have a solid foundation. So make sure that you have the right proportions and balance otherwise it&#8217;s a lot more work to fix it afterward.</p>
<p>As you can see below I refined the face, breast region and arms. I also added a black dress layer.</p>
<p><img class="aligncenter size-full wp-image-577 img" title="09_014" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_014.jpg" alt="09_014" width="450" height="338" /></p>
<p>Next I started to work on the background.</p>
<p><img class="aligncenter size-full wp-image-578 img" title="09_015" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_015.jpg" alt="09_015" width="450" height="338" /></p>
<p>I felt that the skin wasn&#8217;t warm enough so I played with curves some more to give it a more soft golden color.</p>
<p>I also put in highlights on her dress and worked with the background more too.</p>
<p><img class="aligncenter size-full wp-image-579 img" title="09_016" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_016.jpg" alt="09_016" width="450" height="338" /></p>
<h2>The Result</h2>
<p>Here is the final result, I used natural brushes in Photoshop to give the wood it&#8217;s texture.</p>
<p><img class="aligncenter size-full wp-image-580 img" title="09_017" src="http://www.bolducpress.com/wp-content/uploads/2007/06/09_017.jpg" alt="09_017" width="450" height="338" /></p>
<h2>Conclusion</h2>
<p>The process in theory is very simple but it takes a long time. I spent close to 20 hours on this project and there is more I can do with it (such as fix her left eye and thumb).</p>
<p>I also asked fellow artists for critiques. (I don&#8217;t recommended asking friends and family because generally they only thing they will say is &#8220;it doesn&#8217;t look like her&#8221; or &#8220;it looks like her.&#8221;) A great place for advice is the forums at <a href="http://www.threedy.com" target="_blank">3dTotal.com</a> or <a href="http://www.forums.cgsociety.org" target="_blank">cgSociety.org</a></p>
<p>I hope this was helpful, if you have any questions or suggestions feel free to contact me.</p>
<p>I&#8217;m accepting requests. If any of you have a question about Photoshop or PHP and would like to see a tutorial, send me an email <a href="/contact/">here</a>. Make sure that you put &#8220;request&#8221; in the subject.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolducpress.com/tutorials/how-to-draw-a-digital-portrait/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>How to use images created with gdLibrary</title>
		<link>http://www.bolducpress.com/tutorials/how-to-use-images-created-with-gdlibrary/</link>
		<comments>http://www.bolducpress.com/tutorials/how-to-use-images-created-with-gdlibrary/#comments</comments>
		<pubDate>Sat, 16 Jun 2007 15:22:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bolducpress.com/?p=210</guid>
		<description><![CDATA[I've gotten a lot of comments along the lines of, "how do I use my image after I've created it?." So I thought this was a good opportunity to write another tutorial.]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><strong>Note:</strong> This tutorial is a supplement to my other tutorials. If you are interested in manipulating images with gdLibrary please try any of these first.</p>
<ul>
<li><a title="Drop Shadows with gdLibrary" href="/tutorials/drop-shadows-with-gd-library/">Drop Shadows with gdLibrary</a></li>
<li><a title="Create cropped thumbnails with gdLibrary" href="/tutorials/create-cropped-thumbnails-with-gd-library/">Create cropped thumbnails with gdLibrary</a></li>
<li><a title="gdLibrary Bar Chart" href="/tutorials/gd-library-bar-chart/">gdLibrary Bar Chart</a></li>
<li><a title="Line Chart Class with gdLibrary" href="/tutorials/line-chart-class-with-gdlibrar/">Line Chart Class with gdLibrary</a></li>
</ul>
<h2>What you will need</h2>
<ul>
<li>A server with php installed and gdLibrary enabled.</li>
<li>An image script generated with gdLibrary.</li>
<li>A pure text editor, I like <a href="http://www.eclipse.org/pdt/" target="_blank">Eclipse</a>.</li>
</ul>
<h2>Introduction</h2>
<p>In PHP there are two ways to output an image. Each of these has their advantages and disadvantages. These will be discussed later in the tutorial.</p>
<ol>
<li>Output to an image file.</li>
<li>Output to the header.</li>
</ol>
<h2>Part One: Output to an image file.</h2>
<p>At the end of every gdLibrary script there is the following code.</p>
<pre class="brush: php;">ImageJpeg($canvas);
ImageDestroy($canvas);</pre>
<p>To output the image to a file simply add the file path to the <strong>ImageJpeg</strong> function.</p>
<pre class="brush: php;">ImageJpeg($canvas, &quot;some_path/my_image.jpg&quot;);
ImageDestroy($canvas);</pre>
<p>A good way to use this technique is to package your code into a function and add this bit of code at the end.</p>
<pre class="brush: php;">function myFunction()
{
/*

Your code goes here

*/

ImageJpeg($canvas, &quot;some_path/my_image.jpg&quot;);
ImageDestroy($canvas);
}</pre>
<p>This function will run and then save the image to the folder of your choice. Nothing could be better <img src='http://www.bolducpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<h3>Advantages</h3>
<p>You only have to generate the image once.</p>
<p>You can reference the image like any other.<br />
<strong>(&lt;img src = &#8220;somepath/my_generated_image.jpg&#8221; /&gt;)</strong></p>
<p><strong>Speed!</strong> Because you&#8217;re not generating the image every time, this is by far the fastest option.</p>
<h3>Disadvantages</h3>
<p>There is the potential of having thousands (or even tens of thousands) of different images. (such as generating thumbnails)<br />
Managing that many thumbnails can prove daunting (if not impossible).</p>
<h2>Part Two: Output to the header.</h2>
<p>In order to output to the header you have to tell the server to output this file as an image.</p>
<pre class="brush: php;">header(&quot;content-type: image/jpeg&quot;); //&lt;- telling the server that this is an image
ImageJpeg($canvas);
ImageDestroy($canvas);</pre>
<p>The server won&#8217;t save a copy of the image so in order to see it you have to preview it in the browser.<br />
This brings up the question, how do I pass data to my image? Simple, through the browser!</p>
<h3>Passing data</h3>
<p>Take a look at this code.</p>
<pre class="brush: php;">$myImage = &quot;&lt;img src=&quot;/image_file.php?var=some_image.jpg&quot; alt=&quot;&quot; /&gt;&quot;; </pre>
<p>Does this look familiar? It should! I just pass data to the file like I would any other PHP file and then set that php file as the source in an image tag. Ahhh the beauty of PHP <img src='http://www.bolducpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Ok now what if I want to pass a lot of data through the header? Such as an array? Is this possible? You bet it is!</p>
<h4>The Serialize Function</h4>
<p>PHP comes with a function called <strong>serialize</strong>. It converts any data into a byte-stream representation that can be interpreted by the server. In this way we can send all kinds of data.</p>
<p>This function is also helpful as it stores the datatype and structure. So you can actually send an array or an object!</p>
<p>The serialize function can be used like this.</p>
<p>This code does NOT go into your php image file. Instead this goes into the file that is referencing your php image file.</p>
<pre class="brush: php;">
$myArray          = array(1,3,5,11,21,31,5,3,1,3,4);
$serialized_array = serialize($myArray);
$myImage          = &quot;&lt;img src=&quot;/image_file.php?array=$serialized_array&quot; alt=&quot;&quot; /&gt;&quot;; </pre>
<p>Inside your php image file type the following code.</p>
<pre class="brush: php;">//you retrieve your array from the header by using the unserialize function.
$myArray = unserialize($_GET['array']);

/*

Your gd code here

*/
header(&quot;content-type: image/jpeg&quot;);
ImageJpeg($canvas);
ImageDestroy($canvas);</pre>
<p>Note: The serialize function isn&#8217;t limited to just this, you can use it to pass data whenever you want.</p>
<h3>Advantages</h3>
<p>You don&#8217;t have to store any images to the server, it generates them on the fly.</p>
<p>You can change the look for all your generated images quickly and easily.</p>
<h3>Disadvantages</h3>
<p>It can be quite slow as it has to generate a new image everytime. It can be especially slow when dealing with a lot of data. (such as statistics for a chart.)</p>
<h2>Conclusion</h2>
<p>I hope you found this tutorial useful. If you have any questions or suggestions please feel free to post in my comments.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolducpress.com/tutorials/how-to-use-images-created-with-gdlibrary/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Line chart class with gdLibrary</title>
		<link>http://www.bolducpress.com/tutorials/line-chart-class-with-gdlibrar/</link>
		<comments>http://www.bolducpress.com/tutorials/line-chart-class-with-gdlibrar/#comments</comments>
		<pubDate>Wed, 30 May 2007 05:23:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bolducpress.com/?p=206</guid>
		<description><![CDATA[In this tutorial, not only will I show you how to make a line chart, I will also show you how to package that code into a class so that you can use it quickly and easily.]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><strong>Note:</strong> This is a rather advanced tutorial so if you have never encountered classes and OOP<br />
(Object Oriented Programming) before I encourage you to <a href="http://www.spoono.com/php/tutorials/tutorial.php?id=27" target="_blank">read up on it</a> a bit and then come back.</p>
<h2>What you will need</h2>
<ul>
<li>A server with php installed and gdLibrary enabled.</li>
<li>A pure text editor, I like <a href="http://www.eclipse.org/pdt/" target="_blank">Eclipse</a></li>
</ul>
<h2>The Source</h2>
<p><a href="http://www.bolducpress.com/wp-content/uploads/2007/05/bolducpress-line_chart.zip">Download the commented source code to this tutorial.</a></p>
<h2>Part One: Initializing your new class and setting variables.</h2>
<p>Open up your favorite script editor</p>
<p>Create a new file and name it <strong>line_chart.php</strong></p>
<p>Copy the following code and paste it into your new php document.</p>
<pre class="brush: php;">
class line_chart
{
//--------------------------------------------
// variables
//--------------------------------------------

// The chart labels
var $chart_title    = &quot;Web Site Hits&quot;;
var $x_label	    = &quot;Date&quot;;
var $y_label 	    = &quot;Hits&quot;;

//The dimensions of your chart
var $chart_width     = 500;
var $chart_height    = 300;

//The perimeter of  your chart
var $chart_perimeter = 50;

//The data that you want to be plotted
var $data_array      = array();

//Your color array
var $color 			= array();
}//end of class
</pre>
<h2>Part Two: The &#8220;Set&#8221; Methods</h2>
<p>While working in OOP it is good practice to create set methods that will (as you might expect) set your variables.</p>
<p>Copy the following code and paste it into your document under the variables that you just created.</p>
<pre class="brush: php;">
//--------------------------------------------
// set chart dimensions
// This function sets the dimensions of your chart. Right now they are set to default 500x300 but later
// you'll be able to use this function to change the dimensions to whatever you want.
//--------------------------------------------
public function set_chart_dimensions($width, $height)
{
$this-&gt;chart_width  = $width;
$this-&gt;chart_height = $height;
}
//--------------------------------------------
// set chart perimeter
// This function sets the width of the perimeter, you can make the perimeter larger or smaller by passing
// a higher or lower integer.
//--------------------------------------------
public function set_chart_perimeter($perimeter)
{
$this-&gt;perimeter = $perimeter;
}
//--------------------------------------------
// set labels
// This function sets the labels for your graph. You can also remove your labels by setting each value to an
// empty string ( &quot;&quot; )
//--------------------------------------------
public function set_labels($title, $xLabel, $yLabel)
{
$this-&gt;graphTitle = $title;
$this-&gt;xLabel     = $xLabel;
$this-&gt;yLabel     = $yLabel;
}
//--------------------------------------------
// add line
// This function passes an array of information to your data_array. This data will be plotted
// note that I'm using brackets [], this will let me have multiple lines on a graph. (great for making comparisons)
//--------------------------------------------
public function add_line($new_data)
{
$this-&gt;data_array[] = $new_data;
}
</pre>
<h2>Part Three: Preparing the canvas</h2>
<p>All the setup is done, now its time to actually start programming! The first step is creating your canvas so let&#8217;s get to it.</p>
<p>Go back into your class, copy and paste the following code below your add_line() function.</p>
<pre class="brush: php;">
//--------------------------------------------
// prepare canvas
//--------------------------------------------
private function prepare_canvas()
{
//this-&gt;chart is the variable that will store your image. It is the canvas for all of your work.
$this-&gt;chart = imagecreatetruecolor($this-&gt;chart_width, $this-&gt;chart_height);

//By default the canvas only comes with one color. . black (which really isn't a color at all, it's the absence of color <img src='http://www.bolducpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ) anyway
//it would be memory intensive for php to automatically allocate every color into memory (as there are millions of colors)
//so we must do each manually.

$this-&gt;color['white']     = imagecolorallocate($this-&gt;chart, 255, 255, 255);
$this-&gt;color['black']     = imagecolorallocate($this-&gt;chart, 0,0,0);
$this-&gt;color['yellow']    = imagecolorallocate($this-&gt;chart, 248, 255, 190);
$this-&gt;color['blue']      = imagecolorallocate($this-&gt;chart, 3,12,94);
$this-&gt;color['gray']      = imagecolorallocate($this-&gt;chart, 102, 102, 102);
$this-&gt;color['lightGray'] = imagecolorallocate($this-&gt;chart, 216, 216, 216);

//later when we want to adjust the position of our fonts we'll need to know the width and height.
//I'm setting my font size to 2.
$this-&gt;font_width  = imagefontwidth(2);
$this-&gt;font_height = imagefontheight(2);

//This function as you might expect, fills the canvas with a color. In this case, I'm filling it with light gray
imagefill($this-&gt;chart, 0,0, $this-&gt;color['lightGray']);
}
</pre>
<h2>Part Four: Calculating the maximum and minimum Y values.</h2>
<p>In this next part we need to find a maximum and minimum value for the Y-Axis. We could just take the maximum and minimum value in our array (608 and 108) but then the line would go right to the edge and not look very good.</p>
<p><img class="aligncenter size-full wp-image-591 img" title="06_001" src="http://www.bolducpress.com/wp-content/uploads/2007/05/06_001.jpg" alt="06_001" width="400" height="237" /></p>
<p>So let&#8217;s create a buffer.</p>
<p>Copy and paste the following code into your document below the previous function.</p>
<pre class="brush: php;">//--------------------------------------------
// get min and max y values
//--------------------------------------------
private function calculate_min_and_max_y_values()
{

//because we might have multiple lines of data (multiple arrays),
//we'll need to search through all of them in order to find the
//highest and lowest value.

for($i=0; $idata_array); $i++)
{
$current_line = $this-&gt;data_array[$i];
if( min($current_line)&gt;$y_min ) $y_min = min($current_line);
if( max($current_line)&gt;$y_max ) $y_max = max($current_line);
}

//min
$places   = strlen($y_min);				//string length of minimum value. 		  		  so strlen(1) = 1;
$mod      = pow(10, $places-1); 	    //raising that number minus 1 to the power of 10. so pow(10, 0) = 1;
$y_min    = $mod - $y_min; 				//subtracting that from the minimum. 			  so 1 - 1 = 0; &lt;-your y-axis minimum

//We can't have negative hits so if $y_min is less than 0 we
//just set that to 0.
if($y_min&lt;0) $y_min = 0;

//max
$places = strlen($y_max);
$mod    = pow(10, $places-1);
$y_max 	= $mod + $y_max;

//Saving this mod value to a class variable
//(it will be useful later)
$this-&gt;mod = $mod;

//Saving the $y_min and $y_max values so that they can be
//accessed by a different method in the class.

$this-&gt;y_axis_values['min'] = $y_min;
$this-&gt;y_axis_values['max'] = $y_max;
}
</pre>
<h2>Part Five: Preparing the Grid</h2>
<p>Ok prepare yourself, this is going to be the hardest part of the tutorial. But don&#8217;t be afraid, it&#8217;s not too hard. What we need to do next is create a grid on which we can draw our chart.</p>
<p>Remember the perimeter that you assigned earlier? Well that&#8217;s where this comes in. The perimeter acts as a buffer between the edge of your canvas and the grid its self. The perimeter will also be the place where you put your chart labels.</p>
<p><img class="aligncenter size-full wp-image-592 img" title="06_002" src="http://www.bolducpress.com/wp-content/uploads/2007/05/06_002.jpg" alt="06_002" width="300" height="179" /></p>
<p>I&#8217;m going to break up the next function into chunks and explain what they do as we go along.</p>
<p>Copy and paste the following code in to  your document.</p>
<pre class="brush: php;">
private function prepare_grid()
{

//The grid width. We don't want the grid to be the same size as the chart otherwise the entire
//document will be just one grid with no place for labels. Therefore, subtract the perimeter width from all sides.
$gridWidth  = $this-&gt;chart_width  - ($this-&gt;chart_perimeter*2);
$gridHeight = $this-&gt;chart_height - ($this-&gt;chart_perimeter*2);

//I prefer to work with coordinates, it makes it easy to visualize the process. If you observe below you'll see
//That I've made four corners.
$this-&gt;c1 = array(&quot;x&quot;=&gt;$this-&gt;chart_perimeter,             &quot;y&quot;=&gt;$this-&gt;chart_perimeter);
$this-&gt;c2 = array(&quot;x&quot;=&gt;$this-&gt;chart_perimeter+$gridWidth,  &quot;y&quot;=&gt;$this-&gt;chart_perimeter);
$this-&gt;c3 = array(&quot;x&quot;=&gt;$this-&gt;chart_perimeter+$gridWidth,  &quot;y&quot;=&gt;$this-&gt;chart_perimeter+$gridHeight);
$this-&gt;c4 = array(&quot;x&quot;=&gt;$this-&gt;chart_perimeter,             &quot;y&quot;=&gt;$this-&gt;chart_perimeter+$gridHeight);
</pre>
<p><img class="aligncenter size-full wp-image-593 img" title="06_003" src="http://www.bolducpress.com/wp-content/uploads/2007/05/06_003.jpg" alt="06_003" width="300" height="179" /></p>
<p>Go ahead and copy and paste the following code below your previous.</p>
<pre class="brush: php;">
//now that I've made the grid coordinates its time to connect the dots and create a grid plane.
//In this function I'm creating a solid white rectangle
imagefilledrectangle($this-&gt;chart, $this-&gt;c1['x'], $this-&gt;c1['y'], $this-&gt;c3['x'], $this-&gt;c3['y'], $this-&gt;color['white']);
</pre>
<p><img class="aligncenter size-full wp-image-594 img" title="06_004" src="http://www.bolducpress.com/wp-content/uploads/2007/05/06_004.jpg" alt="06_004" width="300" height="179" /></p>
<p>More copying and pasting.</p>
<pre class="brush: php;">
//getting the biggest array
//now I need to find the highest x-value but unlike the y-value that I found earlier, I'm not trying to find
//the highest data value but rather the highest count value.
//To put it simply, which array has the most entries?

$biggest_array = array();
for($i=0; $idata_array); $i++)
{
if(count($biggest_array) &lt; count($this-&gt;data_array[$i])) $biggest_array = $this-&gt;data_array[$i];
}
</pre>
<p>I&#8217;m going to increment by grid units so I need to find what the width and height of that grid unit is (in pixels)</p>
<p>and again. . .</p>
<pre class="brush: php;">
$this-&gt;square['w'] = $gridWidth/count($biggest_array);
$this-&gt;square['h'] = $gridHeight/$this-&gt;y_axis_values['max'];
</pre>
<p><img class="aligncenter size-full wp-image-595 img" title="006_05" src="http://www.bolducpress.com/wp-content/uploads/2007/05/006_05.jpg" alt="006_05" width="288" height="145" /></p>
<p>I also want some padding between the first line and the left side of the graph, otherwise the chart won&#8217;t<br />
look that great.</p>
<p><img class="aligncenter size-full wp-image-596 img" title="06_006" src="http://www.bolducpress.com/wp-content/uploads/2007/05/06_006.jpg" alt="06_006" width="400" height="120" /></p>
<pre class="brush: php;">
$this-&gt;vertical_padding = $this-&gt;square['w']/2;
</pre>
<p>Copy and paste the following code</p>
<pre class="brush: php;">
//------------------------------------------------
//drawing the vertical lines and axis labels
//------------------------------------------------
foreach($biggest_array as $assoc=&gt;$value)
{
//drawing the line
imageline($this-&gt;chart,  $this-&gt;vertical_padding+$this-&gt;c4['x']+$increment,   $this-&gt;c4['y'], $this-&gt;vertical_padding+$this-&gt;c1['x']+$increment, $this-&gt;c1['y'], $this-&gt;color['black']);

//axis values
//finding the width of the word so that we can accuratly position it
$wordWidth = strlen($assoc)*$this-&gt;font_width;

//the x-position of the line, this will be incremented on every loop
$xPos = $this-&gt;c4['x']+$increment+$this-&gt;vertical_padding-($wordWidth/2);

//creating the axis value label
ImageString($this-&gt;chart, 2, $xPos, $this-&gt;c4['y'], $assoc, $this-&gt;color['black']);

$increment += $this-&gt;square['w'];
}
</pre>
<p><img class="aligncenter size-full wp-image-597 img" title="06_007" src="http://www.bolducpress.com/wp-content/uploads/2007/05/06_007.jpg" alt="06_007" width="350" height="206" /></p>
<p>Next we need to create the horizontel lines to finish up our grid. Copy and paste the following code.</p>
<pre class="brush: php;">
//------------------------------------------------
//drawing the horizontel lines and axis labels
//------------------------------------------------
//resetting the increment back to 0
$increment = 0;
for($i=$this-&gt;y_axis_values['min']; $i&lt;$this-&gt;y_axis_values['max']; $i++)
{
//main lines
//often the y-values can be in the thousands, if this is the case then we don't want to draw every single
//line so we need to make sure that a line is only drawn every 50 or 100 units.
if($i%$this-&gt;mod==0){
//drawing the line
imageline($this-&gt;chart, $this-&gt;c4['x'], $this-&gt;c4['y']+$increment, $this-&gt;c3['x'], $this-&gt;c3['y']+$increment, $this-&gt;color['grey']);

//axis values
$xPos = $this-&gt;c1['x']-($this-&gt;font_width*strlen($i))-5;
ImageString($this-&gt;chart, 2, $xPos, $this-&gt;c4['y']+$increment-($this-&gt;font_height/2), $i, $this-&gt;color['black']);

}
//tics
//these are the smaller lines between the longer, main lines.
elseif(($this-&gt;mod/5)&gt;1 &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp; $i%($this-&gt;mod/5)==0)
{
imageline($this-&gt;chart, $this-&gt;c4['x'], $this-&gt;c4['y']+$increment, $this-&gt;c4['x']+10, $this-&gt;c4['y']+$increment, $this-&gt;color['grey']);
}
$increment-=$this-&gt;square['h'];
}

//------------------------------------------------
//creating the left line
//------------------------------------------------
imageline($this-&gt;chart, $this-&gt;c1['x'], $this-&gt;c1['y'], $this-&gt;c4['x'], $this-&gt;c4['y'], $this-&gt;color['black']);

}//end of prepare_grid function
</pre>
<p><img class="aligncenter size-full wp-image-598 img" title="06_008" src="http://www.bolducpress.com/wp-content/uploads/2007/05/06_008.jpg" alt="06_008" width="350" height="209" /></p>
<p>I also added a left line to make it look better.</p>
<p><img class="aligncenter size-full wp-image-599 img" title="06_009" src="http://www.bolducpress.com/wp-content/uploads/2007/05/06_009.jpg" alt="06_009" width="350" height="409" /></p>
<h2>Part Six: Drawing the axis labels</h2>
<p>Every chart needs to have some chart labels so let&#8217;s add some!</p>
<p>Copy and paste the following code.</p>
<pre class="brush: php;">
private function draw_chart_labels()
{
//------------------------------------------------
// Making the chart labels
//------------------------------------------------

//Graph Title
ImageString(
$this-&gt;chart, 2,
($this-&gt;chart_width/2)-(strlen($this-&gt;chart_title)*$this-&gt;font_width)/2, $this-&gt;c1['y']-($this-&gt;chart_perimeter/2),
$this-&gt;chart_title,
$this-&gt;color['green']);

//X-Axis
ImageString(
$this-&gt;chart, 2,
($this-&gt;chart_width/2)-(strlen($this-&gt;x_label)*$this-&gt;font_width)/2,  $this-&gt;c4['y']+($this-&gt;chart_perimeter/2),
$this-&gt;x_label,
$this-&gt;color['green']);

//Y-Axis
ImageStringUp(
$this-&gt;chart, 2,
$this-&gt;c1['x']-$this-&gt;font_height*3, $this-&gt;chart_height/2+(strlen($this-&gt;y_label)*$this-&gt;font_width)/2,
$this-&gt;y_label,
$this-&gt;color['green']);
}
</pre>
<p>Here is the chart with the labels.</p>
<p><img class="aligncenter size-full wp-image-600 img" title="06_010" src="http://www.bolducpress.com/wp-content/uploads/2007/05/06_010.jpg" alt="06_010" width="350" height="208" /></p>
<h2>Part Seven: Plotting the lines.</h2>
<p>You&#8217;ve come a long way! Congratulations! There are only a few steps left before you&#8217;ll be frolicking in graph goodness!</p>
<p>Lets do what you&#8217;ve been waiting for, plotting the lines on your new chart.</p>
<p>Copy and paste as always.</p>
<pre class="brush: php;">
//--------------------------------------------
// plot lines
//--------------------------------------------
private function plot_lines()
{
//------------------------------------------------
// Making chart lines
//------------------------------------------------
$increment = 0; 		//resetting the increment value

//looping through each array of data
//(in this case there is only one set of data
//but later you'll be able to add more)
for($i=0; $idata_array); $i++)
{

$line = $this-&gt;data_array[$i];
//getting the first value
$firstVal = end(array_reverse($line));

$increment = 0;
//getting the first point for your line
$point1 = array($this-&gt;c4['x']+$increment+$this-&gt;vertical_padding,$this-&gt;c4['y']-($firstVal*$this-&gt;square['h']));

//looping through your current array of data
foreach($line as $assoc=&gt;$value)
{
//getting the second point for your line
$yPos 	= $this-&gt;c4['y']-($value*$this-&gt;square['h']);
$xPos 	= $this-&gt;c4['x']+$increment+$this-&gt;vertical_padding;
$point2 = array($xPos, $yPos);

//drawing your line
imageline($this-&gt;chart, $point1[0], $point1[1], $point2[0], $point2[1], $this-&gt;color['blue']);

//point1 becomes point2
$point1 = $point2;

//increment to the next x position
$increment += $this-&gt;square['w'];
}
}
}
</pre>
<h2>Part Eight: The output function</h2>
<p>Guess what . . you&#8217;re almost done!</p>
<p>Copy and paste this simple function</p>
<pre class="brush: php;">
//--------------------------------------------
// output
//--------------------------------------------
private function output()
{
//sets the type of output (in this case a jpg image)
header(&quot;content-type: image/jpg&quot;);
imagejpeg($this-&gt;chart);

//after output it removes the image from the buffer to free up memory
imagedestroy($this-&gt;chart);
}
</pre>
<h2>Part Nine: The plot function.</h2>
<p>All right time for the last function. Thankfully this one is REALLY easy. Just copy and paste as usual. (make sure that<br />
they are in this exact order).</p>
<pre class="brush: php;">
//--------------------------------------------
// plot
//--------------------------------------------
public function plot()
{
$this-&gt;prepare_canvas();
$this-&gt;calculate_min_and_max_y_values();
$this-&gt;prepare_grid();
$this-&gt;plot_lines();
$this-&gt;draw_chart_labels();
$this-&gt;output();
}
</pre>
<p>Notice that these are all the functions that you just made? Pretty much in order too. This is the essence of modular and the power of classes. Now it is very easy to debug for if we have a problem we can just go through and comment out those functions in order to isolate it.</p>
<h2>Part Ten: Creating an instance of your new class.</h2>
<p>Ok all the hard work is done, now for the fun part.</p>
<p>Copy and paste the following code after the closing curly-bracket of your class (where it says <em>//end of class</em>)</p>
<pre class="brush: php;">
//Your Chart Data (this is what will be plotted)
$data['May 10'] = 108;
$data['May 11'] = 419;
$data['May 12'] = 305;
$data['May 13'] = 433;
$data['May 14'] = 608;
$data['May 15'] = 702;
$data['May 16'] = 498;
$data['May 17'] = 500;
$data['May 18'] = 208;

//creates a new instance of your line_chart class
$myChart = new line_chart;

//set the dimensions of your chart
$myChart-&gt;set_chart_dimensions(500,300);

//set the perimeter of your chart
$myChart-&gt;set_chart_perimeter(50);

//set the different chart labels
$myChart-&gt;set_labels(&quot;My Title&quot;, &quot;My X-Label&quot;, &quot;My Y-Label&quot;);

//this references your add_line function and sets your data
$myChart-&gt;add_line($data);

//outputs your chart;
$myChart-&gt;plot();
</pre>
<p>See how easy and compact that is? With just six lines of code you created a line chart! Amazing! You can also just do it with three, simply remove the set_chart_dimensions, set_labels and set_chart_perimeter functions and it will grab the default values.</p>
<p>This is the final result of all our hard work!</p>
<p><img class="aligncenter size-full wp-image-601 img" title="06_011" src="http://www.bolducpress.com/wp-content/uploads/2007/05/06_011.jpg" alt="06_011" width="450" height="267" /></p>
<p>And look what happens when I pass it another array of data!</p>
<p><img class="aligncenter size-full wp-image-602 img" title="06_012" src="http://www.bolducpress.com/wp-content/uploads/2007/05/06_012.jpg" alt="06_012" width="450" height="269" /></p>
<h2>Conclusion:</h2>
<p>Go ahead and add some more features. Perhaps write a function that will set the color of the line or the background. The sky is the limit!</p>
<p>I hope this tutorial was helpful, feel free to post any comments or questions you may have.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1376001680822691";
/* 300x250, created 5/4/09 */
google_ad_slot = "7225239655";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bolducpress.com/tutorials/line-chart-class-with-gdlibrar/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
