<?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>Triggerdesign &#187; Simon</title>
	<atom:link href="https://triggerdesign.de/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>https://triggerdesign.de</link>
	<description>Web development</description>
	<lastBuildDate>Thu, 22 Oct 2015 09:37:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.39</generator>
	<item>
		<title>Our first Laravel application</title>
		<link>https://triggerdesign.de/our-first-laravel-application/</link>
		<comments>https://triggerdesign.de/our-first-laravel-application/#comments</comments>
		<pubDate>Wed, 29 Oct 2014 08:33:23 +0000</pubDate>
		<dc:creator><![CDATA[Simon]]></dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://triggerdesign.de/?p=199</guid>
		<description><![CDATA[Now it’s time to play with all your imaginations. With Laravel on your server, it is possible to create any web application you want – but for now we will make a good old blogging tool. Connect your database Laravel supports nearly every DBMS, but we will use MySQL to save our blog posts persistently. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Now it’s time to play with all your imaginations. With Laravel on your server, it is possible to create any web application you want – but for now we will make a good old blogging tool.</p>
<h3>Connect your database</h3>
<p>Laravel supports nearly every DBMS, but we will use MySQL to save our blog posts persistently. Go into<strong> app\config\database.php</strong> and tell the framework your database credentials by changing the already existing array called <strong>mysql</strong>:</p><pre class="crayon-plain-tag">'mysql' =&gt; array(
	'driver'    =&gt; 'mysql',
	'host'      =&gt; 'localhost',
	'database'  =&gt; 'DATABASE NAME',
	'username'  =&gt; 'USERNAME HERE',
	'password'  =&gt; 'PASSWORD',
	'charset'   =&gt; 'utf8',
	'collation' =&gt; 'utf8_unicode_ci',
	'prefix'    =&gt; '',
),</pre><p>&nbsp;</p>
<div class="blog-infofield">
<p>Note: For this example you should use an IDE that supports FTP connections. <a href="https://www.youtube.com/watch?v=AHK20LWEWXQ">PhpStorm </a>and <a href="http://www.patrickjwaters.com/blog/2011-07-24/how-setup-eclipse-php-pdt-remote-system-explorer-theme-manager-and-drupal-plugins/35">Eclipse</a> can automatically deploy the PHP files onto your server after every change you make.</p>
</div>
<h3>Use composer to install free code packages</h3>
<p>The package manager tool composer will help use once again. We will use the a <a href="https://github.com/JeffreyWay/Laravel-4-Generators">generator written by Jeffrey Way</a> to auto generate all the basic files we need for a resources like post entries or  comments.</p>
<p>Go to your root folder an open the<strong> composer.json </strong>file, you will have to add the <strong>&#8220;require-dev&#8221; </strong>array:</p><pre class="crayon-plain-tag">{
...
	"require": {
		"laravel/framework": "4.2.*"
	},
    "require-dev": {
        "way/generators": "~2.0"
    },
...
}</pre><p>Next step is to go to your ssh-console again and run the following command in the &#8220;<strong>superblog</strong>&#8221; folder (the root folder of your application):</p><pre class="crayon-plain-tag">composer update --dev</pre><p>The command above downloaded the generator package into your &#8220;superblog/vendor&#8221; folder, now you have to tell Laravel that it should use this package by going into &#8220;<strong>app/config/app.php</strong>&#8221; (the main config file of your application):</p><pre class="crayon-plain-tag">'providers' =&gt; array(
		/*...*/
		'Illuminate\View\ViewServiceProvider',
		'Illuminate\Workbench\WorkbenchServiceProvider',
		'Way\Generators\GeneratorsServiceProvider'
	),</pre><p></p>
<h3> Scaffold your blog</h3>
<p>We will now use the generator to scaffold our first resource: the posts.<br />
The generator will generate the controller the folliwing things for us:</p>
<ul>
<li>The controller in which we can handle actions like list, show, edit and delete.</li>
<li>The model in which we can define the relationships and special functions like getters and setters.</li>
<li>Files for the view</li>
<li>A migration file for the creation of a fitting database table.</li>
</ul>
<p>All you need for this is just one line of code! So go into your ssh and type in:</p><pre class="crayon-plain-tag">php artisan generate:resource post --fields="title:string, content:text"
#Accept every question that follows with an Y (for yes)</pre><p>In the end the generator will output the following sentence: <b>All done! Don&#8217;t forget to add &#8220;Route::resource(&#8216;posts&#8217;, &#8216;PostsController&#8217;);&#8221; to app/routes.php. </b>If you follow this suggestion you can already call the following URLs:</p>
<ul>
<li>domain.com/posts (for a list of all posts)</li>
<li>domain.com/posts/create (will show a form for the creation of a post)</li>
<li>domain.com/posts/1 (will show details about a not existing blog with an id that equals 1)</li>
<li>domain.com/posts/1/edit (will show a form for updating a post)</li>
</ul>
<p>Now we will do the same for the Comments:</p><pre class="crayon-plain-tag">php artisan generate:resource comment --fields="email: string, title:string, content:text, post_id:integer"  

