Simple demo of generating an equilateral triangle in SVG using JS.
The post SVG Triangle Generator using JS appeared first on jQuery Rain.
by Admin via jQuery Rain
"Mr Branding" is a blog based on RSS for everything related to website branding and website design, it collects its posts from many sites in order to facilitate the updating to the latest technology.
To suggest any source, please contact me: Taha.baba@consultant.com
Simple demo of generating an equilateral triangle in SVG using JS.
The post SVG Triangle Generator using JS appeared first on jQuery Rain.
Portfolio of Julie Poignot, UX Designer & Front-end Developer.
I think we're all always looking for that touch that makes a design feel fresh and different - a pattern, a photo, or a texture that doesn't feel like stock. One of my favorites sources is Flickr - but probably not the way you use it.
Sure, most of us know about Flickr's vast library of creative commons licensed images but there's another rich vein of fascinating imagery worth exploring.
[caption id="attachment_133402" align="alignright" width="410"] J.L.M. Lauweriks. Alphabet, [1900]. NAI Collection[/caption]
Many of the world's great libraries, government agencies, private companies, national & state archives, museums, and historical societies use Flickr as a catalog for their book, documents, illustrations, and photographs. All in the Public Domain and copyright free.
This includes organizations such as:
The Internet Archive of Book Images alone has been digitizing lapsed copyright books for well over a decade now, and now has more than 5 million images on the site.
The works fall into two broad categories.
Accessing these images isn't hard. Perform a standard search, click the 'Any license' dropdown on the top left and hit 'No known copyright restrictions'.
[caption id="attachment_133404" align="aligncenter" width="703"] Flickr search - 'No known copyright restrictions'[/caption]
Clearly we're not talking about the kind of smooth graphics you'd expect to find on a big stock site, so you need to be strategic. This is a gargantuan library so you could be clicking that 'next page' link for days.
Continue reading %How to Find Cool, Quirky, Copyright Free Photos on Flickr%
Over the past decade, browser vendors have introduced various new APIs that enable us as programmers to create richer and more fluent experiences. One of these is the getUserMedia
API, which enables access to the user's audio and video devices. However, it's still not quite there yet in terms of browser compatibility.
With this in mind, Adam Wróbel wrote JpegCamera, a library that takes into account the different caveats among browsers for interacting with user's camera and provides fallbacks for those cases where access to client's media is not supported.
In this article we'll see how by using JpegCamera, together with HTML canvas
element capabilities, we can build a clone of Instagram's Layout app:
The demo Layout-like application
The source code for the demo can be downloaded from Github.
JpegCamera allows you to access the user's camera as part of your application, gracefully degrading to a Flash fallback if the browser does not support getUserMedia()
.
The first step to is to include the necessary scripts in your project.
The library depends on the SWF Object and Canvas to Blob libraries, both of which come as part of the zip download from the project's Github page. However, in the same zip there's a with dependencies version of the script, which provides the same functionality as having the three scripts loaded in the page.
With this in mind, you can either include the three needed scripts.
<script src="/jpeg_camera/swfobject.min.js" type="text/javascript"></script>
<script src="/jpeg_camera/canvas-to-blob.min.js" type="text/javascript"></script>
<script src="/jpeg_camera/jpeg_camera.min.js" type="text/javascript"></script>
Or just go with the one script alternative.
<script type="text/javascript" src="js/libs/jpeg_camera/jpeg_camera_with_dependencies.min.js"></script>
For production environments, the later seem to be the way to go, unlike during development.
Once the library is included you can use the global JpegCamera object to check the camera availability, and choose how to manage the fallback if not.
If the access is granted, you can setup a listener for when the camera is ready with the JpegCamera()
constructor.
The JpegCamera()
constructor takes a CSS selector as an argument which should identify the container to be used for the camera stream.
The snippet below shows the code that does this:
(function() {
if(!window.JpegCamera) {
alert('Camera access is not available in your browser');
} else {
JpegCamera('.camera')
.ready(function(resolution) {
// ...
}).error(function() {
alert('Camera access was denied');
});
}
})();
This way, you can setup your application to only start once the camera is ready, or let the user know that they either require a different browser or need to enable camera access for the application.
Inside the ready
callback function, the device's camera resolution is passed as the first argument. This can be useful if the application we are building relies on the device's camera quality (i.e.: to make HD capture available or not).
Meanwhile the error
callback receives as an argument a string
message explaining what happened. If you need to show the user an explanation in case of an error, you can use the message the library supplies.
In addition to this, the JpegCamera API provides the following methods:
capture()
: This is the method that takes a picture. It returns the image itself as a Snapshot
object (the class that JpegCamera
uses for images).show()
: Once you take the picture, the Snapshot
object that you obtain allows you to display the image in the page, by invoking its show()
method. The image will be displayed inside the same container you specified when initializing the camera.showStream()
: If a snapshot is currently displayed in the container, showStream()
hides the image and displays the stream.getCanvas()
: Takes a callback function as a parameter, which will receive as an argument the canvas
element with the captured image.Let's dive into an example application that illustrates what JpegCamera allows us to do.
The demo application emulates (sort of) what Layout does: it allows the user to take photos and generates new images by combining them. In our version, the combined images can be downloaded by clicking on them.
The application structure is based on the Module Pattern. This pattern gives us a couple of benefits:
You'll notice that I pass three parameters into the self invoked functions:
(window, document, jQuery)
And these arguments are received:
function(window, document, $)
The reason for passing window
and document
is for minification purposes. If we pass these as arguments, then each of them can be replaced for a single character. If we had just referenced these global objects directly, the minifier would not be able to substitute them with shorter names.
With jQuery
, we do it to avoid conflicts with other libraries that might also using $
as their main function (i.e.: Prototype).
At the top of the Layouts
and Custom
modules you'll see something along these lines:
if(!window.LayoutApp) {
window.LayoutApp = {};
}
This is for two reasons:
index.html
.The application logic is divided into three modules:
These three modules together with our libraries must be included in our index.html
as follows:
Continue reading %Accessing the User’s Camera with JpegCamera and Canvas%
Only a few months ago, HHVM (HipHop Virtual Machine) was a popular buzzword in the PHP community. Many of us were curious about this technology, especially the reports of improved performance. Previously, Zend’s PHP was the only alternative — until Facebook introduced HHVM to the world.
Good news, HHVM is no longer a buzzword. Many people (including myself) dislike hyped up technologies, but I’m happy to write this as a post-buzzword article.
So let's dive in!
In this article, I'll cover:
To understand what HHVM is, we first need to cover what Zend Engine is (currently we're at version 3 with PHP 7). The best explanation on this can be found on this Wikipedia article:
The Zend Engine is the open source scripting engine that interprets the PHP programming language. It was originally developed by Andi Gutmans and Zeev Suraski while they were students at the Technion - Israel Institute of Technology. They later founded a company called Zend Technologies in Ramat Gan, Israel. The name Zend is a combination of their forenames, Zeev and Andi.
Is it the language or an interpreter? It's a ongoing debate with every scripting language. However, let's say that PHP the language, is abstract, it's a blueprint for the interpreter (parser). It's more of a philosophical debate than a real debate. HHVM is like Zend Engine, but it takes a different approach to parse and run the source code.
Continue reading %Getting Started with HHVM and WordPress%
|