by Rob Hope via One Page Love
"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
Monday, July 24, 2017
Responsive Logos
by Rob Hope via One Page Love
Getting Started With Matter.js: Introduction
Matter.js is a 2D rigid body physics engine written in JavaScript. This library can help you easily simulate 2D physics in the browser. It offers a lot of features like the ability to create rigid bodies and assign physical properties like mass, area or density to them. You can also simulate different kinds of collisions and forces like gravity and friction.
Matter.js supports all major browsers including IE8+. Additionally, it is suitable for use on mobile devices as it can detect touch and has responsiveness. All these features make it worth investing your time to learn how to use the engine as you will then be able to create physics-based 2D games or simulations easily. In this tutorial, I will cover the basics of this library, including its installation and usage, and I'll provide a working example.
Installation
You can install Matter.js by using package managers like Bower or NPM with the help of the following commands:
bower install matter-js npm install matter-js
You can also get a link to the library from a CDN and directly include it in your projects like this:
<script src="path/to/matter.min.js"></script>
A Basic Example
The best way to learn about Matter.js is to see some actual code and understand how it works. In this section, we will create a few bodies and go through the required code line by line.
var Engine = Matter.Engine, Render = Matter.Render, World = Matter.World, Bodies = Matter.Bodies; var engine = Engine.create(); var render = Render.create({ element: document.body, engine: engine, options: { width: 800, height: 400, wireframes: false } }); var boxA = Bodies.rectangle(400, 200, 80, 80); var ballA = Bodies.circle(380, 100, 40, 10); var ballB = Bodies.circle(460, 10, 40, 10); var ground = Bodies.rectangle(400, 380, 810, 60, { isStatic: true }); World.add(engine.world, [boxA, ballA, ballB, ground]); Engine.run(engine); Render.run(render);
We begin by creating aliases for all the Matter.js modules that we might need in our project. The Matter.Engine
module contains methods for creating and manipulating engines. Engines are required in a project to update the simulation of the world. The Matter.Render
module is a basic HTML5 canvas-based renderer. This module is required to visualize different engines.
The Matter.World
module is used to create and manipulate the world in which the engine runs. It is similar to the Matter.Composite
module, but it lets you tweak a few additional properties like gravity
and bounds
. The last module in our code, called Matter.Bodies
, allows you to create rigid body objects. Another similar module called Matter.Body
allows you to manipulate individual bodies.
The next line uses the create([settings])
method of the Matter.Engine
module to create a new engine. The settings
parameter in the above method is actually an object with key-value pairs to override the default values of a few properties related to the engine.
For example, you can control the global scaling factor of time for all the bodies in the world. Setting a value less than 1 will result in the world interacting in slow motion. Similarly, a value greater than 1 will make the world fast-paced. You will learn more about the Matter.Engine
module in the next tutorial of the series.
After that, we use the create([settings])
method of the Matter.Render
module to create a new renderer. Just like the Engine module, the settings parameter in the above method is an object used to specify different options for the parameter. You can use the element
key to specify the element where the library should insert the canvas. Similarly, you can also use the canvas
key to specify the canvas element where the Matter.js world should be rendered.
There is an engine
key that you can use to specify the engine that should be used to render the world. There is also an options
key that actually accepts an object as its value. You can use this key to set values for different parameters like the width
or height
of the canvas. You can also turn the wireframes on or off by setting the value of wireframe
key to true
or false
respectively.
The next few lines create different bodies that will interact in our world. The bodies are created with the help of the Matter.Bodies
module in Matter.js. In this example, we have just created two circles and a rectangle using the circle()
and rectangle()
method. Other methods are available as well to create different polygons.
Once we have created the bodies, we need to add them to a world of our choice using the add()
method from the Matter.World
module. After adding the necessary bodies to our world, we just need to run the engine and the renderer using the run()
method from the respective modules. That is basically all the code you need to create and render a world in Matter.js.
The code at the beginning of this section creates the following result.
Common Matter.js Modules
There are more than 20 different modules in Matter.js. All these modules provide different methods and properties that are useful for creating different kinds of simulations and allow you to interact with them. Some of these modules handle collisions, while others handle rendering and simulation.
The example in the previous section used four different modules to handle the rendering, simulation and creation of bodies. In this section, you will learn about the roles of some common modules available in Matter.js.
- Engine: You need engines to update the simulations of your Matter.js world. The
Engine
module provides different methods and properties that allow you to control the behavior of different engines. - World: This module provides you with methods and properties to create and manipulate whole worlds at once. The
World
is actually aComposite
body with additional properties like gravity and bounds. - Bodies: The
Bodies
module contains different methods to help you create rigid bodies with common shapes like a circle, rectangle or trapezium. - Body: This module provides you different methods and properties to create and manipulate the rigid bodies that you have created using the functions from the
Bodies
module. This module allows you to scale, rotate or translate individual bodies. It also has functions to let you specify the velocity, density or inertia of different bodies. Because of so many functions, the third tutorial in this series only discusses the methods and properties available in the Body module. - Composites: Just like the
Bodies
module, this module contains different methods that you can use to create composite bodies with common configurations. For example, you can create a stack or pyramid of rectangular boxes using just a single method with the help ofComposites
module. - Composite: The
Composite
module has methods and properties that allow you to create and manipulate composite bodies. You can read more about theComposite
andComposites
modules in the fourth tutorial of the series. - Constraint: This module allows you to create and manipulate constraints. You can use a constraint to make sure that two bodies or a fixed world-space point and a body maintain a fixed distance. It is similar to connecting two bodies through a steel rod. You can modify the stiffness of these constraints so that the rod starts acting more like springs. Matter.js uses constraints when creating a Newton's cradle or a chain composite.
- MouseConstraint: This module provides you with methods and properties that let you create and manipulate mouse constraints. This is helpful when you want different bodies in the world to interact with the user.
Final Thoughts
This tutorial was meant to introduce you to the Matter.js library. Keeping that in mind, I have provided a quick overview of the features and installation of the library. The basic example involving two circles and a box shows how easy it is to create simple simulations using the library.
Since Matter.js has a lot of modules each of which adds its own unique methods to the engine, I have written a brief summary of few common modules. The rest of the series will focus on teaching you about these common modules in more detail.
by Monty Shokeen via Envato Tuts+ Code
How to Submit a DMCA Takedown Notice
Do people copy your content and post it on their site without permission? Did you know the Digital Millennium Copyright Act (DMCA) can help? In this article, you’ll discover how to file a DMCA takedown notice to protect your content from plagiarists and content scrapers. What Is the DMCA and How Does It Protect Bloggers [...]
This post How to Submit a DMCA Takedown Notice first appeared on .
- Your Guide to the Social Media Jungle
by Ana Gotter via
Mobile Development Languages
If you want to code a mobile app, you need to know a programming language. But it can be hard to choose the best language (or languages) for a project. There are a lot of options out there, and in this post I'll help you narrow them down so that you can pick the best.
It all depends on what you're building. For certain apps, mobile developers may not need all the available features of a particular language. In other situations, a single app may require more than one language. In this tutorial, I'll go through various mobile development languages and highlight some of the details that can help you make a decision.
Let's start with some languages which you may already be familiar with.
Android Languages
Java
According to the TIOBE Index, Java is the most popular programming language as of June 2017. If you want to develop Android apps, you'll most likely to stick to Java. It has a large and established developer community, and that means you can easily get technical support and help.
So, when you're developing for mobile with Java, you are free to come up with any type of app you can think of. The only limits will be your imagination and the level of your Java knowledge.
-
AndroidAndroid From Scratch: An Overview of Android Application DevelopmentAshraff Hathibelagal
-
JavaLearn Java for AndroidSue Smith
Kotlin
Kotlin was designed and developed by JetBrains, the Czech company known for their popular IDE, IntelliJ IDEA. Google's Android team has recently announced that they are officially adding support for the Kotlin programming language.
Kotlin was developed to address some of the issues in Java. According to the language's fans, Kotlin syntax is simpler, cleaner, and leads to less code bloat. This helps you focus more on solving the actual problem, rather than struggling with verbose syntax. Also, you can use Kotlin and Java together in the same project, and that makes it really powerful.
iOS Languages
Swift
If you want to develop for iOS, Swift might be the language for you. Introduced in 2014 and declared open source in 2015, Swift is swiftly catching up with mobile developers. It's very popular, especially among new iOS development startups.
Apple has added some great features to the language, such as simplified syntax, the ability to easily pinpoint programmer errors, etc. Apple's huge efforts to promote Swift clearly indicate that it wants this new language to become the mainstream programming language for its app ecosystem.
-
SwiftCreate iOS Apps With Swift 3Markus Mühlberger
-
SwiftSwift From Scratch: IntroductionBart Jacobs
Objective-C
Objective-C was the original development language for iOS. While the recently introduced Swift language is the future of iOS development, many advanced projects still rely on Objective-C. So the transition from Objective-C to Swift is expected to be somewhat slow, and you may need both of them for some projects, at least for the time being.
Cross-Platform Languages
JavaScript
JavaScript has a long history going back to the early days of the World Wide Web. A very popular front-end and server-side language, it lets web developers do everything from enhancing the user experience of their websites to building complete web apps.
Today, there are several JavaScript frameworks that specifically target mobile development platforms, such as Ionic 2 and React Native. It's very easy to develop cross-platform mobile apps using these frameworks and libraries. This means you only have to write a single version of your app, and it will run on iOS or Android.
-
JavaScriptJavaScript FundamentalsDan Wellman
-
Ionic 2Introduction to Ionic 2Wernher-Bel Ancheta
-
React NativeGet Started With React NativeMarkus Mühlberger
TypeScript
TypeScript is a superset of JavaScript and offers better safety by adding optional static typing. It also provides better support for developing large-scale applications. Developed and maintained by Microsoft, TypeScript allows developers to write cross-platform mobile apps using frameworks such as NativeScript.
-
Web DevelopmentGetting Started with TypeScriptSayanee Basu
-
NativeScriptCode a Mobile App With NativeScriptKeyvan Kasaei
Other Languages
C#
C# is the language of Windows Mobile. It's very similar to C++ and Java. Microsoft has adopted some of the features of Java to simplify its architecture, while maintaining the C++ like design. It also has a large and active community of developers who are always friendly and helpful.
C
C is the second most popular language on the TIOBE index, and just like Java, its community is full of seasoned developers who could offer you valuable advice on how to write bug-free code.
Created by Dennis Ritchie, while working for Bell Labs, C is a widely adopted and powerful language that allows you to directly manipulate low-level operations of a computer. If you want to use Android NDK (Native Development Kit), you'll need to get familiar with the C language.
C++
If you are familiar with C, then you'll really enjoy reading and writing C++ code. C++ is an extension of C, with more high-level features and support for object-oriented programming. C++ is also a favorite language of Android NDK developers. You can use C++ to develop Windows Mobile apps too. C++ goes head to head with Java in the field of software development, and it's really worth mastering.
Python
Python is another popular language that's easy to learn and easy to read. The creators of the language have made extra efforts to keep the syntax as simple and clear as possible. This really helps novice developers maintain high levels of productivity, from day one. If you are comfortable with writing Python code, then you can use frameworks such as Kivy to develop cross-platform mobile apps.
Ruby
Ruby is an object-oriented scripting language, influenced by Ada, C++, Perl, Python, and Lisp. RubyMotion is a great framework for developing native and cross-platform mobile apps in Ruby. It's fairly easy to learn Ruby, thanks to its elegant syntax that focuses on simplicity and productivity.
How to Classify the Languages?
Mobile apps can be grouped into three categories, namely native, hybrid, and native cross-platform. Native apps can fully utilize all the OS facilities and features, and they are the fastest when it comes to performance. However, you need to maintain different codebases for different mobile platforms, as each platform uses different programming languages.
For example, Android platform makes use of Java plus C/C++ to develop native apps. Apple's iOS platform relies on Objective-C and Swift as its native languages. C# is used by Windows Mobile platform to code its native apps. All of these native app programming languages are compiled, rather than interpreted.
Hybrid mobile apps are actually websites that are designed to work with mobile devices too. A user can access them via a mobile browser as if they are visiting a website on a desktop computer. The combination of HTML5, CSS and JavaScript is the obvious choice, if you want to develop web apps.
Recently, a new batch of mobile cross-platform frameworks has emerged. These frameworks combine the best features of native apps and hybrid apps—they're fast and light and can access the full power of the native device, but they also are coded with JavaScript and other web languages, so a lot of code can be reused between platforms.
React Native and NativeScript are popular native cross-platform frameworks. If you want to learn more about these, check out our comprehensive beginner course or some of our many tutorials.
Comparison of Features
Before getting deeper into the detailed language features, you must select a platform. You can refer to the article Mobile Development Platforms to get an idea of various platforms and how to pick the one that suits you best. Assuming that you've already selected a mobile development platform, let's see how these languages compare in terms of their features.
Native Android
If you want to develop for native Android, Java and Kotlin are your obvious choices. So let's have a look at them.
Null Safety
Kotlin has better control over Null references so that the famous NullPointerException
bugs (common in Java) are much easier to eliminate. This reduces development time and improves programmer productivity.
Concurrency
Although Java supports concurrent operations, the relevant code may suffer heavily from readability and maintainability issues. Kotlin addresses these issues by using Coroutines. The resulting code is easily readable and easily understandable too.
Type System
Java's type system isn't consistent, and this can sometimes lead to confusion. In particular, the primitive types such as integer, boolean, and so on need to be handled as special cases. By contrast, Kotlin has a relatively simple and more versatile type system that minimizes programmer errors and mistakes.
Supported Programming Styles
Although Java can theoretically support various programming styles, some developers believe that it overly promotes OOP (Object-Oriented Programming). Kotlin doesn't seem to enforce any particular style of programming, so developers have more freedom to choose an approach that fits best. However, Kotlin developers need to have a thorough knowledge of software architecture and development principles.
Which One to Choose?
In a nutshell, it seems that Kotlin is better than Java, but it may take some time for a complete transformation. One challenge is that programmers are used to the thinking patterns enforced by Java. Another is that Kotlin is a new language, and certain features are still experimental.
Anyway, Google has clearly announced that they will offer complete support for Kotlin. In fact, Android Studio, the official Android IDE, now comes with full support for Kotlin. New features and capabilities are constantly added to Kotlin. Over the next few years, we are going to experience a transition period from Java to Kotlin, at least in native Android development.
Native iOS
Objective-C and Swift are the two options you have for iOS development. So let's have a look at each one's features.
Code Syntax
Swift has simpler and clearer syntax to help programmers achieve their goals with the minimum number of LOC (Lines Of Code). This also helps reduce programmer errors and eases bug fixing.
Memory Management
Swift clearly beats Objective-C, when it comes to memory management. Swift enforces more robust and reliable control mechanisms, allowing programmers to avoid undesirable memory leaks.
Performance
Execution of Swift code is much faster than that of Objective-C. This clearly leads to faster app performance and better user experience.
Supported Programming Styles
Unlike Objective-C, Swift has built-in support for functional programming too. So developers don't have to limit themselves to any pre-defined programming styles. That helps developers understand the problem clearly and come up with a better solution.
Which One to Choose?
Just as Kotlin is slowly replacing Java in native Android development, Swift seems sure to thrive in native iOS development, forcing Objective-C to retire. Apple has already started extensive support for Swift, and that's going to get even better in the future. Like Android developers, iOS developers are also experiencing a transition period at the moment.
While there are several code migration tools available, it may not be possible to fully convert Objective-C projects to Swift without issues. Sometimes, specific workarounds may be required, and that might need a fair knowledge of Objective-C. So the best strategy is to give priority to Swift and learn a bit of Objective-C only when it's absolutely necessary. Also, you need to keep an eye on the latest Swift developments and trends.
Cross-Platform Apps
JavaScript (coupled with other HTML5 technologies) is the most used cross-platform mobile development language. There are also other languages, such as Python and Ruby, but JavaScript has the broadest range of support and adoption.
Unless you are already a big Ruby or Python fan and you want to try out the cutting-edge of mobile development with those languages, you should stick with JavaScript or its type-augmented sibling, TypeScript.
Conclusion
Choosing a mobile development language can be tricky if you don't understand the features of each one, along with the current industry trends. With this knowledge, though, it's easy to see that choosing a language heavily depends on the particular mobile development platform too.
I'm sure now you have a clearer picture of mobile app development languages and are able to match the relevance of their features to the latest development trends. So just get started coding your next app with confidence!
If you want some help getting started with a new language, check out some of the tutorials and video courses linked throughout this post, or some of our other posts on mobile development!
-
Mobile DevelopmentMobile Development PlatformsBala Durage Sandamal Siripathi
-
React NativeGet Started With React Native LayoutsWernher-Bel Ancheta
-
NativeScriptCreate Your First NativeScript AppWernher-Bel Ancheta
-
Android StudioCoding Functional Android Apps in Kotlin: Getting StartedJessica Thornsby
-
SwiftSwift From Scratch: An Introduction to FunctionsBart Jacobs
-
JavaWhat's the Difference Between Java and JavaScript?Tom McFarlin
-
Ionic 2Code Your First Ionic 2 App: Getting Set UpWernher-Bel Ancheta
by Bala Durage Sandamal Siripathi via Envato Tuts+ Code
Dunkirk WebVR
by via Awwwards - Sites of the day