#Accept every question that follows with an Y (for yes)</pre><p>After generating the post files go to &#8220;<strong>app/routes.php</strong>&#8221; and add <strong>Route::resource(&#8216;comments&#8217;, &#8216;CommentsController&#8217;); </strong>below the route for the posts.</p>
<div class="blog-infofield">
<p>You can step over the points below if you just scroll down, click download and copy the contentsof the github repository over the folder of your app.</p>
<p>&nbsp;</p>
</div>
]]></content:encoded>
			<wfw:commentRss>https://triggerdesign.de/our-first-laravel-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting started with Laravel</title>
		<link>https://triggerdesign.de/getting-started-with-laravel/</link>
		<comments>https://triggerdesign.de/getting-started-with-laravel/#comments</comments>
		<pubDate>Mon, 27 Oct 2014 19:26:42 +0000</pubDate>
		<dc:creator><![CDATA[Simon]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://triggerdesign.de/?p=174</guid>
		<description><![CDATA[What will be covered In this ePaper you will learn how to work with the MVC-Framework Laravel. You will experience the development of a running blog-application, that is easy to expand with free code packages, maintainable and fun to code. The presentation and this ePaper cover the following points: Prepare your webserver for the Framework [&#8230;]]]></description>
				<content:encoded><![CDATA[<h3><span style="font-size: 1.17em;">What will be covered</span></h3>
<p>In this ePaper you will learn how to work with the MVC-Framework Laravel. You will experience the development of a running blog-application, that is easy to expand with free code packages, maintainable and fun to code.</p>
<p><span id="more-174"></span></p>
<p>The presentation and this ePaper cover the following points:</p>
<ol>
<li>Prepare your webserver for the Framework</li>
<li>How to install composer</li>
<li>How install and configure Laravel</li>
<li>Bringing free pre-coded composer packages into your application</li>
<li>Scaffold a blogging tool using a generator</li>
<li>How you can use one line of code to make your Website accessible via REST</li>
<li>Forget never-ending HTML and PHP combinations – write your templates in Blade</li>
</ol>
<h3>The Result</h3>
<p>You can see the result here: <a href="http://epaper2.brainlovers.com/posts">http://epaper2.brainlovers.com/posts</a></p>
<p>If something does not work the way it should you can always take a look at this repository:<a href="https://github.com/triggerdesign/LaravelBlogDemo"> https://github.com/triggerdesign/LaravelBlogDemo</a></p>
<h3>A short introduction</h3>
<p>The server based script language PHP is well known for its less than desirable syntax, it is easy to use and runs on nearly every webserver without any further configuration. It is easy to create small web applications like a blog or a simple CMS with PHP, but bigger systems need a reliable architecture.</p>
<p>You need a lot of knowledge and have to spend a lot of time for a stable web application that makes use of modern technologies and software patterns such as MVC, ORMs and REST.</p>
<p>This is why Frameworks are important for professional web developers. But why should you reinvent the wheel, if there are awesome Frameworks that you can install and use for free.  A Framework should not only provide you shortcuts, tools and components, it should also have a good documentation and an active community.</p>
<p>Laravel is a framework that delivers everything you need for coding a web application of any size. You can use Laravel for small projects, but it also grows with your needs.<br />
This is the reason why Laravel currently is the most hyped PHP Framework:</p>
<div class="blog-highlightarea">
<p><a rel="gallery[174]" class="imglink" href="http://triggerdesign.de/wordpress/wp-content/uploads/php-frameworks.jpg"</a><img class="wp-image-184 aligncenter" src="http://triggerdesign.de/wordpress/wp-content/uploads/php-frameworks.jpg" alt="php frameworks" width="507" height="398" /></a></p>
</div>
<p>If you want to read more about this topic I recommend you this article: <a href="http://www.sitepoint.com/best-php-frameworks-2014/">Sitepoint &#8211; PHP Frameworks 2014</a></p>
<h4>You don&#8217;t like text based tutorials?</h4>
<p>You can skip the complete Requirements and installation section if you watch this free video tutorial made by the famous Jeffrey Way:</p>
<p><strong><a href="https://laracasts.com/series/laravel-from-scratch/episodes/1">https://laracasts.com/series/laravel-from-scratch/episodes/1</a></strong></p>
<p>If feel like a pro and prefer a quick start you can also read a shorter version of the Installation here:</p>
<p><strong><a href="http://laravel.com/docs/4.2/quick">http://laravel.com/docs/4.2/quick</a></strong></p>
<h3>Requirements</h3>
<p>I assume that you are using a Windows System for your daily work. If you are using a Mac or even Linux you will know how to use your command line to install the things you need.</p>
<p>This are the things you need to follow my presentation:</p>
<ul>
<li><b>A Linux environment</b>: It is easy to install Laravel if you use the right system. Because most websites run on a Linux based server we will use Ubuntu (please do not leave this tutorial now, you don’t have to be a Linux nerd to do this). You will also need SSH access to your server to run certain Laravel commands.</li>
<li><b>A Webserver: </b>You should install Apache (or Nginx) as a webserver, PHP 5.3 or greater and a MySQL Database together with phpMyAdmin.<br />
There are quadrillions of tutorials out there for this topic but I recommend watching this:<br />
Install a virtual Ubuntu Server on Windows: <a href="https://www.youtube.com/watch?v=Ykt3MeNwORQ">https://www.youtube.com/watch?v=Ykt3MeNwORQ</a><br />
Or rent a server somewhere, I am sure it will come with PHP, MySQL and phpMyAdmin.</li>
<li><b>An IDE or a Texteditor:</b> You can use the good old Windows notepad to develop Laravel applications, but an IDE like PhpStorm, Dreamweaver or Eclipse will help you a lot and increase your coding speed enormously. You will need FTP access (via your IDE or an FTP Client like <a href="https://filezilla-project.org/">FileZilla</a>) if you want to edit the files live on your webserver.</li>
</ul>
<p>When it is not possible for you to run a Linux system, you can also use Windows: <a href="http://www.wikihow.com/Install-Laravel-Framework-in-Windows">http://www.wikihow.com/Install-Laravel-Framework-in-Windows</a></p>
<p>If you can use Vagrant you can use the Laravel Homestead box, which is very easy to install: <a href="http://laravel.com/docs/4.2/homestead">http://laravel.com/docs/4.2/homestead</a></p>
<h3>Install Laravel</h3>
<h4>Install composer globally</h4>
<p><img class="size-medium wp-image-185 aligncenter" src="http://triggerdesign.de/wordpress/wp-content/uploads/logo-composer-transparent-252x300.png" alt="logo-composer-transparent" width="252" height="300" /></p>
<p>We will need “<strong>Composer</strong>” a package manager for PHP. This very helpful tool will download and update all your dependencies (like an authentication system, code generators and tons of other helpers and libraries) automatically.</p>
<p>Use an SSH client like “<strong>PuTTY</strong>” to connect to your server and paste in the following lines to install composer globally:</p><pre class="crayon-plain-tag">curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer</pre><p>When you now type in “<strong>composer</strong>” into you command line you will see some info about the composer commands you can use.</p>
<h4>Lets arrive</h4>
<p><img class="size-medium wp-image-189 aligncenter" src="http://triggerdesign.de/wordpress/wp-content/uploads/arrived-177x300.png" alt="arrived" width="177" height="300" /></p>
<p>&nbsp;</p>
<p>Now we will install the Laravel framework onto our web server. Instead of downloading the files like your grandma, you can use the thing you have just installed &#8211; <strong>composer</strong>:</p><pre class="crayon-plain-tag"># Go to your web folder
cd /var/www/httpdocs 

# Get the laravel installer
composer global require "laravel/installer=~1.1"

# Make the installer accessible via the "laravel" command
export PATH="$PATH:~/.composer/vendor/bin"

# Create a new laravel app with the name "superblog"
laravel new superblog</pre><p>Wait some seconds and lets watch the laravel installer doing its magic&#8230; After seeing the last composer output : &#8220;<em>Application ready! Build something amazing.</em>&#8221; you are ready to go!</p>
<h4><span style="font-size: 1em;">Take a look at Laravel</span></h4>
<p>Now your web folder will look like this:</p>
<ul>
<li>superblog
<ul>
<li>app/</li>
<li>bootstrap/</li>
<li>public/</li>
<li>vendor/</li>
<li>composer.json</li>
<li>artisan</li>
</ul>
</li>
</ul>
<p>Make sure your web server points to the &#8220;<strong>superblog/public</strong>&#8221; folder and give full rights to your &#8220;superblog/app/storage&#8221; folder:</p><pre class="crayon-plain-tag">sudo chmod -R 777 app/storage</pre><p></p>
<div class="blog-infofield">
<p>If you don&#8217;t follow the step above you will have to call &#8220;yourdomain.com/superblog/public/&#8221; instead of &#8220;yourdomain.com/&#8221; all the time, which is not very nice.</p>
</div>
<p>Visit your website and you will hopefully see the <strong>you have arrived</strong> logo.</p>
<h4>Our first Laravel application</h4>
<p><span class="blog-link-button ctnk-button ctnk-button-ico16 button-link"><a title="Our first Laravel application" href="http://triggerdesign.de/our-first-laravel-application/">Proceed</a></span></p>
]]></content:encoded>
			<wfw:commentRss>https://triggerdesign.de/getting-started-with-laravel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flat Fancybox styling</title>
		<link>https://triggerdesign.de/flat-fancybox-styling/</link>
		<comments>https://triggerdesign.de/flat-fancybox-styling/#comments</comments>
		<pubDate>Sun, 26 Jan 2014 11:24:34 +0000</pubDate>
		<dc:creator><![CDATA[Simon]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[jQuery Plugin]]></category>

		<guid isPermaLink="false">http://triggerdesign.de/?p=169</guid>
		<description><![CDATA[Im absolutely in love with the amazin lightbox alternative fancybox. If you want to use this jquery plugin commercialy please remember to use the 1.0 version of it (http://fancybox.net/) or buy the latest one at http://fancyapps.com/fancybox/. To use it in a flat webdesign you should transform the Javascript and CSS a bit, here is my version [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Im absolutely in love with the amazin lightbox alternative fancybox.<br />
If you want to use this jquery plugin commercialy please remember to use the 1.0 version of it (http://fancybox.net/) or buy the latest one at http://fancyapps.com/fancybox/.</p>
<p>To use it in a flat webdesign you should transform the Javascript and CSS a bit, here is my version of it:</p>
<h3>CSS</h3>
<p></p><pre class="crayon-plain-tag">.fancybox-nav {
    width: 150px;       
}

.fancybox-next {
	right: -65px;
}

.fancybox-prev {
	left: -65px;
}

.fancybox-nav span {
    visibility: visible;
    opacity: 0.5;
}

.fancybox-nav:hover span {
    opacity: 1;
}</pre><p></p>
<h3> Javascript</h3>
<p></p><pre class="crayon-plain-tag">$('.fancyboxLink').fancybox({
		padding: 0,
		margin : [50, 60, 20, 60],
		helpers	: {
			media : {

			},
			title	: {
				type: 'outside'
			},
			thumbs	: {
				width	: 100,
				height	: 100
			},
			overlay : {
				css : {
					'background' : 'rgba(0, 0, 0, 0.85)'
				}
			}
		}	
	});</pre><p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://triggerdesign.de/flat-fancybox-styling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nextgen Images directly from the Database</title>
		<link>https://triggerdesign.de/get-nextgen-gallery-images-direct-from-the-database/</link>
		<comments>https://triggerdesign.de/get-nextgen-gallery-images-direct-from-the-database/#comments</comments>
		<pubDate>Tue, 17 Sep 2013 09:04:57 +0000</pubDate>
		<dc:creator><![CDATA[Simon]]></dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://triggerdesign.de/?p=146</guid>
		<description><![CDATA[Create your own logic, but keep the nice backend from the NGG Wordpress Plugin.]]></description>
				<content:encoded><![CDATA[<p>For one of my projects I had to make my own gallery using the <a href="http://www.nextgen-gallery.com/">Nextgen Gallery by Alex Rabe</a> as basis. I wanted to make an unordered List, which then gets filtered by the <a href="http://mixitup.io/">Jquery Plugin Mixitup</a>. So I decided to write a little code that provides me the images directly from the database, working with the nggdb object.</p>
<h3>Source:</h3>
<p>&nbsp;</p><pre class="crayon-plain-tag">function trigger_get_nggalbum_galleries($albumid){
	global $nggdb;
	$albums = $nggdb-&gt;find_album($albumid);
	$gallery_ids = $albums-&gt;gallery_ids;
	return $gallery_ids;
}

function trigger_get_nggallery_images($galleryid){
	global $nggdb;
	$galleryImages 	=  $nggdb-&gt;get_gallery($galleryid);
	$gallery		=  $nggdb-&gt;find_gallery($galleryid);

	$images = array();
	foreach($galleryImages as $gImage){
		$cImage = array();
		$cImage['gallery'] = $gImage-&gt;title;
		$cImage['galleryid'] = $gImage-&gt;_ngiw-&gt;_orig_image-&gt;galleryid;
		//$cImage['ngiw'] = $gImage-&gt;_ngiw-&gt;_orig_image;

		$cImage['slug'] = $gImage-&gt;_ngiw-&gt;_orig_image-&gt;image_slug;
		$cImage['alttext'] = $gImage-&gt;_ngiw-&gt;_orig_image-&gt;alttext;
		$cImage['description'] = $gImage-&gt;_ngiw-&gt;_orig_image-&gt;description;

		$cImage['width'] = $gImage-&gt;_ngiw-&gt;_orig_image-&gt;meta_data-&gt;full-&gt;width;
		$cImage['height'] = $gImage-&gt;_ngiw-&gt;_orig_image-&gt;meta_data-&gt;full-&gt;height;

		$cStorage = $gImage-&gt;_ngiw-&gt;get_storage();
		$cImage['full'] = $cStorage-&gt;get_image_url($gImage-&gt;_ngiw-&gt;_orig_image, 'full');
		//$cImage['medium'] = $cStorage-&gt;get_image_url($gImage-&gt;_ngiw-&gt;_orig_image, 'medium');
		//$cImage['small'] = $cStorage-&gt;get_image_url($gImage-&gt;_ngiw-&gt;_orig_image, 'small');
		$cImage['thumb'] = $cStorage-&gt;get_image_url($gImage-&gt;_ngiw-&gt;_orig_image, 'thumbnail');

		$images[] = $cImage;
	}

	$galleryValues = array();
	$galleryValues['title'] =  $gallery-&gt;title;
	$galleryValues['slug'] =  $gallery-&gt;slug;
	$galleryValues['galdesc'] =  $gallery-&gt;galdesc;
	$galleryValues['page'] =  $gallery-&gt;pageid;
	$galleryValues['path'] =  $gallery-&gt;path;
	$galleryValues['abspath'] =  $gallery-&gt;abspath;

	$returner = array('gallery' =&gt; $galleryValues, 'images' =&gt; $images);
	return $returner;
}

function trigger_get_nggalbum_images($albumid, $orderingalleries = true){
	$nggalleries = agez_get_nggalbum_galleries($albumid);
	$images = array();
	foreach($nggalleries as $nggid){
		$cImages = agez_get_nggallery_images($nggid);

		if($orderingalleries)
			$images[$cImages['gallery']['slug']]['images'] = $cImages['images'];
		else
			$images = array_merge($cImages['images'], $images);

		$images[$cImages['gallery']['slug']]['gallery'] = $cImages['gallery'];
	}

	return $images;	
}</pre><p>Just use these functions inside your template or plugin.</p>
<p><em>trigger_get_nggalbum_galleries($albumid) </em>will return the ID`s of every gallery inside the given album</p>
<p><em>trigger_get_nggallery_images($galleryid) </em>returns all images inside a gallery as an array which contains information about the gallery and the images.</p><pre class="crayon-plain-tag">gallery =&gt; title, slug, galdesc, page, path, abspath
image =&gt;
[0] =&gt; gallery, galleryid, slug, alttext, description, width, height, full (url to full image), thumb (url to thumbnail)
...</pre><p>&nbsp;</p>
<p><em>trigger_get_nggalbum_images($albumid) </em>works just like <em>trigger_get_nggallery_images, but this time it will return all the images inside a given album.</em></p>
<h3>Usage:</h3>
<p></p><pre class="crayon-plain-tag">&lt;?php
$albumImages = trigger_get_nggalbum_images(1, true);
//Returns all images in the album ID:1 and orders them by their gallery membership (second argument)

foreach($albumImages as $galSlug =&gt; $galImages):
foreach($galImages['images'] as $galImageKey =&gt; $galImage):
&lt;li class="mix &lt;?=$galSlug ?&gt;" data-name="Abby" data-age="2"&gt;
				&lt;a href="&lt;?=$imgLink ?&gt;"&gt;
					&lt;img src="&lt;?=$galImage['thumb'] ?&gt;" /&gt;
					&lt;div class="mix-overlay"&gt;
						&lt;div class="mix-overlay-text"&gt;
						&lt;h3&gt;&lt;?=$galImage['slug'] ?&gt;&lt;/h3&gt;						
						&lt;span&gt;&lt;?=$galImage['gallery'] ?&gt;&lt;/span&gt;
						&lt;? if(!$galIsVideo): ?&gt;
						&lt;p&gt;&lt;?=$galImage['description'] ?&gt;&lt;/p&gt;
						&lt;? endif; ?&gt;
						&lt;/div&gt;
					&lt;/div&gt;
				&lt;/a&gt;
			&lt;/li&gt;
endforeach;
endforeach;
?&gt;</pre><p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://triggerdesign.de/get-nextgen-gallery-images-direct-from-the-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Canvas Me</title>
		<link>https://triggerdesign.de/canvas-me/</link>
		<comments>https://triggerdesign.de/canvas-me/#comments</comments>
		<pubDate>Mon, 05 Aug 2013 22:05:28 +0000</pubDate>
		<dc:creator><![CDATA[Simon]]></dc:creator>
				<category><![CDATA[jQuery Plugin]]></category>

		<guid isPermaLink="false">http://triggerdesign.de/wordpress/?p=105</guid>
		<description><![CDATA[Comprehensive jQuery Plugin that allows you to create games with Javascript and Canvas.]]></description>
				<content:encoded><![CDATA[<h3>How to implement:</h3>
<p></p><pre class="crayon-plain-tag">&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;script src="../js/canvasme/jquery.canvasme.js"&gt;&lt;/script&gt;</pre><p>&nbsp;</p>
<h3>Basic Usage:</h3>
<p></p><pre class="crayon-plain-tag">var MyCanvasMe = $("#myTestCanvas").canvasMe({
		backgroundColor: "#333",
		updateObjectFunc : function(cObject, vars, gameTime){

                },
                mouseclickFunc : function(pos, which, objects, vars){

                },
                mousemoveFunc : function(pos, which, pressed, objects){
                }
	});</pre><p></p>
<h3>Examples</h3>
<ol>
<li><a title="Gravishoot" href="http://triggerdesign.de/wordpress/88/">Gravishoot &#8211; Little gravitation game which uses canvasMe</a></li>
<li><a href="http://triggerdesign.de/download/canvasme/canvasmeTest.html">CanvasMe Test &#8211; Little tech demo</a></li>
<li><a title="Particle Simulation" href="http://triggerdesign.de/wordpress/particle-simulation/">Particle Simulation</a></li>
</ol>
<h3>Functions:</h3>

<table id="tablepress-1" class="tablepress tablepress-id-1">
<thead>
<tr class="row-1 odd">
	<th class="column-1">Function</th><th class="column-2">Description</th>
</tr>
</thead>
<tbody class="row-hover">
<tr class="row-2 even">
	<td class="column-1">objectsByRole</td><td class="column-2">Return all obechts by the given role<br />
[string]</td>
</tr>
<tr class="row-3 odd">
	<td class="column-1">moveCamera</td><td class="column-2">Moves the camera over the available space.<br />
moveX [int], moveY [int]</td>
</tr>
<tr class="row-4 even">
	<td class="column-1">setCamera</td><td class="column-2">Sets the camera at the given position<br />
worldX [int], worldY [int]</td>
</tr>
<tr class="row-5 odd">
	<td class="column-1">getRealPosition</td><td class="column-2">Return the current camera position relative to the origin. <br />
x [int], y [int]</td>
</tr>
<tr class="row-6 even">
	<td class="column-1">pointInWorld</td><td class="column-2">Returns true if the given point inside the world.<br />
x [int], y [int]</td>
</tr>
<tr class="row-7 odd">
	<td class="column-1">pointInView</td><td class="column-2">Returns true if the given point inside the current view.<br />
x [int], y [int]</td>
</tr>
<tr class="row-8 even">
	<td class="column-1">getFPS</td><td class="column-2">Return the current Frames per Second</td>
</tr>
<tr class="row-9 odd">
	<td class="column-1">addObject</td><td class="column-2">Adds an Object to the obejects array<br />
object [array], additional [array]<br />
<br />
The object array should contain x, y, size, color, type, opacity, visible</td>
</tr>
<tr class="row-10 even">
	<td class="column-1">addCircle</td><td class="column-2">_x [int], _y [int], _size [int], _color [hex-string],, _opacity [int], _additional [array]</td>
</tr>
<tr class="row-11 odd">
	<td class="column-1">addRect</td><td class="column-2">_x, _y, _w, _h, _color, _opacity, _add</td>
</tr>
<tr class="row-12 even">
	<td class="column-1">addImage</td><td class="column-2">_x, _y, _w, _h, _opacity, _source, _add</td>
</tr>
<tr class="row-13 odd">
	<td class="column-1">removeObject</td><td class="column-2">Removes the given object from the objects array.<br />
object [array]</td>
</tr>
<tr class="row-14 even">
	<td class="column-1">intNear</td><td class="column-2">Return true if the distance between two numbers is lower than the given tolerance. <br />
int1, int2, tolerance</td>
</tr>
<tr class="row-15 odd">
	<td class="column-1">pointNear</td><td class="column-2">Return true if the distance between two points is lower than the given tolerance. <br />
x1, y1, x2, y2, tolerance</td>
</tr>
<tr class="row-16 even">
	<td class="column-1">intersectRect</td><td class="column-2">Return true if two rectangles intersect.<br />
x1, y1, w1, h1, x2, y2, w2, h2</td>
</tr>
<tr class="row-17 odd">
	<td class="column-1">inRect</td><td class="column-2">Returns true if the second rectangle is inside the first.<br />
x1, y1, w1, h1, x2, y2, w2, h2</td>
</tr>
<tr class="row-18 even">
	<td class="column-1">deltaToRad</td><td class="column-2">Converts delta-X and delta-Y to an radian angle.<br />
dx [number], dy[number]</td>
</tr>
<tr class="row-19 odd">
	<td class="column-1">cooledDown</td><td class="column-2">Return true if a weapon or a skill reached its cooldown.<br />
lastUse, perSec</td>
</tr>
<tr class="row-20 even">
	<td class="column-1">pointOnCircle</td><td class="column-2">Return true if a given point is on a circle<br />
midX, midY, radius, alpha</td>
</tr>
<tr class="row-21 odd">
	<td class="column-1">drawText</td><td class="column-2">Draws a Text to the screen.<br />
text,x,y, color, fontsize, lineheight, fontfamily</td>
</tr>
<tr class="row-22 even">
	<td class="column-1">inView</td><td class="column-2">Return true if the given object is inside the screen<br />
object [array]</td>
</tr>
<tr class="row-23 odd">
	<td class="column-1">isPressed</td><td class="column-2">Return true if the given key is pressed<br />
key [int]</td>
</tr>
<tr class="row-24 even">
	<td class="column-1">randColor</td><td class="column-2">Return a random color in "rgb(x, y, z)"</td>
</tr>
<tr class="row-25 odd">
	<td class="column-1">randInt</td><td class="column-2">Returns a random Integer between the given minimum and maximum. If avoidZero is given, it will not return a number that is between -avoidZero and avoidZero.<br />
<br />
min[int], max[int], avoidZero[int]</td>
</tr>
<tr class="row-26 even">
	<td class="column-1">angleToSpeed</td><td class="column-2">Converts an angle to delta-X and delta-Y<br />
speed [speed of the object as int], angle</td>
</tr>
<tr class="row-27 odd">
	<td class="column-1">stop</td><td class="column-2">Stops the game</td>
</tr>
<tr class="row-28 even">
	<td class="column-1">start</td><td class="column-2">Starts the game</td>
</tr>
<tr class="row-29 odd">
	<td class="column-1">pauseUnpause</td><td class="column-2">Toggles between start and stop.</td>
</tr>
<tr class="row-30 even">
	<td class="column-1">getGameTime</td><td class="column-2">Returns the gametime.  The Gametime is the time in Milliseconds that passed since the game has started. This is really helpful for a lot of stuff like timers or cooldowns.</td>
</tr>
<tr class="row-31 odd">
	<td class="column-1"></td><td class="column-2"></td>
</tr>
</tbody>
</table>
<!-- #tablepress-1 from cache -->
]]></content:encoded>
			<wfw:commentRss>https://triggerdesign.de/canvas-me/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gravishoot</title>
		<link>https://triggerdesign.de/gravishoot/</link>
		<comments>https://triggerdesign.de/gravishoot/#comments</comments>
		<pubDate>Mon, 05 Aug 2013 21:00:40 +0000</pubDate>
		<dc:creator><![CDATA[Simon]]></dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://triggerdesign.de/wordpress/?p=88</guid>
		<description><![CDATA[A little Javascript game that uses my own canvas library canvasme.]]></description>
				<content:encoded><![CDATA[<h3>The Result:</h3>
<p><img class="alignnone size-full wp-image-89" alt="gravishoot" src="http://triggerdesign.de/wordpress/wp-content/uploads/gravishoot.jpg" width="900" height="250" /></p>
<p>&nbsp;</p>
<h3>The Code:</h3>
<p></p><pre class="crayon-plain-tag">//the gravitational force of the simulation
	var gravitation = 100;
    //a coefficient that makes the algorithm a bit more realistic
	var gFactor = 100000;
	
	
	var selectedField = "";  //the field selected with the mouse	
	var shootersLeft = 400; //ammount of point on the screen
	var shooterSize = 5; //default size of each point
	
	var lastMousePos = [0,0];
	
	var MyCanvasMe = $("#myTestCanvas").canvasMe({
		backgroundColor: "#333",
		updateObjectFunc : function(cObject, vars, gameTime){
			
			//Check every shooter (little point on the screen) step by step (shooter_n(egative) get attracted, shooter_p(ositive) get pushed away)
			if(cObject.role == "shooter_n" || cObject.role == "shooter_p"){
	
				//Points get reflected by the wall
				if(cObject.x >= 800 && cObject.vX > 0) cObject.vX *= -1;
				if(cObject.y >= 600 && cObject.vY > 0) cObject.vY *= -1;
				if(cObject.x <= 0 && cObject.vX < 0) cObject.vX *= -1;
				if(cObject.y <= 0 && cObject.vY < 0) cObject.vY *= -1;
				
                //Add velocity-X and velocityY- to the current postion         
				cObject.x += cObject.vX;
				cObject.y += cObject.vY;
				
				var inGfield = false;
				
				MyCanvasMe.objectsByRole("gfield", function(gObject){
					var cg =  gObject.size; //current Gravity
					
					//Checks if the current point is near a gravitation field
					if(MyCanvasMe.pointNear(gObject.x, gObject.y, cObject.x, cObject.y, cg)){
					inGfield = true;
					                                        
						distX = MyCanvasMe.round(cObject.x - gObject.x,2);
						distY = MyCanvasMe.round(cObject.y - gObject.y,2);
						
						relX = (distX < 0)? -1 : 1;
						relY = (distY < 0)? -1 : 1;
						
						//Get the absolute distance between gravitation field and point
						distXY = Math.min(MyCanvasMe.round(Math.sqrt(Math.pow(Math.abs(distX),2) + Math.pow(Math.abs(distY),2)),2), cg); 
                        
						//calculates the attraction to the gravitation field using the distance, the pole (line 56) and the gravitationfactor
						rgX = (relX * distXY)*cg*1.5;
						rgY = (relY * distXY)*cg*1.5;
                                                
						addX = rgX / gFactor;
						addY = rgY / gFactor;
						
						raddX = MyCanvasMe.round(addX, 3);
						raddY = MyCanvasMe.round(addY, 3);
						
						//points in the core of the gravitation field get slowed down
						if(distXY > 20){
							cObject.vX = cObject.vX * 0.995;
							cObject.vY = cObject.vY * 0.995;							
						}			

						//if the inner core get pushed away so they dont dissapear in the middle
						attract = distXY > 10;
						
						//the higher the gravitation the lower the size of the point (just a optical thingi)
						setSize = distXY / cg * 5;						
						cObject.size = setSize;
                                                						
						//adds the positive or negative gravitation to the current velocity
						if(attract) { cObject.vX -= addX; cObject.vY -= addY}
                        else        { cObject.vX += addX; cObject.vY += addY}
					}
					else{
						//point is moving free in space
					}
				});
				
				//if the point is moving free, set the size back to default
				if(!inGfield) cObject.size = shooterSize;
			}
                },
                mouseclickFunc : function(pos, which, objects, vars){
                    selectedField = 0;
					
					//select a gfield if mouse is clicked on one
                    MyCanvasMe.objectsByRole("gfield", function(gObject){
                        if(MyCanvasMe.pointNear(gObject.x, gObject.y, pos[0], pos[1], gObject.size))
                            selectedField = gObject;
                    });       
                },
                mousemoveFunc : function(pos, which, pressed, objects){
				
					//moving the selected gravitation field (see line 126)
                    if(pressed){
                       diffX = pos[0] - lastMousePos[0];
                       diffY = pos[1] - lastMousePos[1];
                       
                       selectedField.x += diffX;
                       selectedField.y += diffY;
                    }
                    
                    lastMousePos = pos;
                }
	});
	
	
        //Inserts n != x gravitation fields (color, position and size are random)
        for(var n = 0; n != 4; n++){
            gSize = MyCanvasMe.randInt(60,120);
            gColor = MyCanvasMe.randColor();
            gColor = "rgb(" +  MyCanvasMe.randInt(50,100,0) + "," +   MyCanvasMe.randInt(100,200,0) + "," +   MyCanvasMe.randInt(210,255,0) + ")";
            gPos = [MyCanvasMe.randInt(50,750),MyCanvasMe.randInt(50,550)];
            createGravi(gSize, gColor, gPos);            
        }
        
		
		//Creates one gravitation field
        function createGravi(size, color, position){
             cgfield = MyCanvasMe.addCircle(position[0], position[1], size, color,0.5,{ role: "gfield", gradient : true , composite : "lighter"}) ;
             MyCanvasMe.addCircle(position[0], position[1], 2, color,1.0,{ role: "gfield_center", connect : cgfield}) ;       
        }


		//Inserts shooters (little dots) until the maximum ammount is reached
		window.setInterval(function(){
            if(shootersLeft <= 0) return;
            csPos = [400, 300];
            for(var n = 0; n != 100; n++){
              var cAngle = MyCanvasMe.randInt(0,3600)/10;
              createShooter(csPos, cAngle);
           }        
        },300);
        
		//Creates one shooter at the given position facing the given angle
        function createShooter(position, angle){
            shootersLeft--;
            cColor = "rgb(" +  MyCanvasMe.randInt(200,255,0) + "," +   MyCanvasMe.randInt(100,200,0) + "," +   MyCanvasMe.randInt(5,100,0) + ")";
            var shooter_n = MyCanvasMe.addCircle(position[0], position[1], shooterSize, cColor,1.0,{ role: "shooter_n" }) ;
                   
            var angleSpeed = MyCanvasMe.angleToSpeed(MyCanvasMe.randInt(20,30) / 10,angle);
            shooter_n.vX = angleSpeed[0]; shooter_n.vY = angleSpeed[1];    
            shooter_n.composite = "lighter";            
        }</pre><p>If you want to use the code above you also have to use my jQuery Plugin called <strong>canvasMe</strong>: <a href="http://triggerdesign.de/wordpress/canvas-me/" target="_blank">http://triggerdesign.de/wordpress/canvas-me/</a></p>
]]></content:encoded>
			<wfw:commentRss>https://triggerdesign.de/gravishoot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Particle Simulation</title>
		<link>https://triggerdesign.de/particle-simulation/</link>
		<comments>https://triggerdesign.de/particle-simulation/#comments</comments>
		<pubDate>Mon, 05 Aug 2013 17:10:15 +0000</pubDate>
		<dc:creator><![CDATA[Simon]]></dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://triggerdesign.de/wordpress/?p=65</guid>
		<description><![CDATA[A small Javascript program that simulates particles in your browser using a Canvas object and jQuery.]]></description>
				<content:encoded><![CDATA[<h3>Screenshots:</h3>
<p><a rel="gallery[65]" class="imglink" href="http://triggerdesign.de/wordpress/wp-content/uploads/particle-simulation.jpg"</a><img class="alignnone size-medium wp-image-66" alt="particle simulation" src="http://triggerdesign.de/wordpress/wp-content/uploads/particle-simulation-300x300.jpg" width="300" height="300" /></a><a rel="gallery[65]" class="imglink" href="http://triggerdesign.de/wordpress/wp-content/uploads/particle-simulation2.jpg"</a><img class="alignnone size-medium wp-image-75" alt="particle simulation2" src="http://triggerdesign.de/wordpress/wp-content/uploads/particle-simulation2-300x300.jpg" width="300" height="300" /></a><a rel="gallery[65]" class="imglink" href="http://triggerdesign.de/wordpress/wp-content/uploads/particle-simulation.jpg"</a><img class="alignnone size-medium wp-image-66" alt="particle simulation" src="http://triggerdesign.de/wordpress/wp-content/uploads/particle-simulation-300x300.jpg" width="300" height="300" /></a></p>
<h3>The Sourcecode:</h3>
<p></p><pre class="crayon-plain-tag">$(function(){
		var PI_2 = Math.PI * 2;
		var c_movers = new Array();
		var c_ammount = &lt;? if(empty($_GET["a"])) echo 450; else echo $_GET["a"]; ?&gt;;
		var c_canvas;
		var c_size;
		var c_mid;
		var c_gravity = 0;

		var c_pfriction = 0.8;
		var c_friction  = 0.96;

		var ctx;

		c_init();

		function c_init(){
			c_log("init");
			c_log("click on the field to turn on the gravity");
			c_log("move your mouse - watch the magic happen^^");
			c_canvas = $("canvas")[0];
			ctx = $("canvas")[0].getContext("2d");
			c_size = { w: $(c_canvas).width(),  h: $(c_canvas).height() };
			c_mid = { x: $(c_canvas).width()/2,  y: $(c_canvas).height()/2 };

			var i = c_ammount;
			while(i--) c_add_mover();

			setInterval(c_update, 30);
			setInterval(c_draw, 44);
		}

		function c_physics(_m){
			_m.right	= _m.x + _m.size/2;
			_m.left		= _m.x - _m.size/2;
			_m.top		= _m.y - _m.size/2;
			_m.bottom	= _m.y + _m.size/2;

			if(_m.d.xy &lt; c_size.w *0.95){
				var toAcc = ( 1 - ( _m.d.xy / (c_size.w *0.86) ) ) * c_size.w * 0.0014 * c_gravity;
				_m.vX -= _m.d.x * toAcc;
				_m.vY -= _m.d.y * toAcc;
			}
			/*
			if (_m.d.xy &lt; c_size.w *0.125 &amp;&amp; c_gravity != 0){
				var mAcc = ( 1 - ( _m.d.xy / (c_size.w *0.125) ) ) * c_size.w * 0.00026;
				_m.vX += c_mid.x * mAcc;
				_m.vY += c_mid.y * mAcc;
			}*/

			if(c_gravity != 0){
				_m.vX *= c_friction;
				_m.vY *= c_friction;
				_m.v = 2;
			}
			else{
				_m.vY += 0.3;

				_m.vY *= 0.99;
				_m.vX *= 0.99;

			}

			var vx_before = _m.vX; var vy_before = _m.vY;
			if ( _m.right &gt; c_size.w ){
				_m.x = c_size.w - _m.size/2;
				_m.vX *= -1;
			}

			else if (_m.left &lt; 0 ){
				_m.x = 0 + _m.size/2;;
				_m.vX *= -1;
			}

			if ( _m.bottom &gt; c_size.h ){
				_m.y = c_size.h - _m.size/2;
				_m.vY *= -1;
			}
			else if ( _m.top &lt; 0 ){
				_m.y = 0 + _m.size/2;
				_m.vY *= -1;
			}

			if(vx_before != _m.vX || vy_before != _m.vY)
				_m.v *= c_pfriction;

			_m.v = Math.max(_m.v, 0.5);
		}

		function c_rand(minVal,maxVal, floats, randswitch){
			if(typeof floats == 'undefined') floats = 5;
			var randVal = minVal+(Math.random()*(maxVal-minVal));
			var val =  parseFloat(randVal.toFixed(floats));

			if(randswitch)
				if(Math.random() &gt; 0.5) val *= -1;

			return val;
		}

		function c_add_mover(){
			var new_mover = new mover();
			c_movers.push(new_mover);
		}

		function mover(){
			this.color = "rgb(" + c_rand(200,255,0) + "," +  c_rand(100,200,0) + "," +  c_rand(5,100,0) + ")";
			this.y     = c_mid.y;
			this.x     = c_mid.x;
			this.vX    = c_rand(0.1,3,3,true);
			this.vY    = c_rand(1,2,3);
			this.size  = 5; 
			this.v     = 2; 
			this.d		= {x: 0, y: 0, xy: 0};
			this.alpha	= 1.0;
		}

		function c_log(str){
			var curr_log = $("textarea").val();
			$("textarea").val(curr_log + "\n" + str);

			$("textarea").scrollTop(
					$("textarea")[0].scrollHeight - $("textarea").height()
			);
		}

		//***************************************//

		function c_update(){
			$.each(c_movers, function(index, m){
				m.x += m.vX * m.v;
				m.y += m.vY * m.v;

				m.d.x = m.x - c_mid.x;
				m.d.y = m.y - c_mid.y; 
				var d = Math.sqrt( m.d.x * m.d.x + m.d.y * m.d.y ) || 0.001;
				m.d.xy = d;
				m.d.x /= d;
				m.d.y /= d;

				var d_percent = Math.min(Math.max(Math.abs(m.d.xy / 250), 0.01),1);
				m.alpha = Math.max(1-(d_percent), 0.3);
				m.size = Math.max(d_percent*13,0.5);

				c_physics(m);
			});
		}

		function c_draw(){
			ctx.globalCompositeOperation = "source-over";

			ctx.clearRect(0,0,c_size.w,c_size.h, "#fff");

			$.each(c_movers, function(index, m){
				ctx.beginPath();
				ctx.fillStyle = m.color;
				ctx.globalAlpha  = m.alpha; 
				ctx.globalCompositeOperation = "lighter";
				ctx.arc( m.x , m.y , m.size , 0 , PI_2 , true );
				ctx.fill();
				ctx.closePath();
			});
		}

		$(c_canvas).click(function(){
			if(c_gravity == 0)
				c_gravity = 1;
			else
				c_gravity = 0;
		});

		$(c_canvas).mousemove(function(event){
			if(c_gravity == 0)
				c_mid = { x: $(c_canvas).width()/2,  y: $(c_canvas).height()/2 };
			else
				c_mid = { x: event.clientX -20,  y:  event.clientY -30};
		});

	});</pre><p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://triggerdesign.de/particle-simulation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
