Classicnewcar.us


Tea Rose Home: January 2013

Tea Rose Home: January 2013

We always try our best to challenge your artistic abilities and produce some interesting, beautiful and creative artwork, and as designers we usually turn to different sources of inspiration. As a matter of fact, we’ve discovered the best one—desktop wallpapers that are a little more distinctive than the usual crowd. This creativity mission has been going on for seven years now1, and we are very thankful to all designers who have contributed and are still diligently contributing each month.This post features free desktop wallpapers created by artists across the globe for June 2015. Both versions with a calendar and without a calendar can be downloaded for free. It’s time to freshen up your wallpaper!Please note that:“The month of June is a wonderful time to go fishing, the most soothing and peaceful activity.” — Designed by Igor Izhik3 from Canada.4Designed by Nathalie Ouederni45 from France.46“Summer is coming. And it’s going to be like an amazing water park, full of stunning encounters.” — Designed by Netzbewegung / Mario Metzger62 from Germany.63Designed by Elise Vanoorbeek (Doud Design)105 from Belgium.106“Summer… hair gets lighter, skin gets darker, water gets warmer, nights get longer, music gets louder. Life gets better.” — Designed by Marielle Perikly Kokosidou142 from Greece.143“At last, summer has arrived! So enjoy the sunny weather, make happy thoughts and start planning your vacations. Celebrate the fist month of the summer with a fresh orange juice!” — Designed by WebOlution185 from Greece.186Designed by Ema Tanaskoska Mitrevska230 from Macedonia.231Designed by Iquadart269 from Belarus.270“I am happy in summer! All you need is fresh and relax!” — Designed by Verónica Valenzuela292 from Spain.293“The time we spend with our dads is precious so I picked an activity my dad enjoys a lot, reading.” — Designed by Maria Keller313 from Mexico.314“I made multiple circles overlapping with close distances. The overall drawing looks like a clothing texture, for something you could wear in coming summer. Let’s have a nice summer.” — Designed by Philippe Brouard366 from France.367“We wanted an easy reference guide to help navigate through HTML5 and that could be updateable” — Designed by Castus389 from the UK.390“Shine your light, Before the fight, Just like the sun, Cause we don’t have to run.” — Designed by Anh Nguyet Tran412 from Vietnam.413“June always reminds me of lavender – it just smells wonderful and fresh. For this wallpaper I wanted to create a simple, yet functional design that featured… you guessed it… lavender!” — Designed by Jon Phillips441 from Canada.442“Giraffes are my favorite animal and June 21st is World Giraffe Day, so it was fitting to make it for this month.” — Designed by Megan Jones484 from Pennsylvania, USA.485“June is my wedding anniversary so it has a special place in my heart. And blowing dandelion in the wind is an absolute joy!” — Designed by Thuy Truong513 from the USA.514Designed by Marlin Jackson526 from South Africa.527“I wanted to create a spring/summer vibe and I thought bubbles were a great way to do this because they aren’t too cliche and many people can be seen blowing bubbles during this time of year.” — Designed by Kathleen Reilly571 from United States.572“June brings with the start of the wedding season and all the joy that togetherness brings to the world.” — Designed by Band Hire UK616 from United Kingdom.617“I’m a huge fan of The Walking Dead, and so I decided to make a wallpaper of Hershel.” — Designed by Loïs Claassen643 from the Netherlands.644Please note that we respect and carefully consider the ideas and motivation behind each and every artist’s work. This is why we give all artists the full freedom to explore their creativity and express emotions and experience throughout their works. This is also why the themes of the wallpapers weren’t anyhow influenced by us, but rather designed from scratch by the artists themselves.A big thank you to all designers for their participation. Join in next month666!What’s your favorite theme or wallpaper for this month? Please let us know in the comment section below.(cm)The post Desktop Wallpaper Calendars: June 2015 appeared first on Smashing Magazine.Creativity needs inspiration. Even the greatest designers on earth are nothing without some inspiration from here or there. Look at Android and iOS for example. Armies of designers work on both and yet – isn’t there a slight similarity? Anyway, that’s not the point. To fuel your creativity we have roamed the web fpr new and award-winning piecesof web craftsmanship. Look what we have found. The following specimen stem from around the globe, created by talented agencies and freelancers. All the sites are responsive yet draw a diversified picture of different industries. May the web become even more beautiful… 1. Totem 2. Catalogue-Interactif Bonobo 3. Nothing But Thieves 4. One Dollar Lesson 5. Five Minutes 6. Doriart Webdesign 7. Vangarde Music 8. Sons of Anarchy Tattoo Stories 9. RGB Media Webdesign-Agency 10. De Haus 11. Gogoro 12. adaptable 13. Trippeo 14. Let´s make History 15. Urban Influence 16. MoodBoard Film 17. Reebok – Be more Human 18. Easy Rocket Studio 19. Chedi Andermatt Residences 20. Celebrating Chinese New Year 2015 21. We are Zaion 22. Melanie Daveid 23. Österreich erleben 24. Sassi Holford 25. Bolig Reisen 26. DogStudio 27. FiberSensing 28. NUA Bikes 29. Emiliano Barri 30. RiotGames: Thunderdome 31. In […] * You might also be interested in the following articles: Showcase of Incredible Design Portfolios From All Over the World Link of the Day: Webdesigner News – All the Latest and Greatest… Enjoy Inspiration: Best Design Practices Daily Instant Inspiration: Niice.co, a Brand-new Search Engine for Designers Put Straight! 8 Amazing Sites Created With: Webydo, a Code-free… Pretty Colorful: Webdesign for High-Context Cultures The numerous available CSS selectors let us easily access almost each and every HTML element on any given page. The pseudo-element ::first-line even allows us to apply CSS properties to the first line of text in a document, no matter whether the line is automatically or manually wrapped. Unfortunately, besides ::first-line there are no selevtors to manipulate the second, third, last or whichever line. The JavaScript library Lining.js is here to pimp your possibilities. .line[last] Instead of ::last-line Similar to the selectors ::last-child and ::nth-child() that allow you to touch the last or any random child element, Lining.js adds behaiviors for lines of text. INstead of using the (non-existing) selectors ::last-line and ::nth-line(n), the library introduces the classes .line[last] and .line[index=”n”]. After having embedded the library into your document, start with assigning the data attribute data-lining to every text element you want to manipulate with Lining.js. THe attribute expects no value. 1 2 3 Lorem ipsum … Then use these classes to individually markup lines within the text per CSS. 1 2 3 4 5 6 7 p .line[last] { color: red; } p .line[index=”2″] { font-weight: bold; } .line[last] and .line[index=”2″] active on a text In […] * You might also be interested in the following articles: Styling SVG with CSS: Capabilities and Limitations Fast and Easy: Create HTML Mockups with RoughDraft.js Better than Pure CSS3: Realistic and Complex Shadows with Shine.js HTML5 Server-Sent-Events: How To React On Server Requests With… Perfect Match: Adaptive Backgrounds for jQuery Colors Your Website… Heyoffline.js Notifies Your Users When They Go Offline Building and maintaining1 a WordPress plugin can be a daunting task. The bigger the codebase, the harder it is to keep track of all the working parts and their relationship to one another. And you can add to that the limitations imposed by working in an antiquated version of PHP, 5.2.In this article we will explore an alternative way of developing WordPress plugins, using the lessons learned from the greater PHP community, the world outside WordPress. We will walk through the steps of creating a plugin and investigate the use of autoloading and a plugin container. The first thing you need to do when creating a plugin is to give it a unique name. The name is important as it will be the basis for all our unique identifiers (function prefix, class prefix, textdomain, option prefix, etc.). The name should also be unique across the wordpress.org space. It won’t hurt if we make the name catchy. For our sample plugin I chose the name Simplarity, a play on the words “simple” and “clarity”.We’ll assume you have a working WordPress installation already.First, create a directory named simplarity inside wp-content/plugins. Inside it create the following structure:Open the main plugin file, simplarity.php, and add the plugin information header:This information is enough for now. The plugin name, description, and version will show up in the plugins area of WordPress admin. The license details are important to let your users know that this is an open source plugin. A full list of header information can found in the WordPress codex2.Autoloading allows you to automatically load classes using an autoloader so you don’t have to manually include the files containing the class definitions. For example, whenever you need to use a class, you need to do the following: With autoloading, you can use an autoloader instead of multiple require_once3 statements. It also eliminates the need to update these require statements whenever you add, rename, or change the location of your classes. That’s a big plus for maintainability.Before we create our autoloader we need to create a convention for our class names and their location in the file system. This will aid the autoloader in mapping out the class to its source file.For our class names we will adopt the PEAR naming convention4. The gist is that class names are alphabetic characters in StudlyCaps. Each level of the hierarchy is separated with a single underscore. Class names will directly map to the directories in which they are stored.It’s easier to illustrate it using examples:As you can see with this convention, the autoloader will just replace the underscores with directory separators to locate the class definition.As you might be aware, WordPress has its own naming convention5 for class names. It states:Class names should use capitalized words separated by underscores. Any acronyms should be all upper case. […] Class file names should be based on the class name with class- prepended and the underscores in the class name replaced with hyphens, for example WP_Error becomes class-wp-error.phpI know that we should follow the standards of the platform that we are developing on. However, we suggest using the PEAR naming convention because:Note that we are only using this naming convention for classes. The rest of our code will still follow the WordPress coding standards. It’s important to follow and respect the standards of the platform that we are developing on.Now that we have fully covered the naming convention, we can finally build our autoloader.Open our main plugin file and add the following code below the plugin information header:At the heart of our autoloading mechanism is PHP’s built in spl_autoload_register6 function. All it does is register a function to be called automatically when your code references a class that hasn’t been loaded yet.The first line tells spl_autoload_register to register our function named simplarity_autoloader:Next we define the simplarity_autoloader function:Notice that it accepts a $class_name parameter. This parameter holds the class name. For example when you instantiate a class using $plugin = new Simplarity_Plugin(), $class_name will contain the string “Simplarity_Plugin”. Since we are adding this function in the global space, it’s important that we have it prefixed with simplarity_.The next line checks if $classname contains the string “Simplarity” which is our top level namespace:This will ensure that the autoloader will only run on our classes. Without this check, our autoloader will run every time an unloaded class is referenced, even if the class is not ours, which is not ideal.The next line constructs the path to the directory where our classes reside:It uses WP’s plugin_dir_path7 to get the plugin root directory. __FILE__ is a magic constant8 that contains the full path and filename of the current file. DIRECTORY_SEPARATOR is a predefined constant that contains either a forward slash or backslash depending on the OS your web server is on. We also use realpath9 to normalize the file path.This line resolves the path to the class definition file:It replaces the underscore (_) in $class_name with the directory separator and appends .php.Finally, this line builds the file path to the definition and includes the file using require_once:That’s it! You now have an autoloader. Say goodbye to long lines of require_once statements.A plugin container is a special class that holds together our plugin code. It simplifies the interaction between the many working parts of your code by providing a centralized location to manage the configuration and objects.Here are the things we can expect from the plugin container:Often you’ll find this code in plugins:Instead of doing that, we could do this instead:This has the added benefit of not polluting the global namespace with our plugin’s constants, which in most cases aren’t needed by other plugins.Instead of scattering our class instantiations everywhere in our codebase we can just do this in a single location:This is the most powerful feature of the container. A service is an object that does something as part of a larger system. Services are defined by functions that return an instance of an object. Almost any global object can be a service.Services result in lazy initialization whereby objects are only instantiated and initialized when needed.It also allows us to easily implement a self-resolving dependency injection design. An example:This is roughly equivalent to:Whenever we get an object, as in $house = $plugin['house']; , the object is created (lazy initialization) and dependencies are resolved automatically.Let’s start by creating the plugin container class. We will name it “Simplarity_Plugin”. As our naming convention dictates, we should create a corresponding file: src/Simplarity/Plugin.php.Open Plugin.php and add the following code:The class implements the ArrayAccess interface:This allows us to use it like PHP’s array:The functions offsetSet, offsetExists, offsetUnset and offsetGet are required by ArrayAccess to be implemented. The run function will loop through the contents of the container and run the runnable objects.To better illustrate our plugin container, let’s start by building a sample plugin.This plugin will add a settings page named “Simplarity” under WordPress Admin ? Settings.Let’s go back to the main plugin file. Open up simplarity.php and add the following code. Add this below the autoloader code:Here we use WP’s add_action to hook our function simplarity_init into plugins_loaded:This is important as this will make our plugin overridable by using remove_action. An example use case would be a premium plugin overriding the free version.Function simplarity_init contains our plugin’s initialization code. At the start, we simply instantiate our plugin container:These lines assign global configuration data:The plugin path contains the full path to our plugin, the url contains the URL to our plugin directory. They will come in handy whenever we need to include files and assets. version contains the current version of the plugin that should match the one in the header info. Useful whenever you need to use the version in code.This next code assigns various configuration data to settings_page_properties:These configuration data are related to WP settings API10.This next code instantiates the settings page, passing along settings_page_properties:The run method is where the fun starts:It will call Simplarity_SettingsPage‘s own run method.Now we need to create the Simplarity_SettingsPage class. It’s a class that groups together the settings API functions.Create a file named SettingsPage.php in src/Simplarity/. Open it and add the following code:The class property $settings_page_properties stores the settings related to WP settings API:The constructor function accepts the settings_page_properties and stores it:The values are passed from this line in the main plugin file:The run function is use to run startup code:The most likely candidate for startup code are filters11 and action hooks12. Here we add the action hooks related to our settings page. Do not confuse this run method with the run method of the plugin container. This run method belongs to the settings page class.This line hooks the add_menu_and_page function on to the admin_menu action:Function add_submenu_page in turn calls WP’s add_submenu_page13 function to add a link under the WP Admin ? Settings:As you can see, we are pulling the info from our class property $settings_page_properties which we specified in the main plugin file.The parameters for add_submenu_page are:This line hooks the register_settings function on to the admin_init action:array( $this, 'register_settings' ) means to call register_settings on $this, which points to our SettingsPage instance.The register_settings then calls WP’s register_setting to register a setting:Function render_settings_page is responsible for rendering the page:We hooked render_settings_page earlier using add_submenu_page.Function get_settings_data is a wrapper function for get_option:This is to easily get the settings data with a single function call.Function get_default_settings_data is use to supply us with our own default values:Right now our settings page class cannot be reused if you want to create another subpage. Let’s move the reusable code for the settings page to another class.Let’s call this class Simplarity_WpSubPage. Go ahead and create the file src/Simplarity/WpSubPage.php.Now add the code below:Notice that it is an abstract class. This will prevent intantiating this class directly. To use it you need to extend it first with another class, which in our case is Simplarity_SettingsPage:The only functions we have implemented are render_settings_page and get_default_settings_data, which are customized to this settings page.To create another WP settings page you’ll just need to create a class and extend the Simplarity_WpSubPage. And implement your own render_settings_page and get_default_settings_data.The power of the plugin container is in defining services. A service is a function that contains instantiation and initialization code that will return an object. Whenever we pull a service from our container, the service function is called and will create the object for you. The object is only created when needed. This is called lazy initialization.To better illustrate this, let’s define a service for our settings page.Open simplarity.php and add this function below the Simplarity code:Notice that our service function has a $plugin parameter which contains our plugin container. This allows us to access all configuration, objects, and services that have been stored in our plugin container. We can see that the Simplarity_SettingsPage has a dependency on $plugin['settings_page_properties']. We inject this dependency to Simplarity_SettingsPage here. This is an example of dependency injection. Dependency injection is a practice where objects are designed in a manner where they receive instances of the objects from other pieces of code, instead of constructing them internally. This improves decoupling of code.Now let’s replace this line in simplarity_init:with a service definition assignment:So instead of assigning our object instance directly, we assign the name of our function as string. Our container handles the rest. Right now, every time we get $plugin['settings_page'], a new instance of Simplarity_SettingsPage is returned. Ideally, Simplarity_SettingsPage should only be instantiated once as we are using WP hooks, which in turn should only be registered once.To solve this we use a shared service. A shared service will return a new instance of an object on first call, on succeeding calls it will return the same instance.Let’s create a shared service using a static variable:On first call, $object is null, and on succeeding calls it will contain the instance of the object created on first call. Notice that we are using a static variable. A static variable exists only in a local function scope, but it does not lose its value when program execution leaves this scope.That’s it.Now if you activate the plugin, an admin menu will appear in Admin ? Settings named “Simplarity”. Click on it and you will be taken to the settings page we have created.Earlier we mentioned that our class naming convention was future-ready. In this section we will discuss how our codebase will work in PHP version 5.3 and up. Two of the best features that have graced the PHP world are namespaces and anonymous functions.PHP does not allow two classes or functions to share the same name. When this happens, a name collision occurs and causes a nasty error.With namespaces you can have the same class names as long as they live in their own namespace. A good ogy for namespaces are the folders you have in your OS. You cannot have files with the same name in one folder. However, you can have the same filenames in different folders.With namespaces, class and function names won’t need unique prefixes anymore.Anonymous functions, also known as closures, allow the creation of functions which have no specified name. They are most useful as the value of callback parameters, but they have many other uses. You can also store closures in variables.Here’s an example of closure:Let’s go ahead and use namespaces in our class definitions. Open up the following files in src/Simplarity:In each of these files, add a namespace declaration on top and remove the “Simplarity_” prefix on class names:Since we have updated our class names we also need to update our class instantiations in simplarity.php. We do this by deleting the prefixes:By default, PHP will try to load the class from the root namespace so we need to tell it about our namespaced classes. We add this to the top of simplarity.php just above the autoloader code:This is called importing/aliasing with the use operator15.Open up simplarity.php and change this line in the autoloader from:to:Remember that in 5.2 code we are using underscores as hierarchy separators. For 5.3+ we are using namespaces which use backslash “” as hierarchy separators. Thus we simply swap “_” for “”. We use another backslash to escape the original one: “”.We can now replace the global functions we created for our service definitions with anonymous functions. So instead of doing this:we can just replace this with an inline anonymous function:Pimple is a small dependency injection (DI) container for PHP 5.3+. Pimple has the same syntax as our simple plugin container. In fact our plugin container was inspired by Pimple. In this part, we will extend Pimple and use it.Download Pimple container from GitHub16 and save it in src/Simplarity/Pimple.php.Open up Pimple.php and replace the namespace and the classname to:Open up Plugin.php and replace all the code with:Now let’s change the service definition in simplarity.php to:By default, each time you get a service, Pimple returns the same instance of it. If you want a different instance to be returned for all calls, wrap your anonymous function with the factory() method:The PHP community is big. A lot of best practices have been learned over the years. It’s good to always look beyond the walled garden of WordPress to look for answers. With autoloading and a plugin container we are one step closer to better code.(dp, og, il)The post How To Use Autoloading And A Plugin Container In WordPress Plugins appeared first on Smashing Magazine.Google has been changing its search algorithm time and again to deliver better search results. Factors like keywords, link building, and loading performance play a key role in how Google ranks a website. On April 21st Google officially issued a new ranking factor: the mobile-friendliness of a website. How is this going to affect site operators and what does mobile-friendliness mean from Google’s point of view? Increasing Importance of Mobile Web It shouldn’t come as a surprise that Google has now officially introduced this new ranking factor. We’re using smartphones and tablets more frequently to search the web. Indeed, the same applies to the Google search. It is understandable that Google wants to prioritize websites for mobile devices that can be optimally displayed on them. This website is mobile friendly 😉 A while ago, Google started labeling websites that are optimized for mobile devices in its mobile search results. It makes no difference if a website provides a separate mobile version or a responsive design. If there’s a separate mobile version, Google will only feature this in the search results and the desktop version will be omitted. The mobile-friendly factor doesn’t affect the desktop version of a Google search. Generally, […] * You might also be interested in the following articles: Is your Responsive Design Mobile Website Delivering Acceptable Load… Google Web Fundamentals: Free Handbook for Multi-Device Web Design in… Advertising For Mobile On The Rise [Infographic] ReView.js Changes Viewports In Responsive Designs With a Single Mouse… Leaflet: Interactive Maps with JavaScript and OpenStreetMap The Truth about WordPress Performance [#1/2] Ever wanted to create your own Twitch.tv-like app for livestreaming your work? How about your own YouTube-esque program for playing back your previously recorded video? You might have used Flash, Java, or Silverlight for rich media in the past but with Chrome 42 announcing that that those plug-ins are no longer supported, now is as good a time to go HTML5 as ever. Before I worked at Microsoft, I was a Sr. Engineer on the Product Development team at Comcast, where I worked on video players for a number of platforms, including the web, Xbox One, Xbox 360, and SmartGlass. It was an outstanding education in cutting edge video technology, and I’m glad that I can take my experience with me in this role and teach others much of what I learned there. This is the first of a series of articles about using Azure Media Services to create and consume HTML5 video. In this tutorial, I’ll explain how to use this cloud media solution to get set-up and start experimenting with delivering live or on demand video. First, a Primer on Video Formats There are a number of formats to choose from, so let’s go through some of the […] * You might also be interested in the following articles: Big Time Saver: Becoming a WordPress Pro (Near-)Instantly JavaScript: Using Closure Space to Create Real Private Members Lord Of The Rings: Ringmark Checks Mobile Browsers For HTML5… Time Lapse Videos: How to Quicken the Pace of Your Movies Hands-On: Build a Node.js-powered Chatroom Web App (Part Two) Essential: How to Test Internet Explorer on Android, iOS, and Mac OS X One of the key activities in Design Thinking is doing design. Hence the irony that Design Thinking actually involves design doing. Not exactly in what designers do, but brainstorming solutions, prototyping them, learning and validating, iterating and improving. Rinse and repeat.I like to use the ogy of simulating and experimenting during Chemistry lab to describe the Design activity in our workshops. For example the experiment of splitting “H” and “O” from H2O. I could never get my test tube with the Hydrogen to pop in my first go. I would need to try the process a few times before I get it right. I found it therefore interesting when Ken Rosen explains (perhaps oversimplifying) how the differences of the Airbus A380 and the Boeing 787 could have been better determined through a simulation mindset. Start a simulation mindset for major strategic decisions. Determine the minimum viable model you can use to represent your situation. Use that model to create a game, discussion, or workshop. Play.That is Design Thinking at its best. Applied holistically to simulate scenarios of the hardest problems through the eyes of your stakeholders. Use a sketch, lego blocks, a game, full-size spatial mockups, anything that will give you a “quick and dirty” way to get real quick. With a little effort, you can learn so much about the wicked problems you are trying to solve.Are you sometimes fed up with everything glossy, glassy, gradient-esque, three-dimensional, abstract, surreal – in one word with everything artificial, virtual? Yes? Me too. Now is the perfect time to turn to natural, real and genuine. Simply set your eyes on something organic, something that you can touch, feel and even eat, something that has vibes and evokes warm feelings. Our today’s collection is dedicated to impressive and intricate handmade typography. Edible cookies in the form of the alphabet, letters made from plasticine or carved out from fruits immediately spring to mind. Those are one of the most primitive examples of handcrafted fonts that can be quickly reproduced by any enthusiast equipped with proper tools. In fact this art direction hides a lot more than you can think of: there are works that can inspire, spark interest, refresh, cheer up and overwhelm. From elaborate paper-based letterforms made with the help of quilling technique to characters that are sculpted from metal, wood, plastic, grass or other raw material, designers try to go beyond boundaries in order to create remarkable and staggering letterforms. Today we have curated 30 outstanding examples of their diligence for you: Silk Road Film Festival 2015 – 3D […] * You might also be interested in the following articles: Incredible Typography: 28 Sculptural Fonts (Showcase) World of Design No. 2: New Zealand IM FREE: Curated Collections of Free Commercial Use Photos No Designer Sky’s The Limit: 40 Fresh and Free Photoshop Text Effects Boring Work Made Easy: Free Templates for Creating Manuals Late-breaking: 29 Free Vibrant Flat UI Packs After almost 20 years of evolution, today’s web typography, with its high-density displays and support for OpenType features, is just a step away from the typographic quality of the offline world. But there’s still one field of graphic design where we still constantly fall back to bitmap replacements instead of using native text: display typography, the art of staging letters in illustrative, gorgeous, dramatic, playful, experimental or unexpected ways.Sure, we’re able choose from thousands of web fonts and use CSS effects for type, some with wide browser support (like drop-shadows and 3D transforms) and others that are more experimental (like background-clip and text-stroke), but that’s basically it. If we want really outstanding display typography on our websites, we’ll usually embed it as an image.The disadvantages of using images for type on the web are obvious: file size, lack of feasibility for frequently altered or user-generated content, accessibility, time-consuming production of assets, etc.Wouldn’t it be great if we could style letters the same way we usually style text with CSS? Apply multiple borders with different colors? Add inner and outer bevels? Add patterns, textures and 3D-effects? Give type a used look? Use multiple colors and distorted type? Give type a distressed look?Most of this is already possible: The trick is to unleash the magic of SVG filters. SVG filters (and CSS filters) are usually considered a way to spice up bitmaps via blur effects or color manipulation. But they are much more. Like CSS rules, an SVG filter can be a set of directives to add another visual layer on top of conventional text. With the CSS filter property, these effects can be used outside of SVG and be applied directly to HTML content.Talking about filters in CSS and SVG can be a bit confusing: SVG filters are defined in an SVG filter element and are usually applied within an SVG document. CSS filters can be applied to any HTML element via the filter property. CSS filters such as blur, contrast and hue-rotate are shortcuts for predefined, frequently used SVG filter effects. Beyond that, the specification7 allows us to reference user-defined filters from within an SVG. A further point of confusion is the proprietary -ms- filter tag, which was deprecated in Internet Explorer (IE) 9 and removed when IE 10 was released.This article mostly deals with the first case: SVG filters used in an SVG document embedded on an HTML page, but later we’ll experiment with SVG filters applied to HTML content.The illustrations in this article are taken from demos of SVG filter effects applied to text. Click on any one of them to see the original (modern, SVG-capable browsers only). I call them “sophisticated” SVG filters because under the hood these filters are crafted by combining multiple effects into one output. And even though the appearance of the letters has been altered dramatically, under the hood the text is still crawlable and accessible and can be selected and copied. Because SVG filters are supported in every modern browser, these effects can be displayed in browsers beginning from IE 10.Understanding SVG filters is challenging. Even simple effects like drop-shadows require a complicated, verbose syntax. Some filers, such as feColorMatrix and feComposite, are difficult to grasp without a thorough understanding of math and color theory. This article will not be a tutorial on learning SVG filters. Instead I will describe a set of standard building blocks to achieve certain effects, but I will keep explanations to the bare minimum, focusing on documenting the individual steps that make up an effect. You will mostly read about the how; for those who want to know the why, I’ve put a reading list at the end of this article.Below is a sophisticated SVG fiter in action. The output of this filter is a weathered text effect, and we will use this for a step-by-step walkthrough:Let’s break down this effect into its building blocks:Our SVG filter effect will be constructed by combining multiple small modules, so-called “filter primitives.” Every building block is constructed from a set of one or more primitives that are then combined into a unified output. This process is easier to understand when shown as a graph:We’ll start with a boilerplate SVG that contains an empty filter and text:We have to start somewhere, and the filter tag is the element to begin with. Between its start and end tag, we will put all of the rules for transformation, color, bitmap manipulation, etc. The filter can then be applied to a target as an attribute or via CSS. The target will usually be an element inside an SVG, but later on we will learn about another exciting option: applying SVG filters to HTML elements.A handful of attributes exist to control the filter element:As we’ve learned, filter primitives are the building blocks of SVG filters. To have any effect, an SVG filter should contain at least one primitive. A primitive usually has one or two inputs (in, in2) and one output (result). Primitives exist for blurring, moving, filling, combining or distorting inputs.The specification allows us to take several attributes of the filtered element as an input source. Because most of these do not work reliably across browsers anyway, in this article we will stick with SourceGraphic (the unfiltered source element with colors, strokes, fill patterns, etc.) and SourceAlpha (the opaque area of the alpha channel — think of it as the source graphic filled black), which do have very good browser support.The first filter primitive we will get to know is feMorphology, a primitive meant to extend (operator="dilate") or thin (operator="erode") an input — therefore, perfectly suited to creating outlines and borders.Here is how we would fatten the SourceAlpha by four pixels:The next step is to create a 3D extrusion of the result from the last primitive. Meet feConvolveMatrix. This filter primitive is one of the mightiest and most difficult to grasp. Its main purpose is to enable you to create your own filter. In short, you would define a pixel raster (a kernel matrix) that alters a pixel according to the values of its neighbouring pixels. This way, it becomes possible to create your own filter effects, such as a blur or a sharpening filter, or to create an extrusion.Here is the feConvolveMatrix to create a 45-degree, 3-pixel deep extrusion. The order attribute defines a width and a height, so that the primitive knows whether to apply a 3×3 or a 9×1 matrix:Be aware that IE 11 and Microsoft Edge (at the time of writing) cannot handle matrices with an order greater than 8×8 pixels, and they do not cope well with multiline matrix notation, so removing all carriage returns before deploying this code would be best.The primitive will be applied equally to the left, top, right and bottom. Because we want it to extrude only to the right and bottom, we must offset the result. Two attributes define the starting point of the effect, targetX and targetY. Unfortunately, IE interprets them contrary to all other browsers. Therefore, to maintain compatibility across browsers, we will handle offsetting with another filter primitive, feOffset.As the name implies, feOffset takes an input and, well, offsets it:feComposite is one of the few filter primitives that take two inputs. It then combines them by applying a method for composing two images called Porter-Duff compositing. feComposite can be used to mask or cut elements. Here’s how to subtract the output of feMorphology from the output of feConvolveMatrix:This is a two-step process:First, we create a colored area with feFlood. This primitive will simply output a rectangle the size of the filter region in a color we define:We then cut off the transparent part of BEVEL_30 with one more feComposite:feMerge does just that, mix bevel and source into one output:Looks pretty much like the desired result. Let’s make it a little more realistic by giving it a weathered look.feTurbulence is one of the most fun primitives to play with. However, it can melt your multicore CPU and make your fans rotate like the turbojet engines of a Boeing 747. Use it wisely, especially on a mobile device, because this primitive can have a really, really bad effect on rendering performance.Like feFlood, feTurbulence outputs a filled rectangle but uses a noisy, unstructured texture.We have several values on hand to alter the appearance and rhythm of the texture. This way, we can create surfaces that look like wood, sand, watercolor or cracked concrete. These settings have a direct influence on the performance of the filter, so test thoroughly. Here’s how to create a pattern that resembles paint strokes:By default, feTurbulence outputs a colored texture — not exactly what we want. We need a grayscale alpha map; a bit more contrast would be nice, too. Let’s run it through an feColorMatrix to increase the contrast and convert it to grayscale at the same time:The last thing to do is compose the textured alpha into the letterforms with our old friend feComposite:Done!There are two methods of applying SVG filters to an SVG text element:One of the most exciting features of filters is that it’s possible to embed an SVG, define a filter in it and then apply it to any HTML element with CSS:At the time of writing, Blink and WebKit require it to be prefixed:As easy as it sounds in theory, this process is a dark art in the real world:In these demos, the wrappers are set to contenteditable = "true for convenient text editing. (Be aware that these demos are experimental and will not work in Safari, IE or Edge.)Depending on its complexity, a filter can quickly become a messy thing. During authoring, you could be adding and removing rules and changing their order and values, and soon you’re lost. Here are some rules I’ve made for myself that help me keep track of what’s going on. People and projects vary; what seems logical and structured for me might be chaotic and incomprehensible for you, so take these recommendations with a grain of salt.I group my filter primitives into modules depending on their functionality — for example, “border,” “fill,” “bevel,” etc. At the start and end of a module, I put a comment with the name of this group.A good naming convention will help you structure your filter and keep track of what’s going in and outside of a primitive. After experimenting with BEM-like schemas25, I finally settled on a very simple naming structure:For example, you would have BEVEL_10, BEVEL_20, OUTLINE_10 and so on. I start with 10 and increment by 10 to make it easier to change the order of primitives or to add a primitive in between or to the beginning of a group. I prefer full caps because they stand out and help me to scan the source faster.Though not necessary, I always declare an “in” and a “result.” (If omitted, the output of a primitive will be the input of its successor.)Let’s look at some single techniques to achieve certain effects. By combining these building blocks, we can create new sophisticated filter effects.This method is not guaranteed to look good. Especially when you apply dilate in conjunction with big values for radius, the result can look worse than the geometry created via stroke-width. Depending on the situation, a better alternative would be to store the text in a symbol element, and then insert it when needed via use, and thicken the instance with CSS’ stroke-width property. Be aware that stroke-width cannot be applied to HTML content, though.It should be mentioned that, besides feFlood, feColorMatrix is another method of altering the source input’s color, even though that concept is more difficult to grasp.The feTurbulence filter primitive will create a noisy texture by applying the so-called Perlin noise algorithm (invented by Ken Perlin during his work on TRON in 1981). This will generate a rectangle filled with noise that looks like what you could see on old TV sets late at night before cable TV was invented.The appearance of the noise structure can be modified by several parameters:feImage‘s purpose is to fill the target with a texture. If we want to apply a repeating pattern, it must be used in conjunction with feTile.The cool thing about this filter is that the specification allows us to use any SVG element as an input and to create a pattern fill from it. So, in theory, you could create pattern fills from symbols, groups and fragments within your SVG and then apply them as a texture, even to HTML elements. Unfortunately, because of an old bug33, Firefox accepts only external resources as input. If you prefer to keep things self-contained and want to avoid the additional HTTP request, there’s hope: Embed the pattern fill as an UTF-8 data URI:Some browsers do not understand UTF-8 data URIs when they aren’t URL-encoded, so make URL encoding34 a default:If you want to apply feImage to HTML content, be aware that size matters. The SVG that contains the filter must cover the area where it is being applied. The easiest way to achieve this is by making it an absolutely positioned child within the block element it is being applied to:This is one “Wow” effect that quickly becomes boring when used too often. This filter has a serious effect on performance, so use it wisely.There is a gap between pure CSS layout and custom design elements created in software such as Photoshop or Illustrator. External assets embedded as background images, icon sprites and SVG symbols will always have their place in the design of websites. But sophisticated SVG filters give us more independence from third-party design tools and bridge this gap by enabling us to create visual styles directly in the browser.In this article we’ve seen how SVG filters help us to create playful, decorative web typography. But nothing says we have to stop here. Soon, browser support will be good enough for us to use these effects on every HTML element as easily as we use CSS today. Even though the effects behave differently from native CSS techniques (an SVG filter will affect not only an element but all its children), it will be exciting to see how inventive web designers use these techniques in the near future.(ds, al)The post The Art Of The SVG Filter And Why It Is Awesome appeared first on Smashing Magazine.Welcome to the second part of my series about ECMAScript 6! One of my favorite new web standards Microsoft Edge, the new browser rendering engine we’re creating at Microsoft, is the extensive support it offers for ECMAScript 6. So I wrote this series to walk you through some of the cool things you can do with ECMAScript 6 when writing large applications for the web. In the first installment, I covered Class and Inheritance. In this article, I’ll focus on template strings based on my personal experience creating embedded expressions. Resolving the Line Return Problem When working on babylon.js, I have to deal with shaders code which can be seen, for the sake of comprehension, like a big bunch of text (which looks like C). You can find an example here. The problem when dealing with long-sized text in JavaScript is the line return. How many times did you write this kind of thing? 1 2 3 4 5 6 7 var myTooLongString = “A long time ago, in a galaxy far,” + “far away….” + “It is a period of civil war.” + “Rebel spaceships, striking” + “from a hidden base, have won” + “their first victory against” + […] * You might also be interested in the following articles: From Scratch: Writing a 3D Soft Engine 3/6 JavaScript: Using Closure Space to Create Real Private Members From Scratch: Writing a 3D Soft Engine 2/6 MagicSuggest for jQuery: Beautiful Selection Comboboxes Based on… New Era: Computation of Time with Moment.js HTML5 Server-Sent-Events: How To React On Server Requests With… Enter your email address:Delivered by FeedBurner



Publicar un comentario BLOG_CMT_createIframe('https://draft.blogger.com/rpc_relay.html');





#Contact US #Terms of Use #Privacy Policy #Earnings Disclaimer