{"id":31927,"date":"2017-08-04T03:01:29","date_gmt":"2017-08-03T17:01:29","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=31927"},"modified":"2017-08-04T07:05:19","modified_gmt":"2017-08-03T21:05:19","slug":"css3-filters-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/css3-filters-primer-tutorial\/","title":{"rendered":"CSS3 Filters Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_filters.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"CSS3 Filters Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_filters.jpg\" title=\"CSS3 Filters Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">CSS3 Filters Primer Tutorial<\/p><\/div>\n<p>It&#8217;s not just the image editor <a target=_blank title='Gimp image editor' href='http:\/\/www.gimp.org\/'>Gimp<\/a> that has &#8220;filters&#8221; as tools to create effects with image data (files), as you might see with tutorials like <a title='Gimp Decor Filters Revisit Tutorial' href='#gdfrt'>Gimp Decor Filters Revisit Tutorial<\/a>.  These days, with CSS, and with <a target=_blank title='CSS3 information from w3schools' href='http:\/\/www.w3schools.com\/css\/css3_intro.asp'>CSS3<\/a> these days, there are some great &#8220;filters&#8221; to play around with, that modify an image there and then with CSS and\/or Javascript DOM (as per the HTML select &#8220;dropdown&#8221; element <i>onchange<\/i> event logic &#8230;<\/p>\n<p><code><br \/>\nfunction selchange(selo) {<br \/>\n  var bs=\"\";<br \/>\n  if (selo == null) {<br \/>\n  if (document.getElementById(\"sh-shadow\").value != \"\" && document.getElementById(\"sv-shadow\").value != \"\") {<br \/>\n  if (document.getElementById(\"xblur\").value != \"\") bs+=document.getElementById(\"xblur\").value + document.getElementById(\"xblur\").title + \" \";<br \/>\n  if (document.getElementById(\"sspread\").value != \"\") bs+=document.getElementById(\"sspread\").value + document.getElementById(\"sspread\").title + \" \";<br \/>\n  \/\/alert(\"drop-shadow(\" + document.getElementById(\"sh-shadow\").value + document.getElementById(\"sh-shadow\").title + \" \" + document.getElementById(\"sv-shadow\").value + document.getElementById(\"sv-shadow\").title + \" \" + bs + document.getElementById(\"mycolour\").value + \")\");<br \/>\n  document.getElementById(\"myimage\").style.filter = \"drop-shadow(\" + document.getElementById(\"sh-shadow\").value + document.getElementById(\"sh-shadow\").title + \" \" + document.getElementById(\"sv-shadow\").value + document.getElementById(\"sv-shadow\").title + \" \" + bs + document.getElementById(\"mycolour\").value + \")\";<br \/>\n  document.getElementById(\"myimage\").style.WebkitFilter = \"drop-shadow(\" + document.getElementById(\"sh-shadow\").value + document.getElementById(\"sh-shadow\").title + \" \" + document.getElementById(\"sv-shadow\").value + document.getElementById(\"sv-shadow\").title + \" \" + bs + document.getElementById(\"mycolour\").value + \")\";<br \/>\n  }<br \/>\n  } else if (selo.id.substring(1) == 'h-shadow') {<br \/>\n  if (document.getElementById(\"sv-shadow\").value != \"\") {<br \/>\n  if (document.getElementById(\"xblur\").value != \"\") bs+=document.getElementById(\"xblur\").value + document.getElementById(\"xblur\").title + \" \";<br \/>\n  if (document.getElementById(\"sspread\").value != \"\") bs+=document.getElementById(\"sspread\").value + document.getElementById(\"sspread\").title + \" \";<br \/>\n  document.getElementById(\"myimage\").style.filter = \"drop-shadow(\" + selo.value + selo.title + \" \" + document.getElementById(\"sv-shadow\").value + document.getElementById(\"sv-shadow\").title + \" \" + bs + document.getElementById(\"mycolour\").value + \")\";<br \/>\n  document.getElementById(\"myimage\").style.WebkitFilter = \"drop-shadow(\" + selo.value + selo.title + \" \" + document.getElementById(\"sv-shadow\").value + document.getElementById(\"sv-shadow\").title + \" \" + bs + document.getElementById(\"mycolour\").value + \")\";<br \/>\n  }<br \/>\n  } else if (selo.id.substring(1) == 'v-shadow') {<br \/>\n  if (document.getElementById(\"sh-shadow\").value != \"\") {<br \/>\n  if (document.getElementById(\"xblur\").value != \"\") bs+=document.getElementById(\"xblur\").value + document.getElementById(\"xblur\").title + \" \";<br \/>\n  if (document.getElementById(\"sspread\").value != \"\") bs+=document.getElementById(\"sspread\").value + document.getElementById(\"sspread\").title + \" \";<br \/>\n  \/\/alert(\"drop-shadow(\" + document.getElementById(\"sh-shadow\").value + document.getElementById(\"sh-shadow\").title + \" \" + selo.value + selo.title + \" \" + bs + document.getElementById(\"mycolour\").value + \")\");<br \/>\n  document.getElementById(\"myimage\").style.filter = \"drop-shadow(\" + document.getElementById(\"sh-shadow\").value + document.getElementById(\"sh-shadow\").title + \" \" + selo.value + selo.title + \" \" + bs + document.getElementById(\"mycolour\").value + \")\";<br \/>\n  document.getElementById(\"myimage\").style.WebkitFilter = \"drop-shadow(\" + document.getElementById(\"sh-shadow\").value + document.getElementById(\"sh-shadow\").title + \" \" + selo.value + selo.title + \" \" + bs + document.getElementById(\"mycolour\").value + \")\";<br \/>\n  }<br \/>\n  } else if (selo.id == 'xblur') {<br \/>\n  if (document.getElementById(\"sh-shadow\").value != \"\" && document.getElementById(\"sv-shadow\").value != \"\") {<br \/>\n  if (document.getElementById(\"xblur\").value != \"\") bs+=document.getElementById(\"xblur\").value + document.getElementById(\"xblur\").title + \" \";<br \/>\n  if (document.getElementById(\"sspread\").value != \"\") bs+=document.getElementById(\"sspread\").value + document.getElementById(\"sspread\").title + \" \";<br \/>\n  document.getElementById(\"myimage\").style.filter = \"drop-shadow(\" + document.getElementById(\"sh-shadow\").value + document.getElementById(\"sh-shadow\").title + \" \" + document.getElementById(\"sv-shadow\").value + document.getElementById(\"sv-shadow\").title + \" \" + bs + document.getElementById(\"mycolour\").value + \")\";<br \/>\n  document.getElementById(\"myimage\").style.WebkitFilter = \"drop-shadow(\" + document.getElementById(\"sh-shadow\").value + document.getElementById(\"sh-shadow\").title + \" \" + document.getElementById(\"sv-shadow\").value + document.getElementById(\"sv-shadow\").title + \" \" + bs + document.getElementById(\"mycolour\").value + \")\";<br \/>\n  }<br \/>\n  } else if (selo.id.substring(1) == 'spread') {<br \/>\n  if (document.getElementById(\"sh-shadow\").value != \"\" && document.getElementById(\"sv-shadow\").value != \"\") {<br \/>\n  if (document.getElementById(\"xblur\").value != \"\") bs+=document.getElementById(\"xblur\").value + document.getElementById(\"xblur\").title + \" \";<br \/>\n  if (document.getElementById(\"sspread\").value != \"\") bs+=document.getElementById(\"sspread\").value + document.getElementById(\"sspread\").title + \" \";<br \/>\n  document.getElementById(\"myimage\").style.filter = \"drop-shadow(\" + document.getElementById(\"sh-shadow\").value + document.getElementById(\"sh-shadow\").title + \" \" + document.getElementById(\"sv-shadow\").value + document.getElementById(\"sv-shadow\").title + \" \" + bs + document.getElementById(\"mycolour\").value + \")\";<br \/>\n  document.getElementById(\"myimage\").style.WebkitFilter = \"drop-shadow(\" + document.getElementById(\"sh-shadow\").value + document.getElementById(\"sh-shadow\").title + \" \" + document.getElementById(\"sv-shadow\").value + document.getElementById(\"sv-shadow\").title + \" \" + bs + document.getElementById(\"mycolour\").value + \")\";<br \/>\n  }<br \/>\n  } else {<br \/>\n  document.getElementById(\"myimage\").style.filter = selo.id.substring(1) + \"(\" + selo.value + selo.title + \")\";<br \/>\n  document.getElementById(\"myimage\").style.WebkitFilter = selo.id.substring(1) + \"(\" + selo.value + selo.title + \")\";<br \/>\n  }<br \/>\n}<br \/>\n<\/code><\/p>\n<p>) &#8230; or jQuery means by which to make this happen with a lot of the modern web browsers.  If you see &#8220;CSS3&#8221; mentioned, then don&#8217;t expect everything to work on super-old web browsers, but expect that anything you implement could be aesthetically interesting or pleasing, as it would not have taken until CSS3 to come along if it was a dead set simple thing to have implemented in the early days of the internet.<\/p>\n<p>Today&#8217;s simple (really) proof of concept web application owes a debt of gratitude to this <a target=_blank title='https:\/\/www.w3schools.com\/cssref\/css3_pr_filter.asp' href='https:\/\/www.w3schools.com\/cssref\/css3_pr_filter.asp'>very useful link<\/a>, which gave us the parameters by which we could construct today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_filters.html\" title='Click picture'>live run<\/a> with its pretty simple HTML and CSS (via CSS3) and Javascript DOM <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/css_filters.html_GETME\" title=\"css_filters.html\">css_filters.html<\/a> source code for you to peruse, and make of what you will.  So what (CSS3) filters are we talking about here?<\/p>\n<ul>\n<li>blur(px)<\/li>\n<li>brightness(%)<\/li>\n<li>contrast(%)<\/li>\n<li>drop-shadow(h-shadow v-shadow blur spread color)<\/li>\n<li>grayscale(%)<\/li>\n<li>hue-rotate(deg)<\/li>\n<li>invert(%)<\/li>\n<li>opacity(%)<\/li>\n<li>saturate(%)<\/li>\n<li>sepia(%)<\/li>\n<\/ul>\n<p> &#8230; which are mostly self explanatory we hope.  Let&#8217;s just say you&#8217;re me &#8230; &#8220;You&#8217;re me.&#8221; &#8230; ta &#8230; please explain &#8220;drop shadow&#8221; &#8230; oh &#8230; you mean &#8230; me?<\/p>\n<blockquote cite=\"https:\/\/en.wikipedia.org\/wiki\/Drop_shadow\"><p>\nIn graphic design, a drop shadow is a visual effect consisting of a drawing element which looks like the shadow of an object, giving the impression that the object is raised above the objects behind it.\n<\/p><\/blockquote>\n<p> &#8230; thanks, <a target=_blank title='Drop shadow information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Drop_shadow'>Wikipedia<\/a>.<\/p>\n<p>As you can imagine, this opening up of this functionality to the client-side web developer opens up lots of opportunities to make your webpages stand out.<\/p>\n<hr>\n<p id='gdfrt'>Previous relevant <a target=_blank title='Gimp Decor Filters Revisit Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/gimp-decor-filters-revisit-tutorial\/'>Gimp Decor Filters Revisit Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/GIMP\/gimp_decor.jpg\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Gimp Decor Filters Revisit Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/GIMP\/gimp_decor.jpg\" title=\"Gimp Decor Filters Revisit Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Gimp Decor Filters Revisit Tutorial<\/p><\/div>\n<p>Today we return to the wonderful, marvellous and stupendous <a target=_blank title='Gimp image editor' href='http:\/\/www.gimp.org\/'>Gimp<\/a> image editor and examine some more of its filters, following up on concepts last discussed with <a target=_blank title='Gimp Decor Border Filters Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/gimp-decor-border-filters-primer-tutorial\/'>Gimp Decor Border Filters Primer Tutorial<\/a> in the &#8220;Decor&#8221; category, namely &#8230;<\/p>\n<ul>\n<li>Fuzzy Border<\/li>\n<li>Coffee Stain<\/li>\n<li>Old Photo &#8230; in the tutorial picture &#8230; plus below &#8230;<\/li>\n<li>Add Bevel<\/li>\n<li>Add Border<\/li>\n<li>Slide<\/li>\n<li>Rounded Corners<\/li>\n<\/ul>\n<p> &#8230; which create quite good effects we feel, especially the Fuzzy Border filter, as it is quite difficult, otherwise to create a &#8220;smudged&#8221; border effect, perhaps for vignetting purposes, without this filter.  We imagine an old map photo could be glamourized using &#8220;Coffee Stain&#8221; (for the accident prone) or &#8220;Old Photo&#8221;.<\/p>\n<p>These &#8220;Decor&#8221; filters are available off Gimp&#8217;s Filter menu as a submenu containing these and some other effects.  They use <a target=_blank title='Gimp Script-Fu' href='https:\/\/docs.gimp.org\/en\/gimp-concepts-script-fu.html'>&#8220;Script-Fu&#8221;<\/a> based on the Scheme interpretive language.  These &#8220;Script-Fu&#8221; filters are not only powerful and useful for what they are, but also for how you can introduce predictability with your effects, in that you can record settings you use, make them public, as necessary, to help create a unified creative but predictable set of effects in the photographs you are applying filters to.<\/p>\n<p>So we&#8217;ll leave you with a photo of our house &#8230;<\/p>\n<p><img src='http:\/\/www.rjmprogramming.com.au\/GIMP\/house.jpg' title='Our house, in the middle of our street'><\/img><\/p>\n<p> &#8230; with &#8230;<\/p>\n<ul>\n<li>Fuzzy Border &#8230;<br \/>\n<img src='http:\/\/www.rjmprogramming.com.au\/GIMP\/house_fb.jpg' title='Our house, in Fuzzy Border'><\/img>\n<\/li>\n<li>Coffee Stain (&#8220;Darken only&#8221; unchecked) &#8230; probably not so apt for this image&#8217;s subject matter &#8230;<br \/>\n<img src='http:\/\/www.rjmprogramming.com.au\/GIMP\/house_cs.jpg' title='Our house, in Coffee Stain'><\/img>\n<\/li>\n<li>Old Photo (&#8220;Defocus&#8221;, &#8220;Sepia&#8221;, &#8220;Mottle&#8221; all checked) &#8230;<br \/>\n<img src='http:\/\/www.rjmprogramming.com.au\/GIMP\/house_op.jpg' title='Our house, in Old Photo'><\/img>\n<\/li>\n<li>Add Bevel (30, &#8220;Keep bump layer&#8221; checked) &#8230;<br \/>\n<img src='http:\/\/www.rjmprogramming.com.au\/GIMP\/house_abev.jpg' title='Our house, in Add Bevel'><\/img>\n<\/li>\n<li>Add Border (37 x and 37 y width, 85 delta value on default blue colour) &#8230;<br \/>\n<img src='http:\/\/www.rjmprogramming.com.au\/GIMP\/house_abdr.jpg' title='Our house, in Add Border'><\/img>\n<\/li>\n<li>Slide (62) &#8230;<br \/>\n<img src='http:\/\/www.rjmprogramming.com.au\/GIMP\/house_slide.jpg' title='Our house, in Slide'><\/img>\n<\/li>\n<li>Rounded Corners (Edge radius 30, Shadow x offset 15, y 15, Blur radius 25) &#8230;<br \/>\n<img src='http:\/\/www.rjmprogramming.com.au\/GIMP\/house_rc.jpg' title='Our house, in Rounded Corners'><\/img>\n<\/li>\n<\/ul>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d21761' onclick='var dv=document.getElementById(\"d21761\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/gimp\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d21761' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#31927' onclick='var dv=document.getElementById(\"d31927\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/filter\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d31927' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s not just the image editor Gimp that has &#8220;filters&#8221; as tools to create effects with image data (files), as you might see with tutorials like Gimp Decor Filters Revisit Tutorial. These days, with CSS, and with CSS3 these days, &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/css3-filters-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,30,37],"tags":[152,281,282,431,433,491,576,590,2026,929,931,997,2293,1319],"class_list":["post-31927","post","type-post","status-publish","format-standard","hentry","category-elearning","category-photography","category-tutorials","tag-blur","tag-css","tag-css3","tag-filter","tag-filters","tag-gimp","tag-html","tag-image","tag-javascript-dom","tag-photograph","tag-photography","tag-programming","tag-sepia","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/31927"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=31927"}],"version-history":[{"count":10,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/31927\/revisions"}],"predecessor-version":[{"id":31945,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/31927\/revisions\/31945"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=31927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=31927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=31927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}