<?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>Midwinter Duncan Grant</title>
	<atom:link href="https://www.midwinter-dg.com/feed.xml/feed" rel="self" type="application/rss+xml" />
	<link>https://www.midwinter-dg.com</link>
	<description>Web Designer / Front-End Developer / Wordpress Developer</description>
	<lastBuildDate>Sun, 29 Oct 2017 14:41:43 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.midwinter-dg.com/wp-content/uploads/2011/05/cropped-favicon-32x32.png</url>
	<title>Midwinter Duncan Grant</title>
	<link>https://www.midwinter-dg.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to get a quick custom mobile preview in Safari</title>
		<link>https://www.midwinter-dg.com/how-to-get-a-quick-custom-mobile-preview-in-safari.html</link>
		
		<dc:creator><![CDATA[duncanmid]]></dc:creator>
		<pubDate>Sun, 29 Oct 2017 14:29:45 +0000</pubDate>
				<category><![CDATA[automator]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[responsive design]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[web development]]></category>
		<guid isPermaLink="false">https://www.midwinter-dg.com/?p=1476</guid>

					<description><![CDATA[How to quickly preview webpages for mobile in Safari by using Automator to create a custom sized popup window with mobile user agent string]]></description>
										<content:encoded><![CDATA[<p>Sometimes when you&#8217;re working you just need to quicky view the current page as it would appear on mobile. Maybe you already have the page + web inspector open and you don&#8217;t want to waste time switching to Safari&#8217;s <strong><span class="turquoise">Responsive Design</span></strong> mode. Nevertheless you&#8217;d like to view and interact with the page as if on mobile…</p>
<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-1495" src="https://www.midwinter-dg.com/wp-content/uploads/2017/10/safari-custom-mobile-preview.png" alt="Safari with Website Popup window" width="630" height="436" data-wpmf_image_lightbox="https://www.midwinter-dg.com/wp-content/uploads/2017/10/safari-custom-mobile-preview.png" data-wpmf_size_lightbox="large" data-wpmflightbox="0" srcset="https://www.midwinter-dg.com/wp-content/uploads/2017/10/safari-custom-mobile-preview.png 630w, https://www.midwinter-dg.com/wp-content/uploads/2017/10/safari-custom-mobile-preview-300x208.png 300w" sizes="(max-width: 630px) 100vw, 630px" /></p>
<p>…Here&#8217;s how you can do just that, opening the current page in a floating popup window with a custom size and user agent!</p>
<p>To achieve this you can use <strong><span class="turquoise">Automator</span></strong> to set up a service which will be accessible from the “<span class="turquoise">Services</span>” sub-menu of the main <strong><span class="turquoise">Safari</span></strong> menu.</p>
<p><span class="num">1</span> Open <span class="orange">/Applications/Automator</span> and when the main window opens, select “<span class="turquoise">Service</span>” as the type of document that you want to create.</p>

<a href='https://www.midwinter-dg.com/wp-content/uploads/2017/10/automator-new-service.png'><img decoding="async" width="150" height="150" src="https://www.midwinter-dg.com/wp-content/uploads/2017/10/automator-new-service-150x150.png" class="attachment-thumbnail size-thumbnail" alt="automator - create new service" /></a>

<p><span class="num">2</span> Once selected you can start constructing the workflow. Above the main workflow area (where is says “<span class="turquoise">Drag actions or files here to build your workflow</span>”) you should see a panel with “<span class="turquoise">Service recieves</span>” and several controls. Modify the controls to read “<span class="turquoise">Service recieves no input in Safari</span>”.</p>
<p><img decoding="async" class="alignnone size-full wp-image-1486" src="https://www.midwinter-dg.com/wp-content/uploads/2017/10/service-options.png" alt="" width="560" height="62" srcset="https://www.midwinter-dg.com/wp-content/uploads/2017/10/service-options.png 560w, https://www.midwinter-dg.com/wp-content/uploads/2017/10/service-options-300x33.png 300w" sizes="(max-width: 560px) 100vw, 560px" /></p>
<p><span class="num">3</span> Now, from the Library of actions in the left-hand column select “<span class="turquoise">Internet</span>”, and the from the second column, drag the “<span class="turquoise">Get Current Webpage from Safari</span>” and “<span class="turquoise">Website Popup</span>” actions into the main workflow area.</p>

<a href='https://www.midwinter-dg.com/wp-content/uploads/2017/10/website-popup-workflow.png'><img loading="lazy" decoding="async" width="150" height="150" src="https://www.midwinter-dg.com/wp-content/uploads/2017/10/website-popup-workflow-150x150.png" class="attachment-thumbnail size-thumbnail" alt="Adding a Website Popup in Automator" /></a>

<p><span class="num">4</span> Finally in the “<span class="turquoise">Website Popup</span>” action choose a size and user agent &#8211; I&#8217;ve selected <span class="orange">375x667px</span> for iPhone7 and the iPhone user agent &#8211; then save the workflow.</p>
<p>You should now be able to preview the current tab in Safari by selecting your new workflow from the “<span class="turquoise">Services</span>” sub-menu of the main Safari menu.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1493" src="https://www.midwinter-dg.com/wp-content/uploads/2017/10/safari-services-menu.png" alt="" width="510" height="300" data-wpmf_image_lightbox="https://www.midwinter-dg.com/wp-content/uploads/2017/10/safari-services-menu.png" data-wpmf_size_lightbox="large" data-wpmflightbox="0" srcset="https://www.midwinter-dg.com/wp-content/uploads/2017/10/safari-services-menu.png 510w, https://www.midwinter-dg.com/wp-content/uploads/2017/10/safari-services-menu-300x176.png 300w" sizes="auto, (max-width: 510px) 100vw, 510px" /></p>
<p>If you want to try this with a different browser it should be possible with just a little bit of extra work. I haven&#8217;t tried it myself but it should work if you replace <span class="turquoise">Safari</span> in stage <span class="num">2</span> with the browser you want to use, and replace the first action “<span class="turquoise">Get Current Webpage from Safari</span>” with the “<span class="turquoise">Run AppleScript</span>” action. You will then need to write an AppleScript to get the current URL from the browser window &#8211; but maybe that&#8217;s something for another post…</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Capturing webpages from Safari using Automator and Webkit2Png</title>
		<link>https://www.midwinter-dg.com/capturing-webpages-from-safari-using-automator-and-webkit2png.html</link>
		
		<dc:creator><![CDATA[duncanmid]]></dc:creator>
		<pubDate>Mon, 28 Mar 2016 17:53:00 +0000</pubDate>
				<category><![CDATA[automator]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[Webkit2Png]]></category>
		<guid isPermaLink="false">http://www.midwinter-dg.com/?p=800</guid>

					<description><![CDATA[Being able to save full length screenshots of webpages is very useful. This article explains how to do that directly fron the Safari borwser]]></description>
										<content:encoded><![CDATA[<p>Being able to save full length screenshots of webpages is very useful. A quick scan of the Mac <span class="turquoise">AppStore</span> reveals several apps at different price points that fill this niche but I&#8217;m going to show you how you can achieve this functionality for free on the Mac. In my example I will show you how to capture a full-length image of the current page being viewed in <strong><span class="turquoise">Safari</span></strong>.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1168" src="https://www.midwinter-dg.com/wp-content/uploads/2016/03/safari-web-page-capture-1.png" alt="Safari Services Menu" width="630" height="340" srcset="https://www.midwinter-dg.com/wp-content/uploads/2016/03/safari-web-page-capture-1.png 630w, https://www.midwinter-dg.com/wp-content/uploads/2016/03/safari-web-page-capture-1-300x162.png 300w" sizes="auto, (max-width: 630px) 100vw, 630px" /></p>
<p>This is an image of the kind of thing we&#8217;re aiming to create.</p>
<p>To create the image we will be using <a href="http://www.paulhammond.org/webkit2png/" target="_blank" rel="nofollow noopener">Webkit2Png</a> &#8211; a command line tool created by Paul Hammond, and to make this tool available from <span class="turquoise">Safari</span>, we will be using <strong><span class="turquoise">Automator</span></strong> which comes installed on every Mac.</p>
<p><span class="num">1</span> First of all download a copy of <strong><span class="turquoise">webkit2png</span></strong> to the desktop of your Mac. <a href="https://raw.github.com/paulhammond/webkit2png/master/webkit2png" target="_blank" rel="noopener">Download Webkit2Png</a>. Save this file as &#8216;<span class="orange">webkit2png</span>&#8216; without any file extension.</p>
<p><span class="num">2</span> If you are using <strong>Mac OSX 10.11+</strong> (<strong>El Capitan</strong>), you will need to make a small edit to the script before can continue:</p>
<p>Open <span class="turquoise">webkit2png</span> in your chosen Text Editor / IDE and search for the line <span class="orange">422</span>:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-bash">app = AppKit.NSApplication.sharedApplication()</code></pre>
</div>
</div>
<p>Add the following code before line <span class="orange">422</span>:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-bash"># Handles ATS HTTPS requirement introduced in El Cap
    if options.ignore_ssl_check:
        AppKit.NSBundle.mainBundle().infoDictionary()['NSAppTransportSecurity'] = dict(NSAllowsArbitraryLoads = True)</code></pre>
</div>
</div>
<p>This extra code is to get past the <span class="turquoise">App Transport</span> Security error that <strong>El Capitan</strong> throws when you request a <span class="turquoise">non-https</span> site.<br />
Now save the file.</p>
<p><span class="num">3</span> Now you need to move this file to you <span class="orange">/usr/bin/local/</span> directory. To do this, open <strong>Terminal.app</strong> that resides in your <strong>Utilities</strong> directory. If you don&#8217;t know where the <strong>Utilities</strong> directory is located you can open it directly by using the keyboard shortcut &#8216;<strong>⌘⇧U</strong>&#8216; in the <strong>Finder</strong>. Once <strong>Terminal.app</strong> is open, you can move the <span class="turquoise">Webkit2Png</span> file from your Desktop to to your <span class="orange">/usr/bin/local/</span> directory with the following command:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-bash">sudo mv ~/Desktop/webkit2png /usr/local/bin/</code></pre>
</div>
</div>
<p>You will be asked to enter your account password, and then the file will be moved to the  <span class="orange">/usr/local/bin/</span> directory.</p>
<p><span class="num">4</span> The next thing to do is set the correct <strong>file permissions</strong> on the <span class="turquoise">webkit2png</span> script. Again using Terminal.app, enter the following command to update the permissions on the file:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-bash">chmod a+x /usr/local/bin/webkit2png</code></pre>
</div>
</div>
<p><span class="num">5</span> At this point, <span class="turquoise">webkit2png</span> is ready to use. If you&#8217;re happy using the command line, you can simply capture webpages by typing the following command in to <strong>Terminal.app</strong>:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-bash">webkit2png https://www.midwinter-dg.com/my-blog --width=1280 -F --delay=5 --ignore-ssl-check</code></pre>
</div>
</div>
<p>This command will save a full length screenshot of the url <span class="orange">https://www.midwinter-dg.com/my-blog</span>, with a width of <span class="orange">1280px.</span> The flag <span class="orange">-F</span> is for full width, the delay to ensure the page and any scripts have time to load and the <span class="orange">&#8211;ignore-ssl-check</span> is to ensure non <span class="orange">https</span> pages will be saved.</p>
<p>However, we want to set up <span class="turquoise">Automator</span> to save a screenshot of the current page directly from <span class="turquoise">Safari</span> to the Desktop…</p>
<p><span class="num">6</span> Open <span class="turquoise">Automator.app</span> and select &#8216;<span class="orange">Service</span>&#8216; from the <span class="turquoise">Document type</span> menu. Above the main workflow panel of the Automator app you will see some dropdown menus that read as follows:<br />
<em>&#8216;Service receives <span class="orange">text</span> in any <span class="orange">application</span>&#8216;</em>.<br />
Modify this to read:<br />
<em>&#8216;Service receives <span class="orange">no input</span> in <span class="orange">Safari</span>&#8216;</em>.<br />
Next, from the <span class="turquoise">Library</span> on the left select <span class="orange">Internet</span>, and then drag the &#8216;<span class="orange">Get Current Webpage from Safari</span>&#8216; in to the main workflow panel.</p>
<p><span class="num">7</span> Now, from the <span class="turquoise">Library</span> select &#8216;<span class="orange">Utilities</span>&#8216; and drag the &#8216;<span class="orange">Run Shell Script</span>&#8216; action in to the workflow panel below the previous action. Modify the &#8216;Pass input&#8217; menu in the &#8216;Run Shell Script&#8217; action to read &#8216;as arguments&#8217;, and edit the contents of the action to read:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-bash">/usr/local/bin/webkit2png $@ --dir=/Users/***/Desktop/ -w 1280 --clipwidth 1 -F --delay=5 --ignore-ssl-check</code></pre>
</div>
</div>
<p>where <span class="orange">***</span> is the name of your user account Home folder.<br />
Then save the workflow. In the example above, the screenshot is being saved with a width of 1280px, so I named it &#8216;<span class="turquoise">Capture Page @ 1280px</span>&#8216;. I also created services for several different widths.</p>
<div class="gallery-left">

<a href='https://www.midwinter-dg.com/wp-content/uploads/2016/03/Webkit2Png-Automator-script.png'><img loading="lazy" decoding="async" width="150" height="150" src="https://www.midwinter-dg.com/wp-content/uploads/2016/03/Webkit2Png-Automator-script-150x150.png" class="attachment-thumbnail size-thumbnail" alt="Webkit2Png automator script" /></a>

</div>
<p><span class="num">8</span> To use the new service, open Safari, open a webpage and then from the Safari menu select Services and choose your new service. After a short delay you should see the screenshot saved to your desktop.</p>
<p>If you want to play around with the options available, open <span class="turquoise">Terminal.app</span> and type</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-bash">webkit2png -- help</code></pre>
</div>
</div>
<p>to see a full list of all available options.<br />
Enjoy!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Additional color palettes for the Mac OSX color picker</title>
		<link>https://www.midwinter-dg.com/permalink-additional-color-palettes-for-the-max-osx-color-picker_2014-08-16.html</link>
		
		<dc:creator><![CDATA[duncanmid]]></dc:creator>
		<pubDate>Sat, 16 Aug 2014 07:04:50 +0000</pubDate>
				<category><![CDATA[color]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[downloads]]></category>
		<guid isPermaLink="false">http://www.midwinter-dg.com/?p=390</guid>

					<description><![CDATA[Following on form my previous article: How I created a set of Pantone swatches for the Mac OSX color picker, I have created some more additional Mac OSX color palettes]]></description>
										<content:encoded><![CDATA[<figure id="attachment_1170" aria-describedby="figcaption_attachment_1170" class="wp-caption alignnone" itemscope itemtype="http://schema.org/ImageObject"><img loading="lazy" decoding="async" itemprop="contentURL" class="size-full wp-image-1170" src="https://www.midwinter-dg.com/wp-content/uploads/2014/08/extra-swatches.png" alt="Extra Swatches" width="630" height="344" srcset="https://www.midwinter-dg.com/wp-content/uploads/2014/08/extra-swatches.png 630w, https://www.midwinter-dg.com/wp-content/uploads/2014/08/extra-swatches-300x164.png 300w" sizes="auto, (max-width: 630px) 100vw, 630px" /><figcaption id="figcaption_attachment_1170" class="wp-caption-text" itemprop="description">Additional color palettes for Mac OSX</figcaption></figure>
<p>Following on form my previous article: <a href="https://www.midwinter-dg.com/permalink-how-I-created-a-set-of-pantone-swatches-for-the-mac-osx-color-picker_2014-08-09.html"><em>How I created a set of Pantone swatches for the Mac OSX color picker</em></a>, I have created some more additional <strong>Mac OSX color palettes</strong>.</p>
<p>The following palettes can be found on my <a href="https://www.midwinter-dg.com/resources.html">resources</a> page:</p>
<ul>
<li><em>CSS Named Colors</em></li>
<li><em>TOYO Swatches</em></li>
<li><em>Focoltone Swatches</em></li>
<li><em>Trumatch Swatches</em></li>
</ul>
<p>You can download them from the <a href="https://www.midwinter-dg.com/resources.html#osx-color-palette">OSX Color Palettes</a> section</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How I created a set of Pantone swatches for the Mac OSX color picker</title>
		<link>https://www.midwinter-dg.com/permalink-how-I-created-a-set-of-pantone-swatches-for-the-mac-osx-color-picker_2014-08-09.html</link>
		
		<dc:creator><![CDATA[duncanmid]]></dc:creator>
		<pubDate>Sat, 09 Aug 2014 06:41:10 +0000</pubDate>
				<category><![CDATA[color]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[pantone]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">http://www.midwinter-dg.com/?p=387</guid>

					<description><![CDATA[For a long time now I have wanted to have a full set of Pantone swatches in the Mac OSX color picker. I searched for a quick solution online but never found anything. So in the end I realised that if this was going to happen I would have to do something about it myself]]></description>
										<content:encoded><![CDATA[<p>For a long time now I have wanted to have a full set of <span class="strong">Pantone swatches</span> in the <span class="strong">Mac OSX color picker</span>. I searched for a quick solution online but never found anything. So in the end I realised that if this was going to happen I would have to do something about it myself…</p>
<figure id="attachment_1177" aria-describedby="figcaption_attachment_1177" class="wp-caption alignnone" itemscope itemtype="http://schema.org/ImageObject"><img loading="lazy" decoding="async" itemprop="contentURL" class="size-full wp-image-1177" src="https://www.midwinter-dg.com/wp-content/uploads/2014/08/pantone-swatches.jpg" alt="Pantone Swatches" width="630" height="340" srcset="https://www.midwinter-dg.com/wp-content/uploads/2014/08/pantone-swatches.jpg 630w, https://www.midwinter-dg.com/wp-content/uploads/2014/08/pantone-swatches-300x162.jpg 300w" sizes="auto, (max-width: 630px) 100vw, 630px" /><figcaption id="figcaption_attachment_1177" class="wp-caption-text" itemprop="description">Pantone Swatches in the Mac OSX Color Picker</figcaption></figure>
<h2>Stage 1 &#8211; getting a list of swatches</h2>
<p>Whilst it&#8217;s very easy to create a custom color palette and add your own colors to it I had no particular desire to try and enter an entire Pantone swatch book by hand. A quick search online revealed several sites with lists of swatches and their respective <span class="turquoise">rgb</span> values. So that&#8217;s great &#8211; the difficult part has already been done by someone else! I checked out a few lists and in the end settled on this one: <a href="http://en.labelpartners.com/pantone_coated_table.html" rel="nofollow">http://en.labelpartners.com/pantone_coated_table.html</a> which gave a full set with <span class="turquoise">hex</span> and <span class="turquoise">rgb</span> values laid out in a <span class="orange">&lt;table&gt;</span> just perfect for scraping with <span class="turquoise">php</span>.</p>
<h2>Stage 2 &#8211; scraping the data into a database</h2>
<p>The next task was to get the data off the webpage and into a database. For tasks like this I always use <a href="http://simplehtmldom.sourceforge.net" rel="nofollow">PHP Simple HTML DOM Parser</a>. It&#8217;s very easy to learn &#8211; and makes this kind of task very simple.</p>
<p>Before writing a script to scrape the data I set up a <span class="turquoise">myqsl</span> database <span class="orange">&#8216;pantone_swatches&#8217;</span> with a table <span class="orange">&#8216;coated_swatches&#8217;</span> to hold the data. The table structure was as follows:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-sql">
CREATE TABLE `coated_swatches` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  `hex` varchar(7) DEFAULT NULL,
  `red` varchar(5) DEFAULT NULL,
  `green` varchar(5) DEFAULT NULL,
  `blue` varchar(5) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</code></pre>
</div>
</div>
<p>At this point I wasn&#8217;t really sure if I needed the <span class="turquoise">rgb</span> values or the <span class="turquoise">hex</span> values so I decided to get everything just in case.</p>
<p>Now, with the database ready it was time to scrape the data. I wrote the following <span class="turquoise">php</span> script making use of PHP Simple HTML DOM Parser to sort through each <em>table row</em> (<span class="orange">&lt;tr&gt;</span>) and get the text content from each <em>table data cell</em> (<span class="orange">&lt;td&gt;</span>) and inset as a row in the database:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-php">
//connect to mysql...
$user="root";
$host="localhost";
$password="YOUR_PASSWORD_HERE";
$database="pantone_swatches";
$table="coated_swatches";
$cxn = mysqli_connect ($host, $user, $password, $database)
or die (mysqli_error($cxn));

//include simple html dom...
require('simple_html_dom.php');

//get page source...
$html = file_get_html('http://en.labelpartners.com/pantone_coated_table.html');

$count = 0;

//loop through each &lt;tr&gt;...
foreach($html-&gt;find('tr') as $row) {

	//extract values from each &lt;td&gt;...    
	$name 	= $row-&gt;find('td', 0)-&gt;innertext;		
	$hex 	= $row-&gt;find('td', 1)-&gt;innertext;
	$red 	= $row-&gt;find('td', 2)-&gt;innertext;
	$green 	= $row-&gt;find('td', 3)-&gt;innertext;
	$blue 	= $row-&gt;find('td', 4)-&gt;innertext;
	
	//ignore &lt;table&gt; 'header' row...
	if($count &gt; 0) {
	
		echo $count.': '.$name.'&lt;br&gt;';
		
		//inset in to db...
		$query="
			INSERT INTO
			$table
			(name, hex, red, green, blue)
			VALUES
			('$name', '$hex', '$red', '$green', '$blue')
		";
		
		$result = mysqli_query ($cxn,$query) or die (mysqli_error($cxn));		
	}
	
	$count++;
}
</code></pre>
</div>
</div>
<p>Once the script was ready I launched it and waited for it to complete then checked out the new table to see if everything was OK. The script performed perfectly but now, how to get those values into the Mac OSX color picker?</p>
<h2>Stage 3 &#8211; building a list of NSColors</h2>
<p>You can manually create a custom color palette by opening the color picker, clicking on the third tab <em>&#8216;color palettes&#8217;</em> and then clicking on the small <em>&#8216;gear&#8217;</em> icon and selecting <em>&#8216;new&#8217;</em>. When you do this the new palette is saved in <span class="orange">~/Library/Colors/</span> with <span class="orange">.clr</span> for its file extension. The first thing I tried to do was open one of these <span class="orange">.clr</span> files in a text editor. Once I had tried that I quickly realised it wasn&#8217;t as simple as copying the structure and saving a new file! So, back to the internet and a bit more research revealed a way to generate a <span class="turquoise">.clr</span> file using <strong>Xcode</strong>. <span class="turquoise">.clr</span> files can be generated by creating a new <span class="turquoise">NSColorList</span> object and setting colors, like this:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-objectivec">
//create list
NSColorList *list = [NSColorList.alloc initWithName:@"My Custom Color Palette"];

//add colors
[list setColor:[NSColor colorWithRed:0.831 green:0.835 blue:0.831 alpha:1.0] forKey:@"Custom Color 1"];
[list setColor:[NSColor colorWithRed:0.765 green:0.773 blue:0.769 alpha:1.0] forKey:@"Custom Color 2"];
[list setColor:[NSColor colorWithRed:0.725 green:0.733 blue:0.733 alpha:1.0] forKey:@"Custom Color 3"];

//save file to ~/Library/Colors/
[list writeToFile: [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Colors/"]];
</code></pre>
</div>
</div>
<p>So now, all I needed to do was generate the <strong>objective-c</strong> code from the data in the database, the only difference being that the <span class="turquoise">rgb</span> values in the database range from <em>0 to 255</em> whereas the <span class="turquoise">rgb</span> values for the <span class="turquoise">NSColor</span> class range from <em>0 to 1</em>. This small difference was rectified by dividing the database <span class="turquoise">rgb</span> values by <span class="orange">255</span> and rounding the result to <span class="orange">3</span> decimal places. The code I used to output the <strong>objective-c</strong> code was as follows:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-php">
//connect to mysql...
$user="root";
$host="localhost";
$password="YOUR_PASSWORD_HERE";
$database="pantone_swatches";
$table="coated_swatches";
$cxn = mysqli_connect ($host, $user, $password, $database)
or die (mysqli_error($cxn));

//get data...
$query = "SELECT * FROM $table";
$result = mysqli_query ($cxn,$query)
		or die (mysqli_error($cxn));
		
$nrows = mysqli_num_rows ($result);

//loop through data...
for($i=0;$i&lt;$nrows;$i++) {

	$row = mysqli_fetch_assoc ($result);
	extract ($row);
	
	//divide rgb values by 255 and echo...
	echo '[list setColor:[NSColor colorWithRed:'.round(($red/255),3).' green:'.round(($green/255),3).' blue:'.round(($blue/255),3).' alpha:1.0] forKey:@"Pantone '.$name.'"];&lt;br /&gt;';	
}
</code></pre>
</div>
</div>
<p>Which when executed produced the following result:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-objectivec">
[list setColor:[NSColor colorWithRed:0.996 green:0.867 blue:0 alpha:1.0] forKey:@"Pantone Yellow C"];
[list setColor:[NSColor colorWithRed:1 green:0.843 blue:0 alpha:1.0] forKey:@"Pantone Yellow 012 C"];
[list setColor:[NSColor colorWithRed:0.996 green:0.314 blue:0 alpha:1.0] forKey:@"Pantone Orange 021 C"];
// etc…
// etc…
// etc…
</code></pre>
</div>
</div>
<h2>Stage 4 &#8211; using Xcode to generate the .clr file</h2>
<p>To generate the final <span class="turquoise">.clr</span> file I opened Xcode and created a new project of type <span class="turquoise">Cococa Application</span>. Once this was ready I opened the <span class="turquoise">AppDelegate.m</span> file and where the comment <span class="orange">&#8216;// Insert code here to initialize your application&#8217;</span> appeared in the <span class="orange">&#8211; (void)applicationDidFinishLaunching:(NSNotification *)aNotification</span> method I replaced it with the following:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-objectivec">
NSColorList *list = [NSColorList.alloc initWithName:@"Pantone Coated"];

/* COPY AND PASTE THE GENERATED LIST OF COLORS HERE */

[list writeToFile: [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Colors/"]];
</code></pre>
</div>
</div>
<p>Once that was done I did a build and run and as soon as the application had launched I checked out the contents of my <span class="orange">~/Library/Colors/</span> folder to see a new <strong class="orange">Pantone Coated.clr</strong> file. The next thing to do was open an app (<span class="turquoise">Sketch.app</span>) and then open the color picker to check out the new color palette!</p>
<figure id="attachment_1180" aria-describedby="figcaption_attachment_1180" class="wp-caption alignnone" itemscope itemtype="http://schema.org/ImageObject"><img loading="lazy" decoding="async" itemprop="contentURL" class="size-full wp-image-1180" src="https://www.midwinter-dg.com/wp-content/uploads/2014/08/pantone-in-sketch.jpg" alt="Pantone In Sketch" width="630" height="410" srcset="https://www.midwinter-dg.com/wp-content/uploads/2014/08/pantone-in-sketch.jpg 630w, https://www.midwinter-dg.com/wp-content/uploads/2014/08/pantone-in-sketch-300x195.jpg 300w" sizes="auto, (max-width: 630px) 100vw, 630px" /><figcaption id="figcaption_attachment_1180" class="wp-caption-text" itemprop="description">Using Pantone swatches in Sketch</figcaption></figure>
<h2>Conclusion</h2>
<p>In hindsight the way I went about this was perhaps more lengthy that it could have been. There&#8217;s no reason why I couldn&#8217;t scrape the page and generate the <span class="turquoise">objective-c</span> code all in one step missing out the database. But as I was not sure how to proceed it seemed better to store the data then work out what to do next. Anyway here&#8217;s a short example that does just that:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-php">
//include simple html dom...
require('simple_html_dom.php');

//get page source...
$html = file_get_html('http://en.labelpartners.com/pantone_coated_table.html');

$count = 0;

echo 'NSColorList *list = [NSColorList.alloc initWithName:@"Pantone Coated"];';

//loop through each &lt;tr&gt;...
foreach($html-&gt;find('tr') as $row) {

	//extract values from each &lt;td&gt;...    
	$name 	= $row-&gt;find('td', 0)-&gt;innertext;		
	$hex 	= $row-&gt;find('td', 1)-&gt;innertext;
	$red 	= $row-&gt;find('td', 2)-&gt;innertext;
	$green 	= $row-&gt;find('td', 3)-&gt;innertext;
	$blue 	= $row-&gt;find('td', 4)-&gt;innertext;
	
	//ignore &lt;table&gt; 'header' row...
	if($count &gt; 0) {
	
		//divide rgb values by 255 and echo objective-c code...
		echo '[list setColor:[NSColor colorWithRed:'.round(($red/255),3).' green:'.round(($green/255),3).' blue:'.round(($blue/255),3).' alpha:1.0] forKey:@"Pantone '.$name.'"];&lt;br /&gt;';
			
	}
	
	$count++;
}

echo '[list writeToFile: [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Colors/"]];';
</code></pre>
</div>
</div>
<p>There are many sites online with lists of <strong>Pantone</strong> colors. I also creates a <em>Pantone Pastels</em>, <em>Pantone Metallics</em> and a set of <abbr title="cyan, magenta, yellow, black">CMYK</abbr> swatches using the CMYK values and creating the <span class="turquoise">NSColors</span> like this:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-objectivec">
[NSColor colorWithDeviceCyan: C_VALUE magenta: M_VALUE yellow: Y_VALUE black: K_VALUE alpha:1.0]
</code></pre>
</div>
</div>
<h2>resources</h2>
<dl>
<dt>Color Lists</dt>
<dd><a href="http://en.labelpartners.com/pantone_coated_table.html" rel="nofollow">http://en.labelpartners.com/pantone_coated_table.html</a></dd>
<dd><a href="http://euro-bags.eu/pantone?limit=all" rel="nofollow">http://euro-bags.eu/pantone?limit=all</a></dd>
<dd><a href="http://www.ediy.co.nz/pantone-to-rgb" rel="nofollow">http://www.ediy.co.nz/pantone-to-rgb</a></dd>
<dd><a href="http://www.umsiko.co.za/links/color.html" rel="nofollow">http://www.umsiko.co.za/links/color.html</a></dd>
<dd><a href="http://color2u.cocolog-nifty.com/color4u/archives.html">http://color2u.cocolog-nifty.com/color4u/archives.html</a></dd>
<dt>PHP Simple HTML DOM Parser</dt>
<dd><a href="http://simplehtmldom.sourceforge.net" rel="nofollow">http://simplehtmldom.sourceforge.net</a></dd>
</dl>
<p>&nbsp;</p>
<p>You can download an archive of compiled .clr containing a set of Pantone Coated, Metallic, Pastel and CMYK swatches on my resources page:<br />
<a href="https://www.midwinter-dg.com/resources.html#osx-color-palette">Pantone Swatches for the OSX Color Picker</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>A useful little hack for anyone who still uses CSSEdit</title>
		<link>https://www.midwinter-dg.com/permalink-a-useful-little-hack-for-anyone-who-still-uses-cssedit_2014-04-29.html</link>
		
		<dc:creator><![CDATA[duncanmid]]></dc:creator>
		<pubDate>Tue, 29 Apr 2014 19:26:07 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[cssedit]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[web development]]></category>
		<guid isPermaLink="false">http://www.midwinter-dg.com/?p=385</guid>

					<description><![CDATA[CSSEdit has long since been discontinued, but if like me you still prefer it to anything else for coding 'vanilla' CSS you may like this little hack for enabling the Safari Web Inspector in the app]]></description>
										<content:encoded><![CDATA[<p>Yes I know, <b>CSSEdit</b> has long since been discontinued. But if like me you still prefer it to anything else for coding <i>&#8216;vanilla&#8217;</i> CSS you may like this little hack for enabling the <b>Safari Web Inspector</b> in the app.</p>
<p>Open Terminal.app <span class="orange">/Applications/Utilities/Terminal.app</span>, and copy and paste the following…</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-bash">
defaults write com.macrabbit.CSSEdit WebKitDeveloperExtras TRUE
</code></pre>
</div>
</div>
<p>…then press return.</p>
<p>You should now be able to right click in the preview window and select <span class="turquoise">&#8216;Inspect Element&#8217;</span> from the contextual menu to open the Web Inspector.</p>
<figure id="attachment_1182" aria-describedby="figcaption_attachment_1182" class="wp-caption alignnone" itemscope itemtype="http://schema.org/ImageObject"><img loading="lazy" decoding="async" itemprop="contentURL" class="size-full wp-image-1182" src="https://www.midwinter-dg.com/wp-content/uploads/2014/04/cssedit-inspector.png" alt="Cssedit with web inspector" width="442" height="344" srcset="https://www.midwinter-dg.com/wp-content/uploads/2014/04/cssedit-inspector.png 442w, https://www.midwinter-dg.com/wp-content/uploads/2014/04/cssedit-inspector-300x233.png 300w" sizes="auto, (max-width: 442px) 100vw, 442px" /><figcaption id="figcaption_attachment_1182" class="wp-caption-text" itemprop="description">opening the web inspector in cssedit</figcaption></figure>
<p>Don&#8217;t like it?</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-bash">
defaults write com.macrabbit.CSSEdit WebKitDeveloperExtras FALSE
</code></pre>
</div>
</div>
<p>To put it back to how it was before.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Embedded Tweets kit &#8211; a design resource for Sketch.app</title>
		<link>https://www.midwinter-dg.com/permalink-embedded-tweets-kit-a-design-resource-for-sketch-app_2014-03-26.html</link>
		
		<dc:creator><![CDATA[duncanmid]]></dc:creator>
		<pubDate>Wed, 26 Mar 2014 15:15:16 +0000</pubDate>
				<category><![CDATA[downloads]]></category>
		<category><![CDATA[sketch]]></category>
		<category><![CDATA[vector graphics]]></category>
		<category><![CDATA[web design]]></category>
		<guid isPermaLink="false">http://www.midwinter-dg.com/?p=383</guid>

					<description><![CDATA[Here's a free resource for all those web designers that are using Sketch. It's a kit for embedded Tweets with samples: standard text only Tweet and Tweet with an image.]]></description>
										<content:encoded><![CDATA[<p>Here&#8217;s another free resource for all those web designers that are using <strong>Sketch</strong> (and frankly I can&#8217;t imagine going back to Photoshop!). It&#8217;s a kit for embedded Tweets with samples: a standard text only Tweet and a Tweet with an image.</p>
<div class="gallery-left">

<a href='https://www.midwinter-dg.com/wp-content/uploads/2014/03/embedded_tweets.jpg'><img loading="lazy" decoding="async" width="150" height="150" src="https://www.midwinter-dg.com/wp-content/uploads/2014/03/embedded_tweets-150x150.jpg" class="attachment-thumbnail size-thumbnail" alt="" /></a>

</div>
<p>So if you&#8217;re working on a design for a site that will use embedded Tweets, just drag the appropriate Tweet in to your design and edit it to suit.</p>
<p>You can download the <strong>Embedded Tweets kit for Sketch</strong> from my <a href="https://www.midwinter-dg.com/resources.html#sketch-file">Resources page</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>xCode5 Cocoa bindings tutorial</title>
		<link>https://www.midwinter-dg.com/permalink-xcode5_cocoa_bindings_tutorial_2014-03-24.html</link>
		
		<dc:creator><![CDATA[duncanmid]]></dc:creator>
		<pubDate>Mon, 24 Mar 2014 16:02:10 +0000</pubDate>
				<category><![CDATA[bindings]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[xcode]]></category>
		<guid isPermaLink="false">http://www.midwinter-dg.com/?p=381</guid>

					<description><![CDATA[Cocoa Bindings makes keeping your view objects and data objects in sync with minimum fuss and minimum code. This tutorial introduces the concept by demonstrating how to sync a slider with a text field]]></description>
										<content:encoded><![CDATA[<p>Cocoa Bindings makes keeping your view objects and data objects in sync with minimum fuss and minimum code. This tutorial introduces the concept by demonstrating how to sync a slider with a text field that displays its value. Changing the slider will result in the text field being updated and vice versa.</p>
<p><span class="num">1</span> Open <span class="turquoise">xCode</span> and create a new project. Select <span class="turquoise">OSX</span> and <span class="turquoise">Application</span> from the left column, then choose <span class="turquoise">Cocoa Application</span> and type ‘Cocoa Bindings Demo’ for the Product Name. Once you choose a location on your Mac to create the project you will be presented with a standard blank application containing an <span class="turquoise">AppDelegate</span> class and a <span class="turquoise">MainMenu.xib</span> file.</p>
<figure id="attachment_1184" aria-describedby="figcaption_attachment_1184" class="wp-caption alignnone" itemscope itemtype="http://schema.org/ImageObject"><img loading="lazy" decoding="async" itemprop="contentURL" class="size-full wp-image-1184" src="https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-new-project.jpg" alt="creating a new project in xCode" width="320" height="240" srcset="https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-new-project.jpg 320w, https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-new-project-300x225.jpg 300w" sizes="auto, (max-width: 320px) 100vw, 320px" /><figcaption id="figcaption_attachment_1184" class="wp-caption-text" itemprop="description">creating a new project in xCode</figcaption></figure>
<p><span class="num">2</span> You&#8217;re going to be adding a slider and text field to the main application window, and then connecting their values using cocoa bindings but first you will need a variable to store this value, so you must create a controller class to store this value.</p>
<p>Select <span class="orange">File -&gt; New -&gt; File…</span> (or press <span class="turquoise">cmd N</span>), then select <span class="turquoise">OSX</span> and <span class="turquoise">Cocoa</span> from the left column and then choose <span class="turquoise">Objective-C class</span> and click <span class="turquoise">Next</span>.</p>
<figure id="attachment_1185" aria-describedby="figcaption_attachment_1185" class="wp-caption alignnone" itemscope itemtype="http://schema.org/ImageObject"><img loading="lazy" decoding="async" itemprop="contentURL" class="size-full wp-image-1185" src="https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-new-class.jpg" alt="adding a new class in xCode" width="320" height="240" srcset="https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-new-class.jpg 320w, https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-new-class-300x225.jpg 300w" sizes="auto, (max-width: 320px) 100vw, 320px" /><figcaption id="figcaption_attachment_1185" class="wp-caption-text" itemprop="description">adding a new class in xCode</figcaption></figure>
<p>Call the new class ‘AppController’ with a Subclass of <span class="turquoise">NSObject</span>, click <span class="turquoise">Next</span> and create the object.</p>
<p><span class="num">3</span> Now you need to add the <span class="turquoise">AppController</span> class to the workbench in <span class="turquoise">InterfaceBuilder</span>, so click on the <span class="orange">MainMenu.xib</span> to open it and from the <span class="turquoise">Object Library</span> in the <span class="turquoise">Utilities sidebar</span> select <span class="orange">Object</span> and drag an instance to the workbench.</p>
<div class="gallery-left">

<a href='https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-new-object.jpg'><img loading="lazy" decoding="async" width="150" height="150" src="https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-new-object-150x150.jpg" class="attachment-thumbnail size-thumbnail" alt="" /></a>

</div>
<p>Select the object in the workbench and click on the <span class="turquoise">Identity Inspector</span> in the <span class="turquoise">Utilities sidebar</span>. In the top section (<span class="turquoise">Custom Class</span>), click in the <span class="turquoise">Class</span> text field and type ‘AppController’ (you should find that it auto completes).</p>
<figure id="attachment_1186" aria-describedby="figcaption_attachment_1186" class="wp-caption alignnone" itemscope itemtype="http://schema.org/ImageObject"><img loading="lazy" decoding="async" itemprop="contentURL" class="size-full wp-image-1186" src="https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-custom-class.jpg" alt="linking the object to the AppController in xCode" width="320" height="190" srcset="https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-custom-class.jpg 320w, https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-custom-class-300x178.jpg 300w" sizes="auto, (max-width: 320px) 100vw, 320px" /><figcaption id="figcaption_attachment_1186" class="wp-caption-text" itemprop="description">linking the object to the AppController in xCode</figcaption></figure>
<p><span class="num">4</span> Now you can create the variable to hold the slider / text field value. Open the <span class="orange">AppController.h</span> and add an <span class="orange">int</span>. Call it <span class="orange">sliderAmount</span>. Your code should look like this:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-objectivec">
#import &lt;Foundation/Foundation.h&gt;

@interface AppController : NSObject {
@private

	int sliderAmount;
	
}

@property int sliderAmount;

@end
</code></pre>
</div>
</div>
<p>You will also need to add a <span class="turquoise">property</span>, so that the int can be used with <abbr title="key value coding">KVC</abbr> and <abbr title="key value observing">KVO</abbr>, which is necessary for Cocoa Bindings to work.</p>
<p>Once that is done open the <span class="orange">AppController.m</span> and <span class="turquoise">synthesize</span> the <span class="orange">sliderAmount</span>. Your <span class="orange">AppController.m</span> file should look like this:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-objectivec">
#import "AppController.h"

@implementation AppController

@synthesize sliderAmount;

@end
</code></pre>
</div>
</div>
<p><span class="num">5</span> So now that you&#8217;ve got the <span class="turquoise">Controller Class</span> with an <span class="orange">int</span> to hold the value, it&#8217;s time to create the interface. Go back to the <span class="orange">MainMenu.xib</span> file and click on the <span class="turquoise">Window object</span> in the workbench to open the main application window. Once it is open, go to the <span class="turquoise">Object Library</span> and drag in a span class=&#8221;turquoise&#8221;&gt;Horizontal Slider and a span class=&#8221;turquoise&#8221;&gt;Text Field.</p>
<p class="smaller">Note: In the example I&#8217;ve spent a bit of time sizing and positioning the objects, I&#8217;ve also given the slider tick marks, but I&#8217;ve left its default values of <span class="orange">Minimum 0</span>, <span class="orange">Maximum 100</span> and <span class="orange">Current 50</span>.</p>
<figure id="attachment_1187" aria-describedby="figcaption_attachment_1187" class="wp-caption alignnone" itemscope itemtype="http://schema.org/ImageObject"><img loading="lazy" decoding="async" itemprop="contentURL" class="size-full wp-image-1187" src="https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-window.jpg" alt="designing the Application Window in Interface Builder" width="318" height="150" srcset="https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-window.jpg 318w, https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-window-300x142.jpg 300w" sizes="auto, (max-width: 318px) 100vw, 318px" /><figcaption id="figcaption_attachment_1187" class="wp-caption-text" itemprop="description">designing the Application Window in Interface Builder</figcaption></figure>
<p><span class="num">6</span> So now it&#8217;s time for you to bind the interface elements to the <span class="orange">int</span> value in the <span class="turquoise">Controller Class</span>.</p>
<p>Click on the slider to select it, then in the <span class="turquoise">Utilities sidebar</span>, click on the <span class="turquoise">Bindings Inspector</span>. You will see a list of all the various values that you can bind. In our case we want to bind the value of the slider, so click the disclosure triangle next to <span class="turquoise">&#8216;Value&#8217;</span> and click on the checkbox <span class="turquoise">Bind</span>, then from the drop-down menu, select <span class="turquoise">App Controller</span>. Finally, under the field for <span class="turquoise">Model Key Path</span> you should see that it has the value <span class="orange">self</span>. Remove this and add the name of the <span class="orange">int</span> in the <span class="turquoise">AppController</span> class: <span class="orange">sliderAmount</span> (it should auto complete). The slider is now bound to the <span class="orange">int</span> value in the <span class="turquoise">AppController</span> class &#8211; you should see the correct key path next to <span class="turquoise">Value</span> in the <span class="turquoise">Bindings inspector</span> &#8211; (<span class="orange">App Controller.sliderAmount</span>).</p>
<p><span class="num">7</span> So now our slider is correctly bound to the <span class="orange">int</span> value but on its own not much is going to happen! Now it&#8217;s time to bind the text field to the same <span class="orange">int</span> value. To do that we just repeat the exact same procedure that we used to bind the slider.</p>
<p><span class="num">8</span> Now that both interface elements are bound to the same <span class="orange">int</span> value it&#8217;s time to build an run the app. You should see that when the slider is moved, the text field updates to the new value. It&#8217;s fine, but there&#8217;s something not quite right &#8211; two things actually…</p>
<p>Firstly, the value in the text field only updates when the slider is released and secondly, wasn&#8217;t the default value of our slider set to <span class="orange">50</span>?</p>
<p>To get the slider / text filed to update in realtime as the slider is moved, select the slider then in the <span class="turquoise">Utilities sidebar</span> click on the <span class="turquoise">Attributes inspector</span>. Under the <span class="turquoise">&#8216;control&#8217;</span> section check the checkbox <span class="turquoise">&#8216;Continuous&#8217;</span>. A quick build and run should show the value updating as the slider is moved.</p>
<figure id="attachment_1190" aria-describedby="figcaption_attachment_1190" class="wp-caption alignnone" itemscope itemtype="http://schema.org/ImageObject"><img loading="lazy" decoding="async" itemprop="contentURL" class="size-full wp-image-1190" src="https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-continuous.jpg" alt="making the slider continuous in xCode" width="320" height="220" srcset="https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-continuous.jpg 320w, https://www.midwinter-dg.com/wp-content/uploads/2014/03/bindings-continuous-300x206.jpg 300w" sizes="auto, (max-width: 320px) 100vw, 320px" /><figcaption id="figcaption_attachment_1190" class="wp-caption-text" itemprop="description">making the slider continuous in xCode</figcaption></figure>
<p>As for the initial value of the slider: normally it would be initialised with the value in the current field of the <span class="turquoise">Attributes inspector</span>, but as the slider is now bound to the <span class="orange">int</span> value of <span class="orange">sliderAmount</span> it is initialised with that value. To get it to start at <span class="orange">50</span> (or any other amount for that matter), you need to add an <span class="orange">-init</span> method to your <span class="turquoise">AppController</span> class. So open your <span class="orange">AppController.m</span> file and edit the code as follows:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-objectivec">
#import "AppController.h"

@implementation AppController

@synthesize sliderAmount;

- (id)init
{
	self = [super init];
	
	if(self) {
		
		sliderAmount = 50;
		
	}
	
	return self;
}

@end
</code></pre>
</div>
</div>
<p>A final build and run should see your slider and text field starting with an initial value of <span class="orange">50</span>.</p>
<p>You can find a sample xCode project of this tutorial on <a href="https://www.midwinter-dg.com/resources.html#code-sample">my Resources page.</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Google Maps kit for Sketch.app</title>
		<link>https://www.midwinter-dg.com/permalink-google-maps-kit-for-sketch-app_2014-01-20.html</link>
		
		<dc:creator><![CDATA[duncanmid]]></dc:creator>
		<pubDate>Mon, 20 Jan 2014 14:07:07 +0000</pubDate>
				<category><![CDATA[image vectorizer]]></category>
		<category><![CDATA[sketch]]></category>
		<category><![CDATA[vector graphics]]></category>
		<category><![CDATA[web design]]></category>
		<guid isPermaLink="false">http://www.midwinter-dg.com/?p=379</guid>

					<description><![CDATA[A Google Maps resource for Sketch. For those moments when you need to create a mock-up design including a Google Map!]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="size-full wp-image-1192 alignright" src="https://www.midwinter-dg.com/wp-content/uploads/2014/01/google-maps-for-sketch.png" alt="Google Maps For Sketch" width="256" height="256" srcset="https://www.midwinter-dg.com/wp-content/uploads/2014/01/google-maps-for-sketch.png 256w, https://www.midwinter-dg.com/wp-content/uploads/2014/01/google-maps-for-sketch-150x150.png 150w" sizes="auto, (max-width: 256px) 100vw, 256px" /></p>
<p>Almost all my front-end design and interface design work is done using <a href="http://www.sketchapp.com" rel="nofollow">Sketch</a> these days. I&#8217;m also a massive fan of Google Maps and the <a href="https://developers.google.com/maps/" rel="nofollow">Google Maps API</a>. To that end I have created this small kit for those moments when you need to create a mock-up design including a Google Map!</p>
<p>Download <a href="https://www.midwinter-dg.com/resources.html#sketch-file">Google Maps for Sketch</a></p>
<p>Whilst I was creating the Google Maps for Sketch kit I made use of my latest app Image Vectorizer, to create the graphics.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Animated image captions using the css backface-visibility property</title>
		<link>https://www.midwinter-dg.com/permalink-animated-image-captions-using-backface-visibility_2013-03-09.html</link>
		
		<dc:creator><![CDATA[duncanmid]]></dc:creator>
		<pubDate>Sat, 09 Mar 2013 14:07:51 +0000</pubDate>
				<category><![CDATA[CSS3]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[semantic web]]></category>
		<category><![CDATA[web design]]></category>
		<guid isPermaLink="false">http://www.midwinter-dg.com/?p=377</guid>

					<description><![CDATA[Pure html5 / css3 animated image captions using the backface-visibility property to reveal image captions]]></description>
										<content:encoded><![CDATA[<p>It&#8217;s been a while since I published my <a href="https://www.midwinter-dg.com/permalink-six-fantastic-css3-animated-image-captions_2011-11-21.html">Pure html5 / css3 animated image captions</a> and I thought I&#8217;d revisit the subject. The following demo is a slightly different take on the last &#8211; instead of hiding the captions and revealing them on mouseover this time I&#8217;m hiding the images and showing the captions first. The resulting animated images/captions are then animated using css3 2d and 3d transforms. Normally if you flip and element using transforms, it appears as a mirror-image, however if you use the <span class="turquoise">backface-visibility</span> property (set to hidden), the resulting element is then hidden. This is the key to the following animations.</p>
<p><a href="https://www.midwinter-dg.com/blog_demos/animated-image-captions-v2/"><img decoding="async" class="shadow" src="https://www.midwinter-dg.com/wp-content/uploads/2013/03/image-captions-with-backface-visibility.png" alt="Animated image captions using the css backface-visibility property" /></a></p>
<h2>the set-up</h2>
<p><span class="num">1</span> The html used is as before, a <span class="orange">&lt;figure&gt;</span> element containing an <span class="orange">&lt;img&gt;</span> and a <span class="orange">&lt;figcaption&gt;</span>, the only difference being this time I&#8217;m allowing myself to use a containing <span class="orange">&lt;div&gt;</span> that specifies the type of animation (horizontal, diagonal, vertical…).</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-markup">
&lt;div class="vertical"&gt;
	&lt;figure&gt;
		&lt;img src="images/joni-mitchell.png" alt="Joni Mitchell" width="200" height="200" /&gt;
		&lt;figcaption class="orange"&gt;Joni Mitchell&lt;/figcaption&gt;
	&lt;/figure&gt;
&lt;/div&gt;
</code></pre>
</div>
</div>
<p><span class="num">2</span> The containing <span class="orange">&lt;div&gt;</span> has a position of relative, and from there on the <span class="orange">&lt;figure&gt;</span>, <span class="orange">&lt;img&gt;</span> and <span class="orange">&lt;figcaption&gt;</span> elements are all set to position absolute so they are all positioned on top of each other.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1203" src="https://www.midwinter-dg.com/wp-content/uploads/2013/03/backface-visibility-1.png" alt="elements positioned in div" width="170" height="170" srcset="https://www.midwinter-dg.com/wp-content/uploads/2013/03/backface-visibility-1.png 170w, https://www.midwinter-dg.com/wp-content/uploads/2013/03/backface-visibility-1-150x150.png 150w" sizes="auto, (max-width: 170px) 100vw, 170px" /></p>
<p><span class="num">3</span> Now, the <span class="orange">&lt;img&gt;</span> tab is flipped over using a transform. Because it has a <span class="turquoise">backface-visibility</span> of hidden it is now invisible.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1204" src="https://www.midwinter-dg.com/wp-content/uploads/2013/03/backface-visibility-2.png" alt="the image is hidden" width="170" height="170" srcset="https://www.midwinter-dg.com/wp-content/uploads/2013/03/backface-visibility-2.png 170w, https://www.midwinter-dg.com/wp-content/uploads/2013/03/backface-visibility-2-150x150.png 150w" sizes="auto, (max-width: 170px) 100vw, 170px" /></p>
<p><span class="num">4</span> The final effect is achieved on mouseover. On mouseover, the <span class="orange">&lt;figure&gt;</span> element is flipped using a transform that is animated using a css3 transition.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1205" src="https://www.midwinter-dg.com/wp-content/uploads/2013/03/backface-visibility-3.png" alt="the figure element is flipped" width="150" height="215" /></p>
<p><span class="num">5</span> Once it if flipped, the <span class="orange">&lt;img&gt;</span> which is now flipped back becomes visible whilst the <span class="orange">&lt;figcaption&gt;</span> which is flipped over becomes hidden.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1206" src="https://www.midwinter-dg.com/wp-content/uploads/2013/03/backface-visibility-4.png" alt="the image is visible and the figcaption is hidden" width="170" height="170" srcset="https://www.midwinter-dg.com/wp-content/uploads/2013/03/backface-visibility-4.png 170w, https://www.midwinter-dg.com/wp-content/uploads/2013/03/backface-visibility-4-150x150.png 150w" sizes="auto, (max-width: 170px) 100vw, 170px" /></p>
<p>And here&#8217;s the full demo of my <a href="https://www.midwinter-dg.com/blog_demos/animated-image-captions-v2/">Animated image captions using the css backface-visibility property</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to apply one picture to all desktops on OSX 10.8 using Automator</title>
		<link>https://www.midwinter-dg.com/permalink-how-to-apply-one-picture-to-all-desktops-on-osx-10-8-using-automator_2013-01-26.html</link>
		
		<dc:creator><![CDATA[duncanmid]]></dc:creator>
		<pubDate>Sat, 26 Jan 2013 10:54:36 +0000</pubDate>
				<category><![CDATA[automator]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[software]]></category>
		<guid isPermaLink="false">http://www.midwinter-dg.com/?p=375</guid>

					<description><![CDATA[How to create an Automator Workflow change all OSX 10.8 desktop pictures in one go]]></description>
										<content:encoded><![CDATA[<p>So you have several desktops set up in <span class="turquoise">Mission Control</span> and you have assigned various apps to each desktop. Now when you want to change your desktop picture you open up <span class="turquoise">System preferences</span>, navigate to the <span class="turquoise">Desktop &amp; Screensaver</span> panel and apply a new picture. At this point <b>OSX 10.8</b><span class="orange">*</span> changes only the picture on the currently active desktop so, if you want to change all desktops to the same picture you have to swap to each desktop and change it manually. Fine if you only have 2 or 3, but if you have many desktops how can you change them all at the same time?</p>
<p class="smaller"><span class="orange">*</span>this probably applies to OSX 10.7 as well &#8211; I don&#8217;t know, as I jumped straight from OSX 10.6 to OSX 10.8.</p>
<p><img loading="lazy" decoding="async" class="img-right" src="https://www.midwinter-dg.com/wp-content/uploads/2013/01/automator-icon-mountain-lion.png" alt="Automator icon from Mountain Lion" width="128" height="128" /></p>
<p>This is where <span class="turquoise">Automator</span> comes in. Automator allows you to script many tedious tasks on you mac (see my previous posts on <a href="https://www.midwinter-dg.com/category/automator">using Automator</a>), in this case we will be selecting a new picture and then rewriting the desktop preferences file to use only that selected picture. The finished Automator script will be a <span class="turquoise">”Service“</span>. It will be available in the <span class="turquoise">Finder</span> under <i>Finder -&gt; Services -&gt; Change All Desktop Picutres…</i></p>
<h3><span class="num">1</span> Open Automator</h3>
<p><span class="turquoise">Automator</span> is in the <span class="turquoise">Applications</span> folder. Open it and select <span class="turquoise">“Service”</span> as the document type.</p>
<h3><span class="num">2</span> Start building your script</h3>
<p>At the top of the workflow pane (the right-hand column where it says <span class="turquoise">“Drag actions or files here to build your workflow.”</span>) you will see <span class="turquoise">“Service receives selected text in any application”</span> where <span class="orange">‘text’</span> and <span class="orange">‘any application’</span> are select boxes. Change the select boxes to read <span class="turquoise">“Service receives no input in Finder”</span>.</p>
<h3><span class="num">3</span> Adding the first action “Ask for Finder Items”</h3>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1210" src="https://www.midwinter-dg.com/wp-content/uploads/2013/01/automator-library.png" alt="The Automator Library" width="333" height="140" srcset="https://www.midwinter-dg.com/wp-content/uploads/2013/01/automator-library.png 333w, https://www.midwinter-dg.com/wp-content/uploads/2013/01/automator-library-300x126.png 300w" sizes="auto, (max-width: 333px) 100vw, 333px" /></p>
<p>From the <span class="turquoise">Library</span> column on the left of the Automator window select <span class="turquoise">“Files &amp; Folders”</span> then from the second column double-click on <span class="turquoise">“Ask for Finder Items”</span> (or drag it in to the workflow).</p>
<h3><span class="num">4</span> Configuring the “Ask for finder Items” action.</h3>
<p>First, change the <span class="turquoise">“prompt”</span> message to <span class="turquoise">“Choose a desktop picture:”</span>, then Select <span class="turquoise">“Start at:”</span> and navigate to where you keep your desktop pictures (I keep all mine in the default: /Library/Desktop Pictures/ folder). Finally make sure that <span class="turquoise">“Allow Multiple Selection”</span> is unchecked.</p>
<h3><span class="num">5</span> Adding the “Run Shell Script” action</h3>
<p>Select <span class="turquoise">“Utilities”</span> from the library and then double-click or drag the <span class="turquoise">“Run Shell Script”</span> action to add it to your workflow.</p>
<h3><span class="num">6</span> Configuring the “Run Shell Script” action</h3>
<p>Once you&#8217;ve added the action, make sure that the first two select boxes are set to:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-bash">
Shell: /bin/bash
Pass input: to stdin
</code></pre>
</div>
</div>
<p>Now in the text area (Where it says <span class="orange">cat</span>), delete <span class="orange">cat</span> and replace it with the following shell script:</p>
<div class="clearfix">
<div class="pre-wrap">
<pre><code class="language-bash">
read -e PICTURE;
 
function set_all_desktops
{
defaults write com.apple.desktop Background "{default = {ImageFilePath='$PICTURE'; };}";
killall Dock
}

set_all_desktops
</code></pre>
</div>
</div>

<a href='https://www.midwinter-dg.com/wp-content/uploads/2013/01/desktops-workflow.png'><img loading="lazy" decoding="async" width="150" height="150" src="https://www.midwinter-dg.com/wp-content/uploads/2013/01/desktops-workflow-150x150.png" class="attachment-thumbnail size-thumbnail" alt="" /></a>

<h3><span class="num">7</span> Saving and running the new Service</h3>

<a href='https://www.midwinter-dg.com/wp-content/uploads/2013/01/choose-a-desktop-picture.png'><img loading="lazy" decoding="async" width="150" height="150" src="https://www.midwinter-dg.com/wp-content/uploads/2013/01/choose-a-desktop-picture-150x150.png" class="attachment-thumbnail size-thumbnail" alt="" /></a>

<p>Choose File -&gt; Save and call it <span class="turquoise">“Change All Desktop Pictures…”</span> and you&#8217;re done. Now to run your new service switch to the Finder and choose Finder -&gt; Services -&gt; <span class="turquoise">“Change All Desktop Pictures…”</span>. In the dialog that opens simply select the new picture and click on <span class="turquoise">“Choose”</span> and all your desktops will be updated.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1211" src="https://www.midwinter-dg.com/wp-content/uploads/2013/01/finder-services.png" alt="The Finder services menu" width="499" height="256" srcset="https://www.midwinter-dg.com/wp-content/uploads/2013/01/finder-services.png 499w, https://www.midwinter-dg.com/wp-content/uploads/2013/01/finder-services-300x154.png 300w" sizes="auto, (max-width: 499px) 100vw, 499px" /></p>
<p>In this example we have built the script as a <i>Finder Service</i>, however you could also build it as an <i>Application</i> which could then be put in the dock. In fact I already have and you can download it from the <a href="https://www.midwinter-dg.com/software#automator-workflows">Automator Workflows</a> section of my <a href="https://www.midwinter-dg.com/software">Software page</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced (Page is feed) 

Served from: www.midwinter-dg.com @ 2026-04-13 14:41:07 by W3 Total Cache
-->