Archive for May, 2015

Desktop Wallpaper Calendars: June 2015

May 31st, 2015 No comments
Fishing Is My Passion!

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:

  • All images can be clicked on and lead to the preview of the wallpaper,
  • You can feature your work in our magazine2 by taking part in our Desktop Wallpaper Calendars series. We are regularly looking for creative designers and artists to be featured on Smashing Magazine. Are you one of them?

Fishing Is My Passion!

“The month of June is a wonderful time to go fishing, the most soothing and peaceful activity.” — Designed by Igor Izhik3 from Canada.


Strawberry Fields

Designed by Nathalie Ouederni45 from France.


The Amazing Water Park

“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.

The Amazing Water Park63


Designed by Elise Vanoorbeek (Doud Design)105 from Belgium.


R U Ready for Summertime?

“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.

R U Ready for Summertime?143

June Is Here!

“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.

June Is Here!186

Let The Spring Set You Free

Designed by Ema Tanaskoska Mitrevska230 from Macedonia.

Let The Spring Set You Free231

Caution! Hot June

Designed by Iquadart269 from Belarus.

Caution! Hot June270

Summer Time…

“I am happy in summer! All you need is fresh and relax!” — Designed by Verónica Valenzuela292 from Spain.

Summer Time...293

Night Night!

“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.

Night Night!314

Knitting For Summer

“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.

Knitting For Summer367

Periodic Table Of HTML5 Elements

“We wanted an easy reference guide to help navigate through HTML5 and that could be updateable” — Designed by Castus389 from the UK.

Periodic Table Of HTML5 Elements390

Shine Your Light

“Shine your light, Before the fight, Just like the sun, Cause we don’t have to run.” — Designed by Anh Nguyet Tran412 from Vietnam.

Shine Your Light413

Lavender Is In The Air!

“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.

Lavender Is In The Air!442

Through The Savannah

“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.

Through The Savannah485

Only True Love Stays

“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.

Only True Love Stays514

Scattered Leaves

Designed by Marlin Jackson526 from South Africa.

Scattered Leaves527

Springtime Bubbles

“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.

Springtime Bubbles572

Happiness Together, Forever

“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.

Happiness, Together, Forever617

Hershel The Walking Dead

“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.

Hershel The Walking Dead644

Join In Next Month!

Please 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?

What’s your favorite theme or wallpaper for this month? Please let us know in the comment section below.



  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6×480.jpg
  7. 7×480.jpg
  8. 8×480.jpg
  9. 9×600.jpg
  10. 10×768.jpg
  11. 11×1024.jpg
  12. 12×864.jpg
  13. 13×720.jpg
  14. 14×800.jpg
  15. 15×960.jpg
  16. 16×1024.jpg
  17. 17×1050.jpg
  18. 18×900.jpg
  19. 19×1200.jpg
  20. 20×1050.jpg
  21. 21×1200.jpg
  22. 22×1080.jpg
  23. 23×1200.jpg
  24. 24×1440.jpg
  25. 25×1440.jpg
  26. 26×480.jpg
  27. 27×480.jpg
  28. 28×480.jpg
  29. 29×600.jpg
  30. 30×768.jpg
  31. 31×1024.jpg
  32. 32×864.jpg
  33. 33×720.jpg
  34. 34×800.jpg
  35. 35×960.jpg
  36. 36×1024.jpg
  37. 37×1050.jpg
  38. 38×900.jpg
  39. 39×1200.jpg
  40. 40×1200.jpg
  41. 41×1080.jpg
  42. 42×1200.jpg
  43. 43×1440.jpg
  44. 44×1440.jpg
  45. 45
  46. 46
  47. 47
  48. 48×480.jpg
  49. 49×768.jpg
  50. 50×1024.jpg
  51. 51×900.jpg
  52. 52×1200.jpg
  53. 53×1200.jpg
  54. 54×1440.jpg
  55. 55×480.jpg
  56. 56×768.jpg
  57. 57×1024.jpg
  58. 58×900.jpg
  59. 59×1200.jpg
  60. 60×1200.jpg
  61. 61×1440.jpg
  62. 62
  63. 63
  64. 64
  65. 65×480.jpg
  66. 66×480.jpg
  67. 67×600.jpg
  68. 68×768.jpg
  69. 69×1024.jpg
  70. 70×864.jpg
  71. 71×720.jpg
  72. 72×800.jpg
  73. 73×960.jpg
  74. 74×1024.jpg
  75. 75×768.jpg
  76. 76×1050.jpg
  77. 77×900.jpg
  78. 78×1200.jpg
  79. 79×1050.jpg
  80. 80×1200.jpg
  81. 81×1080.jpg
  82. 82×1200.jpg
  83. 83×1440.jpg
  84. 84×1440.jpg
  85. 85×480.jpg
  86. 86×480.jpg
  87. 87×600.jpg
  88. 88×768.jpg
  89. 89×1024.jpg
  90. 90×864.jpg
  91. 91×720.jpg
  92. 92×800.jpg
  93. 93×960.jpg
  94. 94×1024.jpg
  95. 95×768.jpg
  96. 96×1050.jpg
  97. 97×900.jpg
  98. 98×1200.jpg
  99. 99×1050.jpg
  100. 100×1200.jpg
  101. 101×1080.jpg
  102. 102×1200.jpg
  103. 103×1440.jpg
  104. 104×1440.jpg
  105. 105
  106. 106
  107. 107
  108. 108×768.jpg
  109. 109×1024.jpg
  110. 110×864.jpg
  111. 111×720.jpg
  112. 112×800.jpg
  113. 113×960.jpg
  114. 114×1024.jpg
  115. 115×768.jpg
  116. 116×1050.jpg
  117. 117×900.jpg
  118. 118×1200.jpg
  119. 119×1050.jpg
  120. 120×1200.jpg
  121. 121×1080.jpg
  122. 122×1200.jpg
  123. 123×1440.jpg
  124. 124×1440.jpg
  125. 125×768.jpg
  126. 126×1024.jpg
  127. 127×864.jpg
  128. 128×720.jpg
  129. 129×800.jpg
  130. 130×960.jpg
  131. 131×1024.jpg
  132. 132×768.jpg
  133. 133×1050.jpg
  134. 134×900.jpg
  135. 135×1200.jpg
  136. 136×1050.jpg
  137. 137×1200.jpg
  138. 138×1080.jpg
  139. 139×1200.jpg
  140. 140×1440.jpg
  141. 141×1440.jpg
  142. 142
  143. 143
  144. 144
  145. 145×480.png
  146. 146×480.png
  147. 147×480.png
  148. 148×600.png
  149. 149×768.png
  150. 150×1024.png
  151. 151×864.png
  152. 152×720.png
  153. 153×800.png
  154. 154×960.png
  155. 155×1024.png
  156. 156×900.png
  157. 157×1050.png
  158. 158×1200.png
  159. 159×1050.png
  160. 160×1200.png
  161. 161×1080.png
  162. 162×1200.png
  163. 163×1440.png
  164. 164×1440.png
  165. 165×480.png
  166. 166×480.png
  167. 167×480.png
  168. 168×600.png
  169. 169×768.png
  170. 170×1024.png
  171. 171×864.png
  172. 172×720.png
  173. 173×800.png
  174. 174×960.png
  175. 175×1024.png
  176. 176×900.png
  177. 177×1050.png
  178. 178×1200.png
  179. 179×1050.png
  180. 180×1200.png
  181. 181×1080.png
  182. 182×1200.png
  183. 183×1440.png
  184. 184×1440.png
  185. 185
  186. 186
  187. 187
  188. 188×480.jpg
  189. 189×480.jpg
  190. 190×480.jpg
  191. 191×600.jpg
  192. 192×768.jpg
  193. 193×1024.jpg
  194. 194×864.jpg
  195. 195×720.jpg
  196. 196×800.jpg
  197. 197×960.jpg
  198. 198×1024.jpg
  199. 199×768.jpg
  200. 200×900.jpg
  201. 201×1050.jpg
  202. 202×1200.jpg
  203. 203×1050.jpg
  204. 204×1200.jpg
  205. 205×1080.jpg
  206. 206×1200.jpg
  207. 207×1440.jpg
  208. 208×1440.jpg
  209. 209×480.jpg
  210. 210×480.jpg
  211. 211×480.jpg
  212. 212×600.jpg
  213. 213×768.jpg
  214. 214×1024.jpg
  215. 215×864.jpg
  216. 216×720.jpg
  217. 217×800.jpg
  218. 218×960.jpg
  219. 219×1024.jpg
  220. 220×768.jpg
  221. 221×900.jpg
  222. 222×1050.jpg
  223. 223×1200.jpg
  224. 224×1050.jpg
  225. 225×1200.jpg
  226. 226×1080.jpg
  227. 227×1200.jpg
  228. 228×1440.jpg
  229. 229×1440.jpg
  230. 230
  231. 231
  232. 232
  233. 233×480.jpg
  234. 234×480.jpg
  235. 235×480.jpg
  236. 236×600.jpg
  237. 237×768.jpg
  238. 238×864.jpg
  239. 239×720.jpg
  240. 240×800.jpg
  241. 241×960.jpg
  242. 242×1024.jpg
  243. 243×900.jpg
  244. 244×1200.jpg
  245. 245×1050.jpg
  246. 246×1200.jpg
  247. 247×1080.jpg
  248. 248×1200.jpg
  249. 249×1440.jpg
  250. 250×1440.jpg
  251. 251×480.jpg
  252. 252×480.jpg
  253. 253×480.jpg
  254. 254×600.jpg
  255. 255×768.jpg
  256. 256×864.jpg
  257. 257×720.jpg
  258. 258×800.jpg
  259. 259×960.jpg
  260. 260×1024.jpg
  261. 261×900.jpg
  262. 262×1200.jpg
  263. 263×1050.jpg
  264. 264×1200.jpg
  265. 265×1080.jpg
  266. 266×1200.jpg
  267. 267×1440.jpg
  268. 268×1440.jpg
  269. 269
  270. 270
  271. 271
  272. 272×480.png
  273. 273×600.png
  274. 274×768.png
  275. 275×720.png
  276. 276×800.png
  277. 277×900.png
  278. 278×1050.png
  279. 279×1080.png
  280. 280×1200.png
  281. 281×1440.png
  282. 282×480.png
  283. 283×600.png
  284. 284×768.png
  285. 285×720.png
  286. 286×800.png
  287. 287×900.png
  288. 288×1050.png
  289. 289×1080.png
  290. 290×1200.png
  291. 291×1440.png
  292. 292
  293. 293
  294. 294
  295. 295×480.png
  296. 296×768.png
  297. 297×864.png
  298. 298×800.png
  299. 299×960.png
  300. 300×900.png
  301. 301×1200.png
  302. 302×1080.png
  303. 303×1440.png
  304. 304×480.png
  305. 305×768.png
  306. 306×864.png
  307. 307×800.png
  308. 308×960.png
  309. 309×900.png
  310. 310×1200.png
  311. 311×1080.png
  312. 312×1440.png
  313. 313
  314. 314
  315. 315
  316. 316×480.png
  317. 317×480.png
  318. 318×1136.png
  319. 319×1334.png
  320. 320×480.png
  321. 321×600.png
  322. 322×768.png
  323. 323×1024.png
  324. 324×864.png
  325. 325×2208.png
  326. 326×720.png
  327. 327×800.png
  328. 328×960.png
  329. 329×1024.png
  330. 330×768.png
  331. 331×1050.png
  332. 332×900.png
  333. 333×1200.png
  334. 334×1050.png
  335. 335×1200.png
  336. 336×1080.png
  337. 337×1200.png
  338. 338×1440.png
  339. 339×1440.png
  340. 340×1800.png
  341. 341×480.png
  342. 342×480.png
  343. 343×1136.png
  344. 344×1334.png
  345. 345×480.png
  346. 346×600.png
  347. 347×768.png
  348. 348×1024.png
  349. 349×864.png
  350. 350×2208.png
  351. 351×720.png
  352. 352×800.png
  353. 353×960.png
  354. 354×1024.png
  355. 355×768.png
  356. 356×1050.png
  357. 357×900.png
  358. 358×1200.png
  359. 359×1050.png
  360. 360×1200.png
  361. 361×1080.png
  362. 362×1200.png
  363. 363×1440.png
  364. 364×1440.png
  365. 365×1800.png
  366. 366
  367. 367
  368. 368
  369. 369×480.jpg
  370. 370×768.jpg
  371. 371×720.jpg
  372. 372×800.jpg
  373. 373×900.jpg
  374. 374×1200.jpg
  375. 375×1080.jpg
  376. 376×1200.jpg
  377. 377×1440.jpg
  378. 378×1800.jpg
  379. 379×480.jpg
  380. 380×768.jpg
  381. 381×720.jpg
  382. 382×800.jpg
  383. 383×900.jpg
  384. 384×1200.jpg
  385. 385×1080.jpg
  386. 386×1200.jpg
  387. 387×1440.jpg
  388. 388×1800.jpg
  389. 389
  390. 390
  391. 391
  392. 392×768.jpg
  393. 393×800.jpg
  394. 394×1024.jpg
  395. 395×768.jpg
  396. 396×900.jpg
  397. 397×900.jpg
  398. 398×1200.jpg
  399. 399×1080.jpg
  400. 400×1200.jpg
  401. 401×1440.jpg
  402. 402×768.jpg
  403. 403×800.jpg
  404. 404×1024.jpg
  405. 405×768.jpg
  406. 406×900.jpg
  407. 407×900.jpg
  408. 408×1200.jpg
  409. 409×1080.jpg
  410. 410×1200.jpg
  411. 411×1440.jpg
  412. 412
  413. 413
  414. 414
  415. 415×1280.png
  416. 416×1024.png
  417. 417×800.png
  418. 418×1024.png
  419. 419×768.png
  420. 420×900.png
  421. 421×1200.png
  422. 422×1050.png
  423. 423×1200.png
  424. 424×1080.png
  425. 425×1200.png
  426. 426×1440.png
  427. 427×1440.png
  428. 428×1280.png
  429. 429×1024.png
  430. 430×800.png
  431. 431×1024.png
  432. 432×768.png
  433. 433×900.png
  434. 434×1200.png
  435. 435×1050.png
  436. 436×1200.png
  437. 437×1080.png
  438. 438×1200.png
  439. 439×1440.png
  440. 440×1440.png
  441. 441
  442. 442
  443. 443
  444. 444×480.jpg
  445. 445×480.jpg
  446. 446×480.jpg
  447. 447×600.jpg
  448. 448×768.jpg
  449. 449×1024.jpg
  450. 450×864.jpg
  451. 451×720.jpg
  452. 452×800.jpg
  453. 453×960.jpg
  454. 454×1024.jpg
  455. 455×1050.jpg
  456. 456×900.jpg
  457. 457×1200.jpg
  458. 458×1050.jpg
  459. 459×1200.jpg
  460. 460×1080.jpg
  461. 461×1200.jpg
  462. 462×1440.jpg
  463. 463×1440.jpg
  464. 464×480.jpg
  465. 465×480.jpg
  466. 466×480.jpg
  467. 467×600.jpg
  468. 468×768.jpg
  469. 469×1024.jpg
  470. 470×864.jpg
  471. 471×720.jpg
  472. 472×800.jpg
  473. 473×960.jpg
  474. 474×1024.jpg
  475. 475×1050.jpg
  476. 476×900.jpg
  477. 477×1200.jpg
  478. 478×1050.jpg
  479. 479×1200.jpg
  480. 480×1080.jpg
  481. 481×1200.jpg
  482. 482×1440.jpg
  483. 483×1440.jpg
  484. 484
  485. 485
  486. 486
  487. 487×768.png
  488. 488×864.png
  489. 489×720.png
  490. 490×800.png
  491. 491×960.png
  492. 492×900.png
  493. 493×1200.png
  494. 494×1050.png
  495. 495×1200.png
  496. 496×1080.png
  497. 497×1200.png
  498. 498×1440.png
  499. 499×1440.png
  500. 500×768.png
  501. 501×864.png
  502. 502×720.png
  503. 503×800.png
  504. 504×960.png
  505. 505×900.png
  506. 506×1200.png
  507. 507×1050.png
  508. 508×1200.png
  509. 509×1080.png
  510. 510×1200.png
  511. 511×1440.png
  512. 512×1440.png
  513. 513
  514. 514
  515. 515
  516. 516×480.jpg
  517. 517×768.jpg
  518. 518×768.jpg
  519. 519×1080.jpg
  520. 520×1440.jpg
  521. 521×480.jpg
  522. 522×768.jpg
  523. 523×768.jpg
  524. 524×1080.jpg
  525. 525×1440.jpg
  526. 526
  527. 527
  528. 528
  529. 529×480.png
  530. 530×480.png
  531. 531×480.png
  532. 532×600.png
  533. 533×768.png
  534. 534×1024.png
  535. 535×864.png
  536. 536×720.png
  537. 537×800.png
  538. 538×960.png
  539. 539×1024.png
  540. 540×768.png
  541. 541×1050.png
  542. 542×900.png
  543. 543×1200.png
  544. 544×1050.png
  545. 545×1200.png
  546. 546×1080.png
  547. 547×1200.png
  548. 548×1440.png
  549. 549×1440.png
  550. 550×480.png
  551. 551×480.png
  552. 552×480.png
  553. 553×600.png
  554. 554×768.png
  555. 555×1024.png
  556. 556×864.png
  557. 557×720.png
  558. 558×800.png
  559. 559×960.png
  560. 560×1024.png
  561. 561×768.png
  562. 562×1050.png
  563. 563×900.png
  564. 564×1200.png
  565. 565×1050.png
  566. 566×1200.png
  567. 567×1080.png
  568. 568×1200.png
  569. 569×1440.png
  570. 570×1440.png
  571. 571
  572. 572
  573. 573
  574. 574×480.png
  575. 575×480.png
  576. 576×480.png
  577. 577×600.png
  578. 578×768.png
  579. 579×1024.png
  580. 580×864.png
  581. 581×720.png
  582. 582×800.png
  583. 583×960.png
  584. 584×1024.png
  585. 585×1050.png
  586. 586×900.png
  587. 587×1200.png
  588. 588×1050.png
  589. 589×1200.png
  590. 590×1080.png
  591. 591×1200.png
  592. 592×1440.png
  593. 593×1440.png
  594. 594×768.png
  595. 595×480.png
  596. 596×480.png
  597. 597×480.png
  598. 598×600.png
  599. 599×768.png
  600. 600×1024.png
  601. 601×864.png
  602. 602×720.png
  603. 603×800.png
  604. 604×960.png
  605. 605×1024.png
  606. 606×1050.png
  607. 607×900.png
  608. 608×1200.png
  609. 609×1050.png
  610. 610×1200.png
  611. 611×1080.png
  612. 612×1200.png
  613. 613×1440.png
  614. 614×1440.png
  615. 615×768.png
  616. 616
  617. 617
  618. 618
  619. 619×480.jpg
  620. 620×600.jpg
  621. 621×1024.jpg
  622. 622×768.jpg
  623. 623×1050.jpg
  624. 624×1200.jpg
  625. 625×1050.jpg
  626. 626×1200.jpg
  627. 627×1080.jpg
  628. 628×1200.jpg
  629. 629×1440.jpg
  630. 630×1440.jpg
  631. 631×480.jpg
  632. 632×600.jpg
  633. 633×1024.jpg
  634. 634×768.jpg
  635. 635×1050.jpg
  636. 636×1200.jpg
  637. 637×1050.jpg
  638. 638×1200.jpg
  639. 639×1080.jpg
  640. 640×1200.jpg
  641. 641×1440.jpg
  642. 642×1440.jpg
  643. 643
  644. 644
  645. 645
  646. 646×768.png
  647. 647×1050.png
  648. 648×900.png
  649. 649×1200.png
  650. 650×1050.png
  651. 651×1200.png
  652. 652×1020.png
  653. 653×1200.png
  654. 654×1440.png
  655. 655×1440.png
  656. 656×768.png
  657. 657×1050.png
  658. 658×900.png
  659. 659×1200.png
  660. 660×1050.png
  661. 661×1200.png
  662. 662×1020.png
  663. 663×1200.png
  664. 664×1440.png
  665. 665×1440.png
  666. 666

The post Desktop Wallpaper Calendars: June 2015 appeared first on Smashing Magazine.

Categories: Others Tags:

Pure Inspiration: 33 New and Award-Winning Websites

May 31st, 2015 No comments

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 […]

Categories: Others Tags:

Lining.js: Controlling Text Lines per CSS Selector

May 30th, 2015 No comments

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 […]

Categories: Others Tags:

How To Use Autoloading And A Plugin Container In WordPress Plugins

May 29th, 2015 No comments
Settings Page In Action

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.

Let’s Begin

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 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.

Folder Structure

First, create a directory named simplarity inside wp-content/plugins. Inside it create the following structure:

  • simplarity.php: our main plugin file
  • css/: directory containing our styles
  • js/: directory containing JavaScript files
  • languages/: directory that will contain translation files
  • src/: directory containing our classes
  • views/: directory that will contain our plugin view files

The Main Plugin File

Open the main plugin file, simplarity.php, and add the plugin information header:

Plugin Name: Simplarity
Description: A plugin for
Version: 1.0.0
License: GPL-2.0+

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:

require_once '/path/to/classes/class-container.php';
require_once '/path/to/classes/class-view.php';
require_once '/path/to/classes/class-settings-page.php';

$plugin = new Container();
$view = new View();
$settings_page = new SettingsPage();

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.

Adopting The PEAR Naming Convention For Class Names

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:

  • A class named Simplarity_Plugin would be defined in the file src/Simplarity/Plugin.php.
  • A class named Simplarity_SettingsPage would be defined in src/Simplarity/SettingsPage.php.

As you can see with this convention, the autoloader will just replace the underscores with directory separators to locate the class definition.

What About The WordPress Coding Standards For Class Names?

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.php

I know that we should follow the standards of the platform that we are developing on. However, we suggest using the PEAR naming convention because:

  • WP coding standards do not cover autoloading.
  • WP does not follow its own coding standards. Examples: class.wp-scripts.php and SimplePie. This is understandable since WordPress grew organically.
  • Interoperability allows you to easily use third-party libraries that follow the PEAR naming convention, like Twig. And conversely, you can easily port your code to other libraries sharing the same convention.
  • It’s important your autoloader is future-ready. When WordPress decides to up the ante and finally move to PHP 5.3 as its minimum requirement, you can easily update the code to be PSR-0 or PSR-4-compatible and take advantage of the built-in namespaces instead of using prefixes. This is a big plus for interoperability.

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.

Building Our Autoloader

Open our main plugin file and add the following code below the plugin information header:

spl_autoload_register( 'simplarity_autoloader' );
function simplarity_autoloader( $class_name ) {
  if ( false !== strpos( $class_name, 'Simplarity' ) ) {
    $classes_dir = realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR;
    $class_file = str_replace( '_', DIRECTORY_SEPARATOR, $class_name ) . '.php';
    require_once $classes_dir . $class_file;

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:

spl_autoload_register( 'simplarity_autoloader' );

Next we define the simplarity_autoloader function:

function simplarity_autoloader( $class_name ) {

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:

if ( false !== strpos( $class_name, 'Simplarity' ) ) {

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:

$classes_dir = realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR;

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:

$class_file = str_replace( '_', DIRECTORY_SEPARATOR, $class_name ) . '.php';

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:

require_once $classes_dir . $class_file;

That’s it! You now have an autoloader. Say goodbye to long lines of require_once statements.

Plugin Container

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.

Uses Of Our Plugin Container

Here are the things we can expect from the plugin container:

  • Store global parameters in a single location

    Often you’ll find this code in plugins:

    define( 'SIMPLARITY_VERSION', '1.0.0' );
    define( 'SIMPLARITY_PATH', realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR );
    define( 'SIMPLARITY_URL', plugin_dir_url( __FILE__ ) );

    Instead of doing that, we could do this instead:

    $plugin = new Simplarity_Plugin();
    $plugin['version] = '1.0.0';
    $plugin['path'] = realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR;
    $plugin['url'] = plugin_dir_url( __FILE__ );

    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.

  • Store objects in a single location

    Instead of scattering our class instantiations everywhere in our codebase we can just do this in a single location:

    $plugin = new Simplarity_Plugin();
    $plugin['scripts'] = new Simplarity_Scripts(); // A class that loads javascript files
  • Service definitions

    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.

    $plugin['settings_page'] = function ( $plugin ) {
      return new SettingsPage( $plugin['settings_page_properties'] );

    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:

    $plugin = new Plugin();
    $plugin['door_width'] = 100;
    $plugin['door_height'] = 500;
    $plugin['door_size'] = function ( $plugin ) {
      return new DoorSize( $plugin['door_width'], $plugin['door_height'] );
    $plugin['door'] = function ( $plugin ) {
      return new Door( $plugin['door_size'] );
    $plugin['window'] = function ( $plugin ) {
      return new Window();
    $plugin['house'] = function ( $plugin ) {
      return new House( $plugin['door'], $plugin['window'] );
    $house = $plugin['house'];

    This is roughly equivalent to:

    $door_width = 100;
    $door_height = 500;
    $door_size = new DoorSize( $door_width, $door_height );
    $door = new Door( $door_size );
    $window = new Window();
    $house = new House( $door, $window );

    Whenever we get an object, as in $house = $plugin['house']; , the object is created (lazy initialization) and dependencies are resolved automatically.

Building The Plugin Container

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:

class Simplarity_Plugin implements ArrayAccess {
  protected $contents;
  public function __construct() {
    $this->contents = array();
  public function offsetSet( $offset, $value ) {
    $this->contents[$offset] = $value;

  public function offsetExists($offset) {
    return isset( $this->contents[$offset] );

  public function offsetUnset($offset) {
    unset( $this->contents[$offset] );

  public function offsetGet($offset) {
    if( is_callable($this->contents[$offset]) ){
      return call_user_func( $this->contents[$offset], $this );
    return isset( $this->contents[$offset] ) ? $this->contents[$offset] : null;
  public function run(){ 
    foreach( $this->contents as $key => $content ){ // Loop on contents
      if( is_callable($content) ){
        $content = $this[$key];
      if( is_object( $content ) ){
        $reflection = new ReflectionClass( $content );
        if( $reflection->hasMethod( 'run' ) ){
          $content->run(); // Call run method on object

The class implements the ArrayAccess interface:

class Simplarity_Plugin implements ArrayAccess {

This allows us to use it like PHP’s array:

$plugin = new Simplarity_Plugin();
$plugin['version'] = '1.0.0'; // Simplicity is beauty

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.

Example Plugin: A Settings Page

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:

add_action( 'plugins_loaded', 'simplarity_init' ); // Hook initialization function
function simplarity_init() {
  $plugin = new Simplarity_Plugin(); // Create container
  $plugin['path'] = realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR;
  $plugin['url'] = plugin_dir_url( __FILE__ );
  $plugin['version'] = '1.0.0';
  $plugin['settings_page_properties'] = array( 
    'parent_slug' => 'options-general.php',
    'page_title' =>  'Simplarity',
    'menu_title' =>  'Simplarity',
    'capability' => 'manage_options',
    'menu_slug' => 'simplarity-settings',
    'option_group' => 'simplarity_option_group',
    'option_name' => 'simplarity_option_name'
  $plugin['settings_page'] = new Simplarity_SettingsPage( $plugin['settings_page_properties'] );

Here we use WP’s add_action to hook our function simplarity_init into plugins_loaded:

add_action( 'plugins_loaded', 'simplarity_init' );

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:

$plugin = new Simplarity_Plugin();

These lines assign global configuration data:

$plugin['path'] = realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR;
$plugin['url'] = plugin_dir_url( __FILE__ );
$plugin['version'] = '1.0.0';

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:

$plugin['settings_page_properties'] = array(
  'parent_slug' => 'options-general.php',
  'page_title' =>  'Simplarity',
  'menu_title' =>  'Simplarity',
  'capability' => 'manage_options',
  'menu_slug' => 'simplarity-settings',
  'option_group' => 'simplarity_option_group',
  'option_name' => 'simplarity_option_name'

These configuration data are related to WP settings API10.

This next code instantiates the settings page, passing along settings_page_properties:

$plugin['settings_page'] = new Simplarity_SettingsPage( $plugin['settings_page_properties'] );

The run method is where the fun starts:


It will call Simplarity_SettingsPage‘s own run method.

The Simplarity_SettingsPage Class

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:

class Simplarity_SettingsPage {
  protected $settings_page_properties;

  public function __construct( $settings_page_properties ){
    $this->settings_page_properties = $settings_page_properties;

  public function run() {
    add_action( 'admin_menu', array( $this, 'add_menu_and_page' ) );
    add_action( 'admin_init', array( $this, 'register_settings' ) );

  public function add_menu_and_page() { 

      array( $this, 'render_settings_page' )
  public function register_settings() { 
  public function get_settings_data(){
    return get_option( $this->settings_page_properties['option_name'], $this->get_default_settings_data() );
  public function render_settings_page() {
    $option_name = $this->settings_page_properties['option_name'];
    $option_group = $this->settings_page_properties['option_group'];
    $settings_data = $this->get_settings_data();
    <div class="wrap">
      <p>This plugin is using the settings API.</p>
      <form method="post" action="options.php">
        settings_fields( $this->plugin['settings_page_properties']['option_group']);
        <table class="form-table">
              <th><label for="textbox">Textbox:</label></th>
                <input type="text" id="textbox"
                  name="<?php echo esc_attr( $option_name."[textbox]" ); ?>"
                  value="<?php echo esc_attr( $settings_data['textbox'] ); ?>" />
        <input type="submit" name="submit" id="submit" class="button button-primary" value="Save Options">
  public function get_default_settings_data() {
    $defaults = array();
    $defaults['textbox'] = '';
    return $defaults;

The class property $settings_page_properties stores the settings related to WP settings API:

class Simplarity_SettingsPage {
  protected $settings_page_properties;

The constructor function accepts the settings_page_properties and stores it:

public function __construct( $settings_page_properties ){
  $this->settings_page_properties = $settings_page_properties;

The values are passed from this line in the main plugin file:

$plugin['settings_page'] = new Simplarity_SettingsPage( $plugin['settings_page_properties'] );

The run function is use to run startup code:

public function run() {
  add_action( 'admin_menu', array( $this, 'add_menu_and_page' ) );
  add_action( 'admin_init', array( $this, 'register_settings' ) );

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:

add_action( 'admin_menu', array( $this, 'add_menu_and_page' ) );

Function add_submenu_page in turn calls WP’s add_submenu_page13 function to add a link under the WP Admin ? Settings:

public function add_menu_and_page() { 

    array( $this, 'render_settings_page' )


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:

  • parent_slug: slug name for the parent menu
  • page_title: text to be displayed in the </code> element of the page when the menu is selected</li> <li><code>menu_title</code>: text to be used for the menu</li> <li><code>capability</code>: the capability required for this menu to be displayed to the user</li> <li><code>menu_slug</code>: slug name to refer to this menu by (should be unique for this menu)</li> <li><code>function</code>: function to be called to output the content for this page</li> </ul> <p>This line hooks the <code>register_settings</code> function on to the <code>admin_init</code> action:</p> <pre><code>add_action( 'admin_init', array( $this, 'register_settings' ) );</code></pre> <p><code>array( $this, 'register_settings' )</code> means to call <code>register_settings</code> on <code>$this</code>, which points to our <code>SettingsPage</code> instance.</p> <p>The <code>register_settings</code> then calls WP’s <code>register_setting</code> to register a setting:</p> <pre><code>public function register_settings() { register_setting( $this->settings_page_properties['option_group'], $this->settings_page_properties['option_name'] ); }</code></pre> <p>Function <code>render_settings_page</code> is responsible for rendering the page:</p> <pre><code>public function render_settings_page() { $option_name = $this->settings_page_properties['option_name']; $option_group = $this->settings_page_properties['option_group']; $settings_data = $this->get_settings_data(); ?> <div class="wrap"> <h2>Simplarity</h2> <p>This plugin is using the settings API.</p> <form method="post" action="options.php"> <?php settings_fields( $option_group ); ?> <table class="form-table"> <tr> <th><label for="textbox">Textbox:</label></th> <td> <input type="text" id="textbox" name="<?php echo esc_attr( $option_name."[textbox]" ); ?>" value="<?php echo esc_attr( $settings_data['textbox'] ); ?>" /> </td> </tr> </table> <input type="submit" name="submit" id="submit" class="button button-primary" value="Save Options"> </form> </div> <?php }</code></pre> <p>We hooked <code>render_settings_page</code> earlier using <code>add_submenu_page</code>.</p> <p>Function <code>get_settings_data</code> is a wrapper function for <code>get_option</code>:</p> <pre><code>public function get_settings_data(){ return get_option( $this->plugin['settings_page_properties']['option_name'] ); }</code></pre> <p>This is to easily get the settings data with a single function call.</p> <p>Function <code>get_default_settings_data</code> is use to supply us with our own default values:</p> <pre><code>public function get_default_settings_data() { $defaults = array(); $defaults['textbox'] = ''; return $defaults; }</code></pre> <h3>Abstracting Our Settings Page Class</h3> <p>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.</p> <p>Let’s call this class <code>Simplarity_WpSubPage</code>. Go ahead and create the file <i>src/Simplarity/WpSubPage.php</i>.</p> <p>Now add the code below:</p> <pre><code><?php abstract class Simplarity_WpSubPage { protected $settings_page_properties; public function __construct( $settings_page_properties ){ $this->settings_page_properties = $settings_page_properties; } public function run() { add_action( 'admin_menu', array( $this, 'add_menu_and_page' ) ); add_action( 'admin_init', array( $this, 'register_settings' ) ); } public function add_menu_and_page() { add_submenu_page( $this->settings_page_properties['parent_slug'], $this->settings_page_properties['page_title'], $this->settings_page_properties['menu_title'], $this->settings_page_properties['capability'], $this->settings_page_properties['menu_slug'], array( $this, 'render_settings_page' ) ); } public function register_settings() { register_setting( $this->settings_page_properties['option_group'], $this->settings_page_properties['option_name'] ); } public function get_settings_data(){ return get_option( $this->settings_page_properties['option_name'], $this->get_default_settings_data() ); } public function render_settings_page(){ } public function get_default_settings_data() { $defaults = array(); return $defaults; } } </code></pre> <p>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 <code>Simplarity_SettingsPage</code>:</p> <pre><code><?php class Simplarity_SettingsPage extends Simplarity_WpSubPage { public function render_settings_page() { $option_name = $this->settings_page_properties['option_name']; $option_group = $this->settings_page_properties['option_group']; $settings_data = $this->get_settings_data(); ?> <div class="wrap"> <h2>Simplarity</h2> <p>This plugin is using the settings API.</p> <form method="post" action="options.php"> <?php settings_fields( $option_group ); ?> <table class="form-table"> <tr> <th><label for="textbox">Textbox:</label></th> <td> <input type="text" id="textbox" name="<?php echo esc_attr( $option_name."[textbox]" ); ?>" value="<?php echo esc_attr( $settings_data['textbox'] ); ?>" /> </td> </tr> </table> <input type="submit" name="submit" id="submit" class="button button-primary" value="Save Options"> </form> </div> <?php } public function get_default_settings_data() { $defaults = array(); defaults['textbox'] = ''; return $defaults; } } </code></pre> <p>The only functions we have implemented are <code>render_settings_page</code> and <code>get_default_settings_data</code>, which are customized to this settings page.</p> <p>To create another WP settings page you’ll just need to create a class and extend the <code>Simplarity_WpSubPage</code>. And implement your own <code>render_settings_page</code> and <code>get_default_settings_data</code>.</p> <h3>Defining A Service</h3> <p>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.</p> <p>To better illustrate this, let’s define a service for our settings page.</p> <p>Open <i>simplarity.php</i> and add this function below the Simplarity code:</p> <pre><code>function simplarity_service_settings( $plugin ){ $object = new Simplarity_SettingsPage( $plugin['settings_page_properties'] ); return $object; }</code></pre> <p>Notice that our service function has a <code>$plugin</code> 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 <code>Simplarity_SettingsPage</code> has a dependency on <code>$plugin['settings_page_properties']</code>. We inject this dependency to <code>Simplarity_SettingsPage</code> 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.</p> <p>Now let’s replace this line in <code>simplarity_init</code>:</p> <pre><code>$plugin['settings_page'] = new Simplarity_SettingsPage( $plugin['settings_page_properties'] );</code></pre> <p>with a service definition assignment:</p> <pre><code>$plugin['settings_page'] = 'simplarity_service_settings'</code></pre> <p>So instead of assigning our object instance directly, we assign the name of our function as string. Our container handles the rest. </p> <h3>Defining A Shared Service</h3> <p>Right now, every time we get <code>$plugin['settings_page']</code>, a new instance of <code>Simplarity_SettingsPage</code> is returned. Ideally, <code>Simplarity_SettingsPage</code> should only be instantiated once as we are using WP hooks, which in turn should only be registered once.</p> <p>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.</p> <p>Let’s create a shared service using a static variable:</p> <pre><code>function simplarity_service_settings( $plugin ){ static $object; if (null !== $object) { return $object; } $object = new Simplarity_SettingsPage( $plugin['settings_page_properties'] ); return $object; }</code></pre> <p>On first call, <code>$object</code> 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.</p> <p>That’s it.</p> <p>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.</p> <figure><sup><a class="colorbox" href="">14</a></sup><br /><figcaption>Settings Page In Action</figcaption></figure> <h3>The Future: PHP 5.3+</h3> <p>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.</p> <h4>Namespaces</h4> <p>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.</p> <p>With namespaces you can have the same class names as long as they live in their own namespace. A good analogy 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.</p> <p>With namespaces, class and function names won’t need unique prefixes anymore.</p> <h4>Anonymous Functions</h4> <p>Anonymous functions, also known as <strong>closures</strong>, 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.</p> <p>Here’s an example of closure:</p> <pre><code><?php $greet = function($name) { printf("Hello %srn", $name); }; $greet('World'); $greet('PHP');</code></pre> <h3>Using Namespaces In Classes</h3> <p>Let’s go ahead and use namespaces in our class definitions. Open up the following files in <i>src/Simplarity:</i></p> <ul> <li><i>Plugin.php</i></li> <li><i>SettingsPage.php</i></li> <li><i>WpSubPage.php</i></li> </ul> <p>In each of these files, add a namespace declaration on top and remove the “Simplarity_” prefix on class names:</p> <pre><code>// Plugin.php namespace Simplarity; class Plugin { ... // SettingsPage.php namespace Simplarity; class SettingsPage extends WpSubPage { ... // WpSubPage.php namespace Simplarity; abstract class WpSubPage { ... </code></pre> <p>Since we have updated our class names we also need to update our class instantiations in <i>simplarity.php</i>. We do this by deleting the prefixes:</p> <pre><code>function simplarity_init() { $plugin = new Plugin(); ... } ... function simplarity_service_settings( $plugin ){ ... $object = new SettingsPage( $plugin['settings_page_properties'] ); return $object; } </code></pre> <p>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 <i>simplarity.php</i> just above the autoloader code:</p> <pre><code>use SimplarityPlugin; use SimplaritySettingsPage; </code></pre> <p>This is called importing/aliasing with the <a class="colorbox" href="">use operator</a><sup><a class="colorbox" href="">15</a></sup>.</p> <h3>Updating The Autoloader</h3> <p>Open up <i>simplarity.php</i> and change this line in the autoloader from:</p> <pre><code>$class_file = str_replace( '_', DIRECTORY_SEPARATOR, $class_name ) . '.php';</code></pre> <p>to:</p> <pre><code>$class_file = str_replace( '', DIRECTORY_SEPARATOR, $class_name ) . '.php';</code></pre> <p>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: “”.</p> <h3>Updating Our Service Definitions To Use Anonymous Functions</h3> <p>We can now replace the global functions we created for our service definitions with anonymous functions. So instead of doing this:</p> <pre><code>function simplarity_init() { ... $plugin['settings_page'] = 'simplarity_service_settings'; ... } ... function simplarity_service_settings( $plugin ){ static $object; if (null !== $object) { return $object; } $object = new Simplarity_SettingsPage( $plugin['settings_page_properties'] ); return $object; }</code></pre> <p>we can just replace this with an inline anonymous function:</p> <pre><code>function simplarity_init() { $plugin = new Plugin(); ... $plugin['settings_page'] = function ( $plugin ) { static $object; if (null !== $object) { return $object; } return new SettingsPage( $plugin['settings_page_properties'] ); }; ... } </code></pre> <h3>Using Pimple As A Plugin Container</h3> <p>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.</p> <p>Download <a class="colorbox" href="">Pimple container from GitHub</a><sup><a class="colorbox" href="">16</a></sup> and save it in <i>src/Simplarity/Pimple.php</i>.</p> <p>Open up <i>Pimple.php</i> and replace the namespace and the classname to:</p> <pre><code>... namespace Simplarity; /** * Container main class. * * @author Fabien Potencier */ class Pimple implements ArrayAccess ... </code></pre> <p>Open up <i>Plugin.php</i> and replace all the code with:</p> <pre><code><?php namespace Simplarity; class Plugin extends Pimple { public function run(){ foreach( $this->values as $key => $content ){ // Loop on contents $content = $this[$key]; if( is_object( $content ) ){ $reflection = new ReflectionClass( $content ); if( $reflection->hasMethod( 'run' ) ){ $content->run(); // Call run method on object } } } } } </code></pre> <p>Now let’s change the service definition in <i>simplarity.php</i> to:</p> <pre><code>$plugin['settings_page'] = function ( $plugin ) { return new SettingsPage( $plugin['settings_page_properties'] ); }; </code></pre> <p>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 <code>factory()</code> method:</p> <pre><code>$plugin['image_resizer'] = $plugin->factory(function ( $plugin ) { return new ImageResizer( $plugin['image_dir'] ); }); </code></pre> <h3>Conclusion</h3> <p>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.</p> <h4>Code Samples</h4> <ul> <li><a class="colorbox" href="">Simplarity: settings page</a><sup><a class="colorbox" href="">17</a></sup></li> <li><a class="colorbox" href="">Simplarity: settings page (PHP5.3+)</a><sup><a class="colorbox" href="">18</a></sup></li> </ul> <h4>Resources</h4> <ul> <li><a class="colorbox" href="">PEAR naming standards</a><sup><a class="colorbox" href="">19</a></sup></li> <li><a class="colorbox" href="">Namespaces explanation</a><sup><a class="colorbox" href="">20</a></sup></li> <li><a class="colorbox" href="">Pimple (a small DI container)</a><sup><a class="colorbox" href="">21</a></sup></li> </ul> <p><em>(dp, og, il)</em></p> <h4>Footnotes</h4> <ol> <li><a class="colorbox" href="">1</a></li> <li><a class="colorbox" href="">2</a></li> <li><a class="colorbox" href="">3</a></li> <li><a class="colorbox" href="">4</a></li> <li><a class="colorbox" href="">5</a></li> <li><a class="colorbox" href="">6</a></li> <li><a class="colorbox" href="">7</a></li> <li><a class="colorbox" href="">8</a></li> <li><a class="colorbox" href="">9</a></li> <li><a class="colorbox" href="">10</a></li> <li><a class="colorbox" href="">11</a></li> <li><a class="colorbox" href="">12</a></li> <li><a class="colorbox" href="">13</a></li> <li><a class="colorbox" href="">14</a></li> <li><a class="colorbox" href="">15</a></li> <li><a class="colorbox" href="">16</a></li> <li><a class="colorbox" href="">17</a></li> <li><a class="colorbox" href="">18</a></li> <li><a class="colorbox" href="">19</a></li> <li><a class="colorbox" href="">20</a></li> <li><a class="colorbox" href="">21</a></li> </ol> <p>The post <a class="colorbox" rel="nofollow" href="">How To Use Autoloading And A Plugin Container In WordPress Plugins</a> appeared first on <a class="colorbox" rel="nofollow" href="">Smashing Magazine</a>.</p> <div class="fixed"></div> </div> <div class="under"> <span class="categories">Categories: </span><span><a href="" rel="category tag">Others</a></span> <span class="tags">Tags: </span><span></span> </div> </div> <div class="post" id="post-32228"> <h2><a class="title" href="" rel="bookmark">How Does Google’s New Ranking Factor Mobile-Friendly Affect Your Website?</a></h2> <div class="info"> <span class="date">May 29th, 2015</span> <span class="author"></span> <span class="comments"><a href="">No comments</a></span> <div class="fixed"></div> </div> <div class="content"> <div class="ftpimagefix" style="float:left"><a class="colorbox" href=""></a></div> <p>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, […]</p> <div> <div><span>*</span> You might also be interested in the following articles:</div> <ul> <li><a class="colorbox" href="">Is your Responsive Design Mobile Website Delivering Acceptable Load…</a></li> <li><a class="colorbox" href=""></a><a class="colorbox" href="">Google Web Fundamentals: Free Handbook for Multi-Device Web Design in…</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="Advertising For Mobile On The Rise [Infographic]" title="Advertising For Mobile On The Rise [Infographic]" width="250" height="200"></a><a class="colorbox" href="">Advertising For Mobile On The Rise [Infographic]</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="ReView.js Changes Viewports In Responsive Designs With a Single Mouse Click" title="ReView.js Changes Viewports In Responsive Designs With a Single Mouse Click" width="250" height="200"></a><a class="colorbox" href="">ReView.js Changes Viewports In Responsive Designs With a Single Mouse…</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="Leaflet: Interactive Maps with JavaScript and OpenStreetMap" title="Leaflet: Interactive Maps with JavaScript and OpenStreetMap" width="250" height="200"></a><a class="colorbox" href="">Leaflet: Interactive Maps with JavaScript and OpenStreetMap</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="The Truth about WordPress Performance [#1/2]" title="The Truth about WordPress Performance [#1/2]" width="250" height="200"></a><a class="colorbox" href="">The Truth about WordPress Performance [#1/2]</a></li> </ul> <div></div> </div> <div class="fixed"></div> </div> <div class="under"> <span class="categories">Categories: </span><span><a href="" rel="category tag">Others</a></span> <span class="tags">Tags: </span><span></span> </div> </div> <div class="post" id="post-31912"> <h2><a class="title" href="" rel="bookmark">What You Need to Know About the Latest HTML5 Video</a></h2> <div class="info"> <span class="date">May 28th, 2015</span> <span class="author"></span> <span class="comments"><a href="">No comments</a></span> <div class="fixed"></div> </div> <div class="content"> <div class="ftpimagefix" style="float:left"><a class="colorbox" href=""></a></div> <p>Ever wanted to create your own 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 […]</p> <div> <div><span>*</span> You might also be interested in the following articles:</div> <ul> <li><a class="colorbox" href="">Big Time Saver: Becoming a WordPress Pro (Near-)Instantly</a></li> <li><a class="colorbox" href=""></a><a class="colorbox" href="">JavaScript: Using Closure Space to Create Real Private Members</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="Lord Of The Rings: Ringmark Checks Mobile Browsers For HTML5 Capability" title="Lord Of The Rings: Ringmark Checks Mobile Browsers For HTML5 Capability" width="250" height="200"></a><a class="colorbox" href="">Lord Of The Rings: Ringmark Checks Mobile Browsers For HTML5…</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="Time Lapse Videos: How to Quicken the Pace of Your Movies" title="Time Lapse Videos: How to Quicken the Pace of Your Movies" width="250" height="200"></a><a class="colorbox" href="">Time Lapse Videos: How to Quicken the Pace of Your Movies</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="Hands-On: Build a Node.js-powered Chatroom Web App (Part Two)" title="Hands-On: Build a Node.js-powered Chatroom Web App (Part Two)" width="250" height="200"></a><a class="colorbox" href="">Hands-On: Build a Node.js-powered Chatroom Web App (Part Two)</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="Essential: How to Test Internet Explorer on Android, iOS, and Mac OS X" title="Essential: How to Test Internet Explorer on Android, iOS, and Mac OS X" width="250" height="200"></a><a class="colorbox" href="">Essential: How to Test Internet Explorer on Android, iOS, and Mac OS X</a></li> </ul> <div></div> </div> <div class="fixed"></div> </div> <div class="under"> <span class="categories">Categories: </span><span><a href="" rel="category tag">Others</a></span> <span class="tags">Tags: </span><span></span> </div> </div> <div class="post" id="post-57103"> <h2><a class="title" href="" rel="bookmark">Adopting the Simulation Mindset in Design</a></h2> <div class="info"> <span class="date">May 27th, 2015</span> <span class="author"><a href="" title="Posts by admin" rel="author">admin</a></span> <span class="comments"><a href="">No comments</a></span> <div class="fixed"></div> </div> <div class="content"> <p>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.</p> <p>I like to use the analogy 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. </p> <p>I found it therefore interesting when <a target="_blank" href="" target="_blank">Ken Rosen explains</a> (perhaps oversimplifying) how the differences of the Airbus A380 and the Boeing 787 could have been better determined through a simulation mindset. </p> <blockquote> <p>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.</p> </blockquote> <p>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.</p> <div> <div> <ul> <li data-position="0" data-poid="in-7586" data-post-type="none"><a target="_blank" href="">Get your Elevator Pitch right for your Design Strategy to Work</a></li> <li data-position="1" data-poid="in-7634" data-post-type="none"><a target="_blank" href="">A Guide to Experience Maps</a></li> <li data-position="2" data-poid="in-7676" data-post-type="none"><a target="_blank" href="">What is the Value of Design?</a></li> <li data-position="3" data-poid="in-7120" data-post-type="none"><a target="_blank" href="">Why Nobody can Copy Apple</a></li> <li data-position="4" data-poid="in-7123" data-post-type="none"><a target="_blank" href="">Silent Design is Design without Designers</a></li> </ul> </div> </div> <div> </div> <div class="fixed"></div> </div> <div class="under"> <span class="categories">Categories: </span><span><a href="" rel="category tag">Designing</a>, <a href="" rel="category tag">Others</a></span> <span class="tags">Tags: </span><span></span> </div> </div> <div class="post" id="post-31598"> <h2><a class="title" href="" rel="bookmark">Back to the Roots: Hand-Made Typography</a></h2> <div class="info"> <span class="date">May 27th, 2015</span> <span class="author"></span> <span class="comments"><a href="">No comments</a></span> <div class="fixed"></div> </div> <div class="content"> <div class="ftpimagefix" style="float:left"><a class="colorbox" href=""></a></div> <p>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 […]</p> <div> <div><span>*</span> You might also be interested in the following articles:</div> <ul> <li><a class="colorbox" href="">Incredible Typography: 28 Sculptural Fonts (Showcase)</a></li> <li><a class="colorbox" href=""></a><a class="colorbox" href="">World of Design No. 2: New Zealand</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="IM FREE: Curated Collections of Free Commercial Use Photos No Designer Can Do Without" title="IM FREE: Curated Collections of Free Commercial Use Photos No Designer Can Do Without" width="250" height="200"></a><a class="colorbox" href="">IM FREE: Curated Collections of Free Commercial Use Photos No Designer</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="Sky's The Limit: 40 Fresh and Free Photoshop Text Effects" title="Sky's The Limit: 40 Fresh and Free Photoshop Text Effects" width="250" height="200"></a><a class="colorbox" href="">Sky’s The Limit: 40 Fresh and Free Photoshop Text Effects</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="Boring Work Made Easy: Free Templates for Creating Manuals" title="Boring Work Made Easy: Free Templates for Creating Manuals" width="250" height="200"></a><a class="colorbox" href="">Boring Work Made Easy: Free Templates for Creating Manuals</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="Late-breaking: 29 Free Vibrant Flat UI Packs" title="Late-breaking: 29 Free Vibrant Flat UI Packs" width="250" height="200"></a><a class="colorbox" href="">Late-breaking: 29 Free Vibrant Flat UI Packs</a></li> </ul> <div></div> </div> <div class="fixed"></div> </div> <div class="under"> <span class="categories">Categories: </span><span><a href="" rel="category tag">Others</a></span> <span class="tags">Tags: </span><span></span> </div> </div> <div class="post" id="post-32462"> <h2><a class="title" href="" rel="bookmark">The Art Of The SVG Filter And Why It Is Awesome</a></h2> <div class="info"> <span class="date">May 26th, 2015</span> <span class="author"></span> <span class="comments"><a href="">No comments</a></span> <div class="fixed"></div> </div> <div class="content"> <div class="ftpimagefix" style="float:left"><a class="colorbox" href=""><img decoding="async" src="" alt="A filter that creates a liquid effect." title="A filter that creates a liquid effect."></a></div> <p>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 <strong>there’s still one field of graphic design where we still constantly fall back</strong> to bitmap replacements instead of using native text: display typography, the art of staging letters in illustrative, gorgeous, dramatic, playful, experimental or unexpected ways.</p> <figure><sup><a class="colorbox" href="">1</a></sup><br /><figcaption>Liquid type effect (<a class="colorbox" href="">demo</a><sup><a class="colorbox" href="">2</a></sup>)</figcaption></figure> <h3>A Case For Display Text In HTML</h3> <p>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 <code>background-clip</code> and <code>text-stroke</code>), but that’s basically it. If we want really outstanding display typography on our websites, we’ll usually embed it as an image.</p> <figure><a class="colorbox" href=""></a><sup><a class="colorbox" href="">3</a></sup><br /><figcaption>Woodtype, a style created purely with SVG filters (<a class="colorbox" href="">demo</a><sup><a class="colorbox" href="">4</a></sup>)</figcaption></figure> <p>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.</p> <p>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?</p> <h3>Sophisticated SVG Filters: CSS For Type</h3> <p>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 <code>filter</code> property, these effects can be used outside of SVG and be applied directly to HTML content.</p> <figure><a class="colorbox" href=""><img decoding="async" src="" width="500" alt="A 3D vintage effect" title="A 3D vintage effect"></a><sup><a class="colorbox" href="">5</a></sup><br /><figcaption>3D vintage effect (<a class="colorbox" href="">demo</a><sup><a class="colorbox" href="">6</a></sup>)</figcaption></figure> <p>Talking about filters in CSS and SVG can be a bit confusing: SVG filters are defined in an SVG <code>filter</code> element and are usually applied within an SVG document. CSS filters can be applied to any HTML element via the <code>filter</code> property. CSS filters such as <code>blur</code>, <code>contrast</code> and <code>hue-rotate</code> are shortcuts for predefined, frequently used SVG filter effects. Beyond that, <a class="colorbox" href="" title="CSS3 Filter Modules at the W3C">the specification</a><sup><a class="colorbox" href="">7</a></sup> allows us to reference user-defined filters from within an SVG. A further point of confusion is the proprietary <code>-ms-</code> <code>filter</code> tag, which was deprecated in Internet Explorer (IE) 9 and removed when IE 10 was released.</p> <p>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.</p> <figure><a class="colorbox" href=""><img decoding="async" src="" alt="Using feImage to fill text with a repeating pattern" title="Using feImage to fill text with a repeating pattern"></a><sup><a class="colorbox" href="">8</a></sup><br /><figcaption>Using <code>feImage</code> to fill text with a repeating pattern (<a class="colorbox" href="">demo</a><sup><a class="colorbox" href="">9</a></sup>)</figcaption></figure> <p>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.</p> <figure><a class="colorbox" href=""><img decoding="async" src="" alt="Applying a sketch effect to text" title="Applying a sketch effect to text"></a><sup><a class="colorbox" href="">10</a></sup><br /><figcaption>A sketchy text effect (<a class="colorbox" href="">demo</a><sup><a class="colorbox" href="">11</a></sup>)</figcaption></figure> <p>Understanding SVG filters is challenging. Even simple effects like drop-shadows require a complicated, verbose syntax. Some filers, such as <code>feColorMatrix</code> and <code>feComposite</code>, 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 <strong>building blocks</strong> 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.</p> <figure><a class="colorbox" href=""><img decoding="async" src="" alt="Variations of posterized text effects" title="Variations of posterized text effects"></a><sup><a class="colorbox" href="">12</a></sup><br /><figcaption>Some variations of posterized text effects (<a class="colorbox" href="">demo</a><sup><a class="colorbox" href="">13</a></sup>)</figcaption></figure> <h3>Constructing A Filter</h3> <p>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:</p> <figure><a class="colorbox" href=""><img decoding="async" src="" alt="Making text look grungy" title="Making text look grungy"></a><sup><a class="colorbox" href="">14</a></sup><br /><figcaption>A grungy wall painting (<a class="colorbox" href="">demo</a><sup><a class="colorbox" href="">15</a></sup>)</figcaption></figure> <p>Let’s break down this effect into its building blocks:</p> <ol> <li>green text;</li> <li>red extrusion;</li> <li>text and extrusion are separated by a transparent gap;</li> <li>text has a grungy, weathered look.</li> </ol> <p>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:</p> <figure><img decoding="async" src="" width="500" alt="Image of an SVG filter graph" title="Image of an SVG filter graph"><figcaption>The processing steps that make up a sophisticated filter are illustrated best in a graph.</figcaption></figure> <h4>Adding A Filter</h4> <p>We’ll start with a boilerplate SVG that contains an empty filter and text:</p> <pre><code><svg version="1.1" id="Ebene_1" xmlns="" xmlns:xlink=""> <defs> <style type="text/css"> <![CDATA[ .filtered{ filter: url(#myfilter); … } ]]> </style> <filter id="myfilter"> <!-- filter stuff happening here --> </filter> </defs> <g class="filtered"> <text x="0" y="200" transform="rotate(-12)">Petrol</text> </g> </svg> </code></pre> <h4>The filter Element</h4> <p>We have to start somewhere, and the <code>filter</code> 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.</p> <p>A handful of attributes exist to control the <code>filter</code> element:</p> <ul> <li>x and y positions (default -10%);</li> <li>width and height (default 120%);</li> <li>an ID, which is necessary to refer to later on;</li> <li><code>filterRes</code>, which predefines a resolution (deprecated with the “<a class="colorbox" href="" title="CSS3 Filter Modules at the W3C">Filter Effects Module Level 1</a><sup><a class="colorbox" href="">16</a></sup>” specification);</li> <li>relative (<code>objectBoundingBox</code> is the default) or absolute (<code>userSpaceOnUse</code>) <code>filterUnits</code>.</li> </ul> <h4>A Word on Filter Primitives</h4> <p>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 (<code>in</code>, <code>in2</code>) and one output (<code>result</code>). Primitives exist for blurring, moving, filling, combining or distorting inputs.</p> <p>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 <code>SourceGraphic</code> (the unfiltered source element with colors, strokes, fill patterns, etc.) and <code>SourceAlpha</code> (the opaque area of the alpha channel — think of it as the source graphic filled black), which do have very good browser support.</p> <h4>How To Thicken The Input Text</h4> <p>The first filter primitive we will get to know is <code>feMorphology</code>, a primitive meant to extend (<code>operator="dilate"</code>) or thin (<code>operator="erode"</code>) an input — therefore, perfectly suited to creating outlines and borders.</p> <p>Here is how we would fatten the <code>SourceAlpha</code> by four pixels:</p> <figure><img decoding="async" src="" width="500" alt="Source fattened by 4 pixels" title="Source fattened by 4 pixels"><figcaption>Source fattened by four pixels</figcaption></figure> <pre><code><feMorphology operator="dilate" radius="4" in="SourceAlpha" result="BEVEL_10" /> </code></pre> <h4>Creating an Extrusion</h4> <p>The next step is to create a 3D extrusion of the result from the last primitive. Meet <code>feConvolveMatrix</code>. 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.</p> <p>Here is the <code>feConvolveMatrix</code> to create a 45-degree, 3-pixel deep extrusion. The <code>order</code> attribute defines a width and a height, so that the primitive knows whether to apply a 3×3 or a 9×1 matrix:</p> <figure><img decoding="async" src="" alt="Using feConvolveMatrix to create an extrusion on the fattened input" title="Using feConvolveMatrix to create an extrusion on the fattened input"><br /><figcaption>Using <code>feConvolveMatrix</code> to create an extrusion on the fattened input</figcaption></figure> <pre><code><feConvolveMatrix order="3,3" kernelMatrix= "1 0 0 0 1 0 0 0 1" in="BEVEL_10" result="BEVEL_20" /> </code></pre> <p>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.</p> <p>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, <code>targetX</code> and <code>targetY</code>. Unfortunately, IE interprets them contrary to all other browsers. Therefore, to maintain compatibility across browsers, we will handle offsetting with another filter primitive, <code>feOffset</code>.</p> <h4>Offsetting</h4> <p>As the name implies, <code>feOffset</code> takes an input and, well, offsets it:</p> <pre><code><feOffset dx="4" dy="4" in="BEVEL_20" result="BEVEL_30"/> </code></pre> <h4>Cutting Off the Extruded Part</h4> <p><code>feComposite</code> 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. <code>feComposite</code> can be used to mask or cut elements. Here’s how to subtract the output of <code>feMorphology</code> from the output of <code>feConvolveMatrix</code>:</p> <figure><img decoding="async" src="" alt="Cutting off the fattened 1st primitive from the extrusion"><br /><figcaption>Cutting off the fattened first primitive from the extrusion</figcaption></figure> <pre><code><feComposite operator="out" in="BEVEL_20" in2="BEVEL_10" result="BEVEL_30"/> </code></pre> <h4>Coloring the Extrusion</h4> <p>This is a two-step process:</p> <p>First, we create a colored area with <code>feFlood</code>. This primitive will simply output a rectangle the size of the filter region in a color we define:</p> <pre><code><feFlood flood-color="#582D1B" result="COLOR-red" /> </code></pre> <p>We then cut off the transparent part of <code>BEVEL_30</code> with one more <code>feComposite</code>:</p> <figure><img decoding="async" src="" alt="Coloring the extrusion" title="Coloring the extrusion"><br /><figcaption>Coloring the extrusion</figcaption></figure> <pre><code><feComposite in="COLOR-red" in2="BEVEL_30" operator="in" result="BEVEL_40" /> </code></pre> <h4>Mixing Bevel and Source Into One Output</h4> <p><code>feMerge</code> does just that, mix bevel and source into one output:</p> <figure><img decoding="async" src="" alt="Bevel and source graphic mixed into one output" title="Bevel and source graphic mixed into one output"><br /><figcaption>Bevel and source graphic mixed into one output</figcaption></figure> <pre><code><feMerge result="BEVEL_50"> <feMergeNode in="BEVEL_40" /> <feMergeNode in="SourceGraphic" /> </feMerge> </code></pre> <p>Looks pretty much like the desired result. Let’s make it a little more realistic by giving it a weathered look.</p> <h4>Adding a Fractal Texture</h4> <p><code>feTurbulence</code> 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.</p> <p>Like <code>feFlood</code>, <code>feTurbulence</code> outputs a filled rectangle but uses a noisy, unstructured texture.</p> <p>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:</p> <pre><code><feTurbulence baseFrequency=".05,.004" width="200%" height="200%" top="-50%" type="fractalNoise" numOctaves="4" seed="0" result="FRACTAL-TEXTURE_10" /> </code></pre> <p>By default, <code>feTurbulence</code> 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 <code>feColorMatrix</code> to increase the contrast and convert it to grayscale at the same time:</p> <figure><img decoding="async" src="" alt="Finally adding a fractal texture to the result"><br /><figcaption>Finally, adding a fractal texture to the result</figcaption></figure> <pre><code><feColorMatrix type="matrix" values= "0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 -1.2 1.1" in="FRACTAL-TEXTURE_10" result="FRACTAL-TEXTURE_20" /> </code></pre> <p>The last thing to do is compose the textured alpha into the letterforms with our old friend <code>feComposite</code>:</p> <pre><code><feComposite in="BEVEL_50" in2="FRACTAL-TEXTURE_20" operator="in"/> </code></pre> <p>Done!</p> <h3>How To Apply SVG Filters To SVG Content</h3> <p>There are two methods of applying SVG filters to an SVG <code>text</code> element:</p> <h4>1. Via CSS</h4> <pre><code>.filtered { filter: url(#filter); } </code></pre> <h4>2. Via Attribute</h4> <pre><code><text filter="url(#filter)">Some text</text> </code></pre> <h3>Applying SVG Filters To HTML Content</h3> <p>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:</p> <pre><code>filter: url(#mySVGfilter); </code></pre> <p>At the time of writing, Blink and WebKit require it to be prefixed:</p> <pre><code>-webkit-filter: url(#mySVGfilter); </code></pre> <p>As easy as it sounds in theory, this process is a dark art in the real world:</p> <ul> <li>SVG filters on HTML content are currently supported in WebKit, Firefox and Blink. IE and Microsoft Edge will display the unfiltered element, so make sure that the default look is good enough.</li> <li>The SVG that contains the filter may not be set to <code>display: none</code>. However, you can set it to <code>visibility: hidden</code>.</li> <li>Sometimes the size of the SVG has a direct influence on how much of the target element is filtered.</li> <li>Did I say that WebKit, Blink and Firefox understand this syntax? Well, Safari (and its little brother mobile Safari) is a special case. You <em>can</em> get most of these demos working in Safari, but you will pull your hair out and bite pieces out of your desk in the process. At the time of writing, I can’t recommend using SVG filters on HTML content in the current version of Safari (8.0.6). Results are unpredictable, and the technique is not bulletproof. To make things worse, if Safari fails to render your filter for some reason, it will not display the HTML target <em>at all</em>, an accessibility nightmare. As a rule of thumb, you increase your chances of getting Safari to display your filter with absolute positioning and fixed sizing of your target. As a proof of concept, I’ve set up a <a class="colorbox" href="" title="POP filter effect, optimized for Safari">“pop” filter effect, optimized for desktop Safari</a><sup><a class="colorbox" href="">17</a></sup>. Applying <code>feImage</code> to HTML elements seems to be impossible in Safari.</li> </ul> <h4>Previous Demos, Applied To HTML Content</h4> <p>In these demos, the wrappers are set to <code>contenteditable = "true</code> for convenient text editing. (Be aware that these demos are experimental and will not work in Safari, IE or Edge.)</p> <ul> <li><a class="colorbox" href="" title="outlined and filled with pattern (HTML)">Image filled text</a><sup><a class="colorbox" href="">18</a></sup></li> <li><a class="colorbox" href="" title="Extruded and filled with pattern (HTML)">Extruded and filled with pattern</a><sup><a class="colorbox" href="">19</a></sup></li> <li><a class="colorbox" href="" title="Extruded and illuminated (HTML)">Extruded and illuminated</a><sup><a class="colorbox" href="">20</a></sup></li> <li><a class="colorbox" href="" title="Grungy look with fractal filters (HTML)">Grungy look with the help of fractal filters</a><sup><a class="colorbox" href="">21</a></sup></li> <li><a class="colorbox" href="" title="Spilled water effect (HTML)">feTurbulence to achieve spilled water effect</a><sup><a class="colorbox" href="">22</a></sup></li> <li><a class="colorbox" href="">Some pop-arty color effects</a><sup><a class="colorbox" href="">23</a></sup></li> <li><a class="colorbox" href="">Sketchy style</a><sup><a class="colorbox" href="">24</a></sup></li> </ul> <h3>Structuring A Filter</h3> <p>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.</p> <h4>Grouping</h4> <p>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.</p> <h4>Naming</h4> <p>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 <a class="colorbox" href="" title="BEM">BEM-like schemas</a><sup><a class="colorbox" href="">25</a></sup>, I finally settled on a very simple naming structure:</p> <pre><code>NAME-OF-GROUP_order-number </code></pre> <p>For example, you would have <code>BEVEL_10</code>, <code>BEVEL_20</code>, <code>OUTLINE_10</code> 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.</p> <h4>Always Declare Input and Result</h4> <p>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.)</p> <h3>Some Building Blocks</h3> <p>Let’s look at some single techniques to achieve certain effects. By combining these building blocks, we can create new sophisticated filter effects.</p> <h4>Text Stroke</h4> <figure><a class="colorbox" href=""><img decoding="async" src="" alt="SVG filter outline"></a><sup><a class="colorbox" href="">26</a></sup></figure> <pre><code><!-- 1. Thicken the input with feMorphology: --> <feMorphology operator="dilate" radius="2" in="SourceAlpha" result="thickened" /> <!-- 2. Cut off the SourceAlpha --> <feComposite operator="out" in="SourceAlpha" in2="thickened" /> </code></pre> <p>This method is not guaranteed to look good. Especially when you apply <code>dilate</code> in conjunction with big values for <code>radius</code>, the result can look worse than the geometry created via <code>stroke-width</code>. Depending on the situation, a better alternative would be to store the text in a <code>symbol</code> element, and then insert it when needed via <code>use</code>, and thicken the instance with CSS’ <code>stroke-width</code> property. Be aware that <code>stroke-width</code> cannot be applied to HTML content, though.</p> <h4>Torn Look</h4> <figure><a class="colorbox" href=""><img decoding="async" src="" alt="Torn look"></a><sup><a class="colorbox" href="">27</a></sup></figure> <pre><code><!-- 1. create an feTurbulence fractal fill --> <feTurbulence result="TURBULENCE" baseFrequency="0.08" numOctaves="1" seed="1" /> <!-- 2. create a displacement map that takes the fractal fill as an input to distort the target: --> <feDisplacementMap in="SourceGraphic" in2="TURBULENCE" scale="9" /> </code></pre> <h4>Color Fill</h4> <figure><a class="colorbox" href=""><img decoding="async" src="" alt="Tornout look"></a><sup><a class="colorbox" href="">28</a></sup></figure> <pre><code><!-- 1. Create a colored filled area --> <feFlood flood-color="#F79308" result="COLOR" /> <!-- 2. Cut off the SourceAlpha --> <feComposite operator="in" in="COLOR" in2="SourceAlpha" /> </code></pre> <p>It should be mentioned that, besides <code>feFlood</code>, <code>feColorMatrix</code> is another method of altering the source input’s color, even though that concept is more difficult to grasp.</p> <h4>Offsetting</h4> <figure><a class="colorbox" href=""><img decoding="async" src="" alt="Offsetting the filtered element"></a><sup><a class="colorbox" href="">29</a></sup></figure> <pre><code><!-- Offset the input graphic by the amount defined in its "dx" and "dy" attributes: --> <feOffset in="SourceGraphic" dx="10" dy="10" /> </code></pre> <h4>Extrusion</h4> <figure><a class="colorbox" href=""><img decoding="async" src="" alt="Extrude the target"></a><sup><a class="colorbox" href="">30</a></sup></figure> <pre><code><!-- Define a convolve matrix that applies a bevel. --> <!-- Order defines the depth of the extrusion; angle is defined by the position of "1" in the matrix. Here we see a 45-degree, 4-pixel deep extrusion: --> <feConvolveMatrix order="4,4" kernelMatrix=" 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1" in="SourceAlpha" result="BEVEL" /> <!-- offset extrusion: --> <feOffset dx="2" dy ="2" in="BEVEL" result="OFFSET" /> <!-- merge offset with Source: --> <feMerge> <feMergeNode in="OFFSET" /> <feMergeNode in="SourceGraphic" /> </feMerge> </code></pre> <h4>Noise Fill</h4> <figure><a class="colorbox" href=""><img decoding="async" src="" alt="Create a noise fill"></a><sup><a class="colorbox" href="">31</a></sup></figure> <p>The <code>feTurbulence</code> 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.</p> <p>The appearance of the noise structure can be modified by several parameters:</p> <ul> <li><code>type</code> in its default state will produce a liquid texture.</li> <li><code>type</code> can be set to <code>fractalNoise</code> instead, which will output a sandy result.</li> <li><code>baseFrequency</code> is there to control x and y pattern repetition.</li> <li><code>numOctaves</code> will increase the level of detail and should have a low value if performance is an issue.</li> <li>The number to start randomization with is determined by <code>seed</code>.</li> </ul> <pre><code><feTurbulence type="fractalNoise" baseFrequency="0.1" numOctaves="5" seed="2" /> </code></pre> <h4>Image Fill</h4> <figure><a class="colorbox" href=""><img decoding="async" src="" alt="Fill target with an image"></a><sup><a class="colorbox" href="">32</a></sup></figure> <p><code>feImage</code>‘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 <code>feTile</code>.</p> <pre><code><!-- The following code will create a 100 × 200-pixel square filled with "myfill.svg": --> <feImage xlink:href="myfill.svg" x="0" y="0" width="100" height="200" result="IMAGEFILL"/> <!-- We then use this fill as an input for feTile, creating a repeating pattern this way: --> <feTile in="IMAGEFILL" resulte="TILEPATTERN"/> <!-- Now we will use feComposite to "cut off" SourceAlpha's transparent areas from the fill: --> <feComposite operator="in" in="TILEPATTERN" in2="SourceAlpha" /> </code></pre> <p>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 <a class="colorbox" href="">old bug</a><sup><a class="colorbox" href="">33</a></sup>, 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:</p> <pre><code><feImage xlink:href='data:image/svg+xml;charset=utf-8,<svg width="100" height="100"><rect width="50" height="50 /></svg>' /> </code></pre> <p>Some browsers do not understand UTF-8 data URIs when they aren’t URL-encoded, so make <a class="colorbox" href="" title="Eric Meyer's URL encoder">URL encoding</a><sup><a class="colorbox" href="">34</a></sup> a default:</p> <pre><code><feImage xlink:href='data:image/svg+xml;charset=utf-8,%3Csvg%20width%3D%22100%22%20height%3D%22100%22%3E%3Crect%20width%3D%2250%22%20height%3D%2250%20%2F%3E%3C%2Fsvg%3E' /> </code></pre> <p>If you want to apply <code>feImage</code> 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:</p> <pre><code><style> h1{ position: relative; filter: url(#myImageFilter); } h1 svg{ position: absolute; visibility: hidden; width: 100%; height: 100%; left: 0; top: 0; } </style> <h1> My Filtered Text <svg> <filter id="myImageFilter">…</filter> </svg> </h1> </code></pre> <h4>Lighting Effect</h4> <figure><a class="colorbox" href=""><img decoding="async" src="" alt="3D Bevel"></a><sup><a class="colorbox" href="">35</a></sup></figure> <p>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.</p> <pre><code><!--We create a heightmap by blurring the source: --> <feGaussianBlur stdDeviation="5" in="SourceAlpha" result="BLUR"/> <!-- We then define a lighting effect with a point light that is positioned at virtual 3D coordinates x: 40px, y: -30px, z: 200px: --> <feSpecularLighting surfaceScale="6" specularConstant="1" specularExponent="30" lighting-color="#white" in="BLUR" result="SPECULAR"> <fePointLight x="40" y="-30" z="200" /> </feSpecularLighting> <!-- We cut off the parts that overlap the source graphic… --> <feComposite operator="in" in="SPECULAR" in2="SourceAlpha" result="COMPOSITE"/> <!-- … and then merge source graphic and lighting effect: --> <feMerge> <feMergeNode in="SourceGraphic" /> <feMergeNode in="COMPOSITE"/> </feMerge> </code></pre> <h3>Conclusion</h3> <p>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.</p> <p>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.</p> <h4>Resources From This Article</h4> <ul> <li><a class="colorbox" href="" title="Repo with demos at GitHub">Sophisticated Filter Effects</a><sup><a class="colorbox" href="">36</a></sup>, GitHub<br /> The repository of demos</li> <li><a class="colorbox" href="" title="Play with code on Codepen">Sophisticated Filter Effects</a><sup><a class="colorbox" href="">37</a></sup>, Codepen<br /> Play around with the code.</li> </ul> <h4>Reading List</h4> <ul> <li>“<a class="colorbox" href="" title="W3C Filter Effects Module Level 1">Filter Effects Module Level 1</a><sup><a class="colorbox" href="">38</a></sup>” (working draft), W3C</li> <li>“<a class="colorbox" href="" title="Smarter SVG Filters at">SVG Filters</a><sup><a class="colorbox" href="">39</a></sup>,” Mike Sierra,</li> <li>“<a class="colorbox" href="" title="Filter Effects in SVG">Filter Effects in SVG</a><sup><a class="colorbox" href="">40</a></sup>,” David Dailey</li> <li>“<a class="colorbox" href="" title="Filter Tutorial by Jakob Jenkov">SVG Filters</a><sup><a class="colorbox" href="">41</a></sup>” (tutorial), Jakob Jenkov</li> <li>“<a class="colorbox" href="" title="Filter Primitives Overview">Filter Primitives Overview</a><sup><a class="colorbox" href="">42</a></sup>,” Manfred Moitzi</li> <li>“<a class="colorbox" href="" title="SVGBasics: Filters">Using Filters to Add Raster Images</a><sup><a class="colorbox" href="">43</a></sup>,” SVGBasics</li> <li>“<a class="colorbox" href="" title="Filters by Matthew Bystedt">Filters</a><sup><a class="colorbox" href="">44</a></sup>,” Matthew Bystedt</li> <li>“<a class="colorbox" href="" title="Cirque du Filter">Cirque du Filter: A Journey Into Advanced SVG Filter Effects</a><sup><a class="colorbox" href="">45</a></sup>” (slidedeck), Michael Mullany, CSS Dev Conf 2013</li> <li>“<a class="colorbox" href="" title="How to go beyond the basics with SVG filters">How to Go Beyond the Basics With SVG Filters</a><sup><a class="colorbox" href="">46</a></sup>,” Michael Mullany, Creative Bloq</li> <li>“<a class="colorbox" href="" title="Porter/Duff Compositing and Blend Modes">Porter/Duff Compositing and Blend Modes</a><sup><a class="colorbox" href="">47</a></sup>,” Søren Sandmann Pedersen</li> <li>“<a class="colorbox" href="" title="Matrix Operations for Image Processing">Matrix Operations for Image Processing</a><sup><a class="colorbox" href="">48</a></sup>,” Paul Haeberli</li> <li>“<a class="colorbox" href="" title="Image Processing using 2D-Convolution">Image Processing Using 2D-Convolution</a><sup><a class="colorbox" href="">49</a></sup>,” Williamson Labs</li> <li>“<a class="colorbox" href="" title="3x3 convolution kernels">3×3 Convolution Kernels With Online Demo</a><sup><a class="colorbox" href="">50</a></sup>,” Zoltán Fegyver</li> <li>“<a class="colorbox" href="" title="he Perlin Noise Math FAQ">The Perlin Noise Math FAQ</a><sup><a class="colorbox" href="">51</a></sup>,” Matt Zucker</li> <li>“<a class="colorbox" href="" title="SVG Light Source Filters">A Look at SVG Light Source Filters</a><sup><a class="colorbox" href="">52</a></sup>,” Joni Trythall, CSS-Tricks</li> </ul> <p><em>(ds, al)</em></p> <h4>Footnotes</h4> <ol> <li><a class="colorbox" href="">1</a></li> <li><a class="colorbox" href="">2</a></li> <li><a class="colorbox" href="">3</a></li> <li><a class="colorbox" href="">4</a></li> <li><a class="colorbox" href="">5</a></li> <li><a class="colorbox" href="">6</a></li> <li><a class="colorbox" href="">7</a></li> <li><a class="colorbox" href="">8</a></li> <li><a class="colorbox" href="">9</a></li> <li><a class="colorbox" href="">10</a></li> <li><a class="colorbox" href="">11</a></li> <li><a class="colorbox" href="">12</a></li> <li><a class="colorbox" href="">13</a></li> <li><a class="colorbox" href="">14</a></li> <li><a class="colorbox" href="">15</a></li> <li><a class="colorbox" href="">16</a></li> <li><a class="colorbox" href="">17</a></li> <li><a class="colorbox" href="">18</a></li> <li><a class="colorbox" href="">19</a></li> <li><a class="colorbox" href="">20</a></li> <li><a class="colorbox" href="">21</a></li> <li><a class="colorbox" href="">22</a></li> <li><a class="colorbox" href="">23</a></li> <li><a class="colorbox" href="">24</a></li> <li><a class="colorbox" href="">25</a></li> <li><a class="colorbox" href="">26</a></li> <li><a class="colorbox" href="">27</a></li> <li><a class="colorbox" href="">28</a></li> <li><a class="colorbox" href="">29</a></li> <li><a class="colorbox" href="">30</a></li> <li><a class="colorbox" href="">31</a></li> <li><a class="colorbox" href="">32</a></li> <li><a class="colorbox" href="">33</a></li> <li><a class="colorbox" href="">34</a></li> <li><a class="colorbox" href="">35</a></li> <li><a class="colorbox" href="">36</a></li> <li><a class="colorbox" href="">37</a></li> <li><a class="colorbox" href="">38</a></li> <li><a class="colorbox" href="">39</a></li> <li><a class="colorbox" href="">40</a></li> <li><a class="colorbox" href="">41</a></li> <li><a class="colorbox" href="">42</a></li> <li><a class="colorbox" href="">43</a></li> <li><a class="colorbox" href="">44</a></li> <li><a class="colorbox" href="">45</a></li> <li><a class="colorbox" href="">46</a></li> <li><a class="colorbox" href="">47</a></li> <li><a class="colorbox" href="">48</a></li> <li><a class="colorbox" href="">49</a></li> <li><a class="colorbox" href="">50×3-convolution-kernels-with-online-demo#demo</a></li> <li><a class="colorbox" href="">51</a></li> <li><a class="colorbox" href="">52</a></li> </ol> <p>The post <a class="colorbox" rel="nofollow" href="">The Art Of The SVG Filter And Why It Is Awesome</a> appeared first on <a class="colorbox" rel="nofollow" href="">Smashing Magazine</a>.</p> <div class="fixed"></div> </div> <div class="under"> <span class="categories">Categories: </span><span><a href="" rel="category tag">Others</a></span> <span class="tags">Tags: </span><span></span> </div> </div> <div class="post" id="post-31287"> <h2><a class="title" href="" rel="bookmark">Understanding ECMAScript 6: Template Strings (#2)</a></h2> <div class="info"> <span class="date">May 26th, 2015</span> <span class="author"></span> <span class="comments"><a href="">No comments</a></span> <div class="fixed"></div> </div> <div class="content"> <div class="ftpimagefix" style="float:left"><a class="colorbox" href=""></a></div> <p>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” + […]</p> <div> <div><span>*</span> You might also be interested in the following articles:</div> <ul> <li><a class="colorbox" href="">From Scratch: Writing a 3D Soft Engine 3/6</a></li> <li><a class="colorbox" href=""></a><a class="colorbox" href="">JavaScript: Using Closure Space to Create Real Private Members</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="From Scratch: Writing a 3D Soft Engine 2/6" title="From Scratch: Writing a 3D Soft Engine 2/6" width="250" height="200"></a><a class="colorbox" href="">From Scratch: Writing a 3D Soft Engine 2/6</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="MagicSuggest for jQuery: Beautiful Selection Comboboxes Based on Bootstrap 3" title="MagicSuggest for jQuery: Beautiful Selection Comboboxes Based on Bootstrap 3" width="250" height="200"></a><a class="colorbox" href="">MagicSuggest for jQuery: Beautiful Selection Comboboxes Based on…</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="New Era: Computation of Time with Moment.js" title="New Era: Computation of Time with Moment.js" width="250" height="200"></a><a class="colorbox" href="">New Era: Computation of Time with Moment.js</a></li> <li><a class="colorbox" href=""><img decoding="async" loading="lazy" src="" alt="HTML5 Server-Sent-Events: How To React On Server Requests With JavaScript" title="HTML5 Server-Sent-Events: How To React On Server Requests With JavaScript" width="250" height="200"></a><a class="colorbox" href="">HTML5 Server-Sent-Events: How To React On Server Requests With…</a></li> </ul> <div></div> </div> <div class="fixed"></div> </div> <div class="under"> <span class="categories">Categories: </span><span><a href="" rel="category tag">Others</a></span> <span class="tags">Tags: </span><span></span> </div> </div> <div id="pagenavi"> <span class="newer"></span> <span class="older"><a href="" >Older Entries</a></span> <div class="fixed"></div> </div> </div> <!-- main END --> <!-- sidebar START --> <div id="sidebar"> <!-- sidebar north START --> <div id="northsidebar" class="sidebar"> <!-- feeds --> <div class="widget widget_feeds"> <div class="content"> <div id="subscribe"> <a rel="external nofollow" id="feedrss" title="Subscribe to this blog..." href=""><abbr title="Really Simple Syndication">RSS</abbr></a> </div> <div class="fixed"></div> </div> </div> <!-- showcase --> <div id="text-389627311" class="widget widget_text"> <div class="textwidget"><a href="" title="Subscribe to my feed" rel="alternate" type="application/rss+xml"><img src="" alt="" style="border:0"/></a><a href="" title="Subscribe to my feed" rel="alternate" type="application/rss+xml">Subscribe for latest Updates</a></div> </div><div id="text-389629461" class="widget widget_text"> <div class="textwidget"><form style="border:1px solid #ccc;padding:3px;text-align:center;" action="" method="post" target="popupwindow" onsubmit="'', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true"><p>Enter your email address:</p><p><input type="text" style="width:140px" name="email"/></p><input type="hidden" value="webmastersgallery" name="uri"/><input type="hidden" name="loc" value="en_US"/><input type="submit" value="Subscribe" /><p>Delivered by <a href="" target="_blank" rel="noopener">FeedBurner</a></p></form></div> </div></div> <!-- sidebar north END --> <div id="centersidebar"> <!-- sidebar east START --> <div id="eastsidebar" class="sidebar"> <!-- categories --> <div class="widget widget_categories"> <h3>Categories</h3> <ul> <li class="cat-item cat-item-518"><a href="">Affiliate Programs</a> </li> <li class="cat-item cat-item-147"><a href="">Designing</a> </li> <li class="cat-item cat-item-519"><a href="">Domain Names</a> </li> <li class="cat-item cat-item-37"><a href="">E-commerce</a> </li> <li class="cat-item cat-item-509"><a href="">Internet Directories</a> </li> <li class="cat-item cat-item-510"><a href="">Message Boards</a> </li> <li class="cat-item cat-item-1"><a href="">Others</a> </li> <li class="cat-item cat-item-506"><a href="">Programming</a> </li> <li class="cat-item cat-item-511"><a href="">Promotion and Marketing</a> </li> <li class="cat-item cat-item-534"><a href="">Scripts and Programming</a> </li> <li class="cat-item cat-item-513"><a href="">Search Engines</a> </li> <li class="cat-item cat-item-135"><a href="">Social Media</a> </li> <li class="cat-item cat-item-514"><a href="">Softwares</a> </li> <li class="cat-item cat-item-515"><a href="">Tips and Tutorials</a> </li> <li class="cat-item cat-item-338"><a href="">Web Hosting</a> </li> <li class="cat-item cat-item-516"><a href="">Webmaster Tools</a> </li> <li class="cat-item cat-item-501"><a href="">Webmasters Resources</a> </li> <li class="cat-item cat-item-3"><a href="">Website Design</a> </li> </ul> </div> </div> <!-- sidebar east END --> <!-- sidebar west START --> <div id="westsidebar" class="sidebar"> <!-- blogroll --> <div class="widget widget_links"> <h3>Blogroll</h3> <ul> <li><a href="">Development Blog</a></li> <li><a href="">Documentation</a></li> <li><a href="">Plugins</a></li> <li><a href="">Suggest Ideas</a></li> <li><a href="">Support Forum</a></li> <li><a href="">Themes</a></li> <li><a href="">WordPress Planet</a></li> </ul> </div> </div> <!-- sidebar west END --> <div class="fixed"></div> </div> <!-- sidebar south START --> <div id="southsidebar" class="sidebar"> <!-- archives --> <div class="widget"> <h3>Archives</h3> <ul> <li><a href=''>July 2024</a></li> <li><a href=''>June 2024</a></li> <li><a href=''>May 2024</a></li> <li><a href=''>April 2024</a></li> <li><a href=''>March 2024</a></li> <li><a href=''>February 2024</a></li> <li><a href=''>January 2024</a></li> <li><a href=''>December 2023</a></li> <li><a href=''>November 2023</a></li> <li><a href=''>October 2023</a></li> <li><a href=''>September 2023</a></li> <li><a href=''>August 2023</a></li> <li><a href=''>July 2023</a></li> <li><a href=''>June 2023</a></li> <li><a href=''>May 2023</a></li> <li><a href=''>April 2023</a></li> <li><a href=''>March 2023</a></li> <li><a href=''>February 2023</a></li> <li><a href=''>January 2023</a></li> <li><a href=''>December 2022</a></li> <li><a href=''>November 2022</a></li> <li><a href=''>October 2022</a></li> <li><a href=''>September 2022</a></li> <li><a href=''>August 2022</a></li> <li><a href=''>July 2022</a></li> <li><a href=''>June 2022</a></li> <li><a href=''>May 2022</a></li> <li><a href=''>April 2022</a></li> <li><a href=''>March 2022</a></li> <li><a href=''>February 2022</a></li> <li><a href=''>January 2022</a></li> <li><a href=''>December 2021</a></li> <li><a href=''>November 2021</a></li> <li><a href=''>October 2021</a></li> <li><a href=''>September 2021</a></li> <li><a href=''>August 2021</a></li> <li><a href=''>July 2021</a></li> <li><a href=''>June 2021</a></li> <li><a href=''>May 2021</a></li> <li><a href=''>April 2021</a></li> <li><a href=''>March 2021</a></li> <li><a href=''>February 2021</a></li> <li><a href=''>January 2021</a></li> <li><a href=''>December 2020</a></li> <li><a href=''>November 2020</a></li> <li><a href=''>October 2020</a></li> <li><a href=''>September 2020</a></li> <li><a href=''>August 2020</a></li> <li><a href=''>July 2020</a></li> <li><a href=''>June 2020</a></li> <li><a href=''>May 2020</a></li> <li><a href=''>April 2020</a></li> <li><a href=''>March 2020</a></li> <li><a href=''>February 2020</a></li> <li><a href=''>January 2020</a></li> <li><a href=''>December 2019</a></li> <li><a href=''>November 2019</a></li> <li><a href=''>October 2019</a></li> <li><a href=''>September 2019</a></li> <li><a href=''>August 2019</a></li> <li><a href=''>July 2019</a></li> <li><a href=''>June 2019</a></li> <li><a href=''>May 2019</a></li> <li><a href=''>April 2019</a></li> <li><a href=''>March 2019</a></li> <li><a href=''>February 2019</a></li> <li><a href=''>January 2019</a></li> <li><a href=''>December 2018</a></li> <li><a href=''>November 2018</a></li> <li><a href=''>October 2018</a></li> <li><a href=''>September 2018</a></li> <li><a href=''>August 2018</a></li> <li><a href=''>July 2018</a></li> <li><a href=''>April 2018</a></li> <li><a href=''>January 2018</a></li> <li><a href=''>December 2017</a></li> <li><a href=''>November 2017</a></li> <li><a href=''>September 2017</a></li> <li><a href=''>August 2017</a></li> <li><a href=''>July 2017</a></li> <li><a href=''>June 2017</a></li> <li><a href=''>May 2017</a></li> <li><a href=''>April 2017</a></li> <li><a href=''>March 2017</a></li> <li><a href=''>February 2017</a></li> <li><a href=''>January 2017</a></li> <li><a href=''>December 2016</a></li> <li><a href=''>November 2016</a></li> <li><a href=''>October 2016</a></li> <li><a href=''>September 2016</a></li> <li><a href=''>August 2016</a></li> <li><a href=''>July 2016</a></li> <li><a href=''>June 2016</a></li> <li><a href=''>May 2016</a></li> <li><a href=''>April 2016</a></li> <li><a href=''>March 2016</a></li> <li><a href=''>February 2016</a></li> <li><a href=''>January 2016</a></li> <li><a href=''>December 2015</a></li> <li><a href=''>November 2015</a></li> <li><a href=''>October 2015</a></li> <li><a href=''>September 2015</a></li> <li><a href=''>August 2015</a></li> <li><a href=''>July 2015</a></li> <li><a href=''>June 2015</a></li> <li><a href='' aria-current="page">May 2015</a></li> <li><a href=''>April 2015</a></li> <li><a href=''>March 2015</a></li> <li><a href=''>February 2015</a></li> <li><a href=''>January 2015</a></li> <li><a href=''>December 2014</a></li> <li><a href=''>November 2014</a></li> <li><a href=''>October 2014</a></li> <li><a href=''>September 2014</a></li> <li><a href=''>August 2014</a></li> <li><a href=''>July 2014</a></li> <li><a href=''>June 2014</a></li> <li><a href=''>July 2013</a></li> <li><a href=''>January 2013</a></li> <li><a href=''>December 2012</a></li> <li><a href=''>August 2012</a></li> <li><a href=''>July 2012</a></li> <li><a href=''>June 2012</a></li> <li><a href=''>May 2012</a></li> <li><a href=''>April 2012</a></li> <li><a href=''>January 2012</a></li> <li><a href=''>November 2011</a></li> <li><a href=''>June 2011</a></li> <li><a href=''>March 2011</a></li> <li><a href=''>February 2011</a></li> <li><a href=''>January 2011</a></li> <li><a href=''>December 2010</a></li> <li><a href=''>November 2010</a></li> <li><a href=''>September 2010</a></li> <li><a href=''>July 2010</a></li> <li><a href=''>June 2010</a></li> <li><a href=''>May 2010</a></li> <li><a href=''>February 2010</a></li> <li><a href=''>December 2009</a></li> <li><a href=''>August 2009</a></li> <li><a href=''>July 2009</a></li> <li><a href=''>June 2009</a></li> <li><a href=''>May 2009</a></li> <li><a href=''>April 2009</a></li> <li><a href=''>March 2009</a></li> </ul> </div> <!-- meta --> <div class="widget"> <h3>Meta</h3> <ul> <li><a href="">Log in</a></li> </ul> </div> </div> <!-- sidebar south END --> </div> <!-- sidebar END --> <div class="fixed"></div> </div> <!-- content END --> <!-- footer START --> <div id="footer"> <a id="gotop" href="#" onclick="MGJS.goTop();return false;">Top</a> <a id="powered" href="">WordPress</a> <div id="copyright"> Copyright © 2009-2024 Webmasters Gallery </div> <div id="themeinfo"> Theme by <a href="">NeoEase</a>. Valid <a href="">XHTML 1.1</a> and <a href="">CSS 3</a>. </div> </div> <!-- footer END --> </div> <!-- container END --> </div> <!-- wrap END --> </body> </html>