Popular

Trending

Sass 3.3 – MAPTASTIC MAPLE

How Do Deepfakes Work and Why are they a Problem

If you are someone that regularly accesses the internet, then you are bound to be more than familiar with deep fakes. In fact, in the last year or so there has been a lot of controversy surrounding deep fakes, as they have been used to put a lot of the world’s leaders in some compromising situations, this includes the queen and even Donald Trump.

Though the world is becoming more familiar with the world of deep fakes, there are still plenty of things that we don’t know about them, like how they work and the problems they could cause in the future.

What are deep fakes

For those of you that don’t know what deep fakes are, deep fakes are when you take the image of someone and edit it into compromising and untrue circumstances. What is so notable about deep fakes is how realistic they look. Unless you were to scrutinize the video or the image closely, it is unlikely that you would even notice that the images that you are seeing are deep fakes. This is why deep fakes have become so popular because it creates the possibility of celebrities and even ordinary people being in circumstances that you would not expect to find them in, but how does deep faking work?

How do deep fakes work?

In order to create a successful deep fake, you are completely reliant on something called artificial neural networks. These networks are systems that recognize recurring patterns in faces and if you give the system enough images to work with, then it should be able to pick up enough similarities to be able to manipulate the face into circumstances and situations that you want to put it in.

Why are they a problem

Though deep fakes can be great for creating projects, they create more problems than they actually fix.

Recently a lot of  YouTubers have been using deep faking to make it appear as though a celebrity has appeared in their video as a way to increase their views. This seems redundant as you can buy youtube views on themarketingheaven without any moral implications. This is extremely unfair for celebrities that depend on the money that they make through appearances to make an income as the people that are using their faces are not giving them any of the profit that they make from their videos, which is arguably extremely wrong of them.

Politics

You may also be aware that deep fakes were used in the world of politics very recently. People created videos that looked as though some of the biggest politicians out there were making threats against other countries and these videos even included talk of nuclear weaponry. Thankfully, no action was taken before these videos were found out to be deep fakes. However, absolutely anything could have happened because of these videos which show just how dangerous deep fakes can be. You never know what famous politician people will use next and what devastating effect it could have on the world.

Pornography

Another way in which deep fakes are having devastating effects on the world is through the porn industry. Deep fakers are taking the faces of well-known celebrities and adding them to porn videos in order to cater to a niche market. There has been a lot of debate on whether or not this is morally wrong, but it is hard to deny that it isn’t ok to steal someone else’s face and put them in a sexually compromising position as a source of monetary gain.

Smart Clothing: What is it and Why It’s so Effective

What is it? 

Smart Clothing is a range of activewear for men and womenit is essentially clothing items that have been enhanced with technology such as sensors and hardware to function in a way that no other clothing would. Many pieces of smart clothing require the individual to connect up to an app via Bluetooth or WIFI. The purpose of smart clothing is to monitor the person’s physical condition, usually while exercising, to track and monitor data such as pulse, temperature, heart rate, muscle strength, etc. However, more recently, various brands and companies have been creating smart wear clothing that is not for the purpose of the exercise. For example, Snapchat brought out glasses that allow the user to take high-quality photos and videos.  

Benefits 

Comfortable:  

A lot of people don’t like the idea of wearing anything uncomfortable when exercising and you can understand why; you want your exercising session to be as enjoyable (as possible) and you do not want anything getting in your way or distracting you. People have reported feeling uncomfortable wearing trackers such as Fitbit on their wrist, as it often gets very sweaty underneath or becomes too tight when swelling occurs from working out. This is why smart clothing is so effective- there are so many different forms of smart clothing that there is something to suit everyone. The Athos or Hexoskin shirt just looks like any other shirt, meaning you are comfortable and are not required to put anything extra on your body, you just wear it how you would your everyday clothes. The same as the Lumo Run smart running shorts which have been designed to just appear and feel like an ordinary pair of shorts or the OMsignal OMbra which has been carefully created to ensure it gives the same comfort and support as a regular sports bra.  

Improved data accuracy:  

For people wishing to track things like steps, accuracy is a big deal, as what’s the point if the number you are given at the end is not an accurate representation of your progress? Some of the trackers that are available today, such as those you wear on your wrist, actually count steps even when the person is moving their arm up and down- as the device thinks the person is walking or running. Therefore, this is not accurate enough. Smart clothing companies have been continuously working on this and have found that to make the data accurate, you need to move the sensors closer to the exact area it is required to monitor. The majority of smart shirts use a reliable heart rate monitor and the shorts are equipped with muscle motion sensors that monitor the part of the body that does the most moving when you are running. One of the things that make smart clothing so effective is that due to increasing the area being monitored, the richer you are allowing the biometric data to be.  

Various purposes:  

While we immediately think of those who wish to complete workouts when we hear about this sort of thing, Smart Clothing could actually have many other uses that could become so important. For example, Bloomer Tech’s heart disease detecting smart bra could become very effective for monitoring the health of patients in hospitals but also people at home. The Owlet Smart Sock is able to monitor babies’ pulse and heart rate, this could be used in hospitals when a child is taken ill, but also for parents to be reassured that their baby is breathing and their sleep has been uninterrupted. 

Everything About Tech-SAAS

Technology is an essential thing in times like now. It has so much to offer to individuals and makes their life less complicated and easier. The SAAS (Software as a service) is a legal instrument that governs the use and redistribution of the software. The software is distributed on a subscription basis and is usually hosted centrally. It is also referred to as “on-demand software” by Microsoft besides being called the Web-based software, hosted software, etc. Hundreds of people use this particular software in their day-to-day lives for home and office purposes. 

It is also a part of the cloud computing software that makes sure the storage and the availability of the resources are managed well. All the SAAS apps are usually accessed by the users who use a thin client that is simple and low-maintenance via the use of a good web browser.

It is the most common software model that is used daily for applications like office software, payroll software, messaging software, management software, CAD software, gamification, virtualization, Customer Relationship Management (CRM), invoicing, human resource management, learning management systems, Content Management (CM), service desk management, etc. Besides, SAAS has incorporated a strategy of all the leading software used by big companies. The sale of SAAS is likely to grow up to 23% that is about $72 billion.

History of the software 

The centralized hosting of applications using SAAS first started in the 1960s. IBM offered it as it is conducted using a service bureau business facility referred to as time-sharing and utility computing. These services are offered to big banks and other organizations from data centers all over the world. The software has brought about an entirely new class of centralized computerization. SAAS has emerged as the biggest sub-variety of a cloud database. 

Distribution and price of the software 

The cloud SAAS model does not require a physical distribution system as it is done indirectly and deployed instantaneously, which negates the need for all the traditional partners and intermediaries. Unlike all the other perpetual licenses, SAAS does not require an up-front cost. Rather it charges a subscription amount that can be either monthly or annually. The cost of setting up SAAS software is comparatively less than the other usual software, and the vendors typically charge it depending on the number of people using the application at a time. Usually, the customers reside with the SAAS vendors, and the money charged while using the application.

The low cost of setting up new customers in a multitenant environment allows people to enable all the SAAS vendors to come and offer applications that mostly use a defined freemium model. Through this model, the free services are offered with limited functionality as well as scope. The vendors use a key driver for the growth and to provide competitive on-premise software. 

Characteristics of the software 

  • Configuration and customization: all the SAAS applications are typically known as the application configurators. The customer can easily alter all the configuration options that further affect the functions and look of the software. Every customer molds the settings as per their convenience and the designs they like
  • Featured delivery system: the SAAS software has to be updated more than all the other traditionally used software programs. Certain factors enable its use, some of which are:
  1. Hosting of the application to be done centrally because, in this case, the update is decided as well as executed by the providers and not the customers
  2. The application should only have a single level of configuration that helps make the process of development faster. 
  3. The applications’ vendors do not expend their resources by updating and maintaining every backdated software version again and again. This is because there is only a single version of the same.
  4. The vendor of the application gets access to all the data that belongs to the customer and expediting design and testing using regression.
  5. The solution provider gets access to all the user behavior within the application.  
  • Using open integration protocols: as SAAS software does not have access to the company’s internal systems, they usually offer integration protocols along with API’s (Application Programming Interface). The software operates over a wide network and has spawned the mashup development as they are lightweight and help combine the data. All this helps in creating compound services. 
  • They have a collaborative function: the software is inspired by all the services on the networking sites. Several SAAS applications provide collaborative features as well as share information.

Advantages of SAAS 

The following are the advantages of SAAS:

  • It helps in flexible payments: customers opt for this software as it does not include complications of purchasing the entire software or having additional hardware to support it. This service thus makes use of the pay-on-the-go option. The offerings of SAAS can be terminated whenever the individual wants to stop all kinds of recurring costs. 
  • It has a scalable usage: cloud services like SAAS offer high vertical scalability as it gives greater access to the customers to choose a few or more services. 
  • They come with automatic updates: rather than purchasing new software every time, people using SAAS software can update it every few days. It also ensures patch management and helps reduce the burden on the IT staff of any organization.
  • They have accessibility and persistence: because all the SAAS loaded applications are delivered to the individuals over the internet, they get easy access to any internet-abled device and location familiar to the applications. 

Besides, many other models support the software and help in a smooth functioning and a good-quality infrastructure and services offered. Thus, getting access to SAAS enabled software is important for all the big enterprises and organizations using the software. It is the greatest software that makes the life of individuals easier.              

What Is Saas, And Why Do Users Prefer Such A Tech?

Understand the SaaS technology

SaaS or the Software as a service means that the users can connect their cloud-based application through their internet. The most prominent examples of such services are calendering, emails, office tools, etc. The users get a software solution through the SaaS model. Here, you can rent the apps according to your usage for your firms. The users will connect to them using their internet. The data center of the service providers locates the data of infrastructure, app software, and middleware. There will be a service agreement with appropriate terms and conditions to ensure the security and availability of the application and the data.

Know the characteristics of SaaS

Understanding the characteristics of Saas is a straightforward procedure. Let us have a look at some of them.

  • The Saas model will have multitenant architecture. Therefore, all the applications and their users will share a common infrastructure wherein they maintain the codebase. That allows all the vendors to bring in innovative ideas and save their time in developmental projects. That way, it will sit to control the outdated code versions.
  • Saas model provides easy application customization possible. It architects in a certain way to update the users at every time due to the same infrastructure. Therefore, they can go forward with the latest upgrades, and it is less risky as the adoption cost is also low. So, it is a pocket-friendly method to adopt and practice.
  • The SaaS model will provide better access to the information from their network devices. That way, it manages to make the controlled privileges possible. You can also monitor the data usage and make sure that every user is visible to the same data at a particular time. That also allows knowing that people are looking at the same mindset towards things.
  • The SaaS model harnesses the web operations of the consumer. People familiar with My Yahoo and Amazon know about such web interfaces in the applications. So by pointing the arrow and clicking on it, and customize the process. That way, you will not have to depend upon updating the business software. It is a much-upgraded version to make things easier.
  • Some organizations are developing integration platforms for SaaS. You can also call them the SIPs, and they use them to build the additional applications for SaaS. Here, the SaaS will move beyond the limited software functionality and become the mission-critical applications platform. They are bringing up these new trends for efficient working.

Advantages of adopting Saas

the users will find a lot of benefit from the usage of SaaS. Let us have a look at some of them.

  • The SaaS model will provide access to all the sophisticated applications to the users. Here, they will not have to buy, update, or install this hardware and software. It will allow the users to manage complicated enterprise applications like CRM and ERP, affordable to those firms who do not have enough resources to get them.
  • The SaaS model will save a lot of money here. The users will pay only for what they are using. It will also scale upwards and downwards depending upon your usage level. So you do not have to worry about paying more than what you are benefiting from always.
  • In This model, the users have the benefit of running the application of SaaS from their web browser. Therefore, you do not have to install or download this software. But there are some plugins required. Therefore, there is no need to purchase them for the users.
  • The SaaS model is one of the ideal ways to mobilize the workforce with great ease. It is because you can have access to their applications from your mobile devices. There are many computers wherein most of the developing apps do not run. Here, you do not have to look for such things. It does not require expertise in onboarding for controlling the security issues for computing. The service providers will look after your data security no matter which device you are using.
  • Your mobile device will store all the pieces of information in the cloud. Therefore, you will have access to them anywhere you want. Wherever you get the internet connection, the app will store these pieces of information in your cloud. That way, you do not have to worry about losing your data even if your mobile or computer stops working.

Disadvantages of the SaaS model

There are some disadvantages of the SaaS model as well. In such a scenario, the businesses rely their work on the outsiders for providing the software. For tracking reports, running the software, reporting billings, you have to look out for other vendors. These things can lead to disruptions, imposing unwanted changes, finding a security breach, and many more. So, you should understand the service-level agreement of the SaaS providers. 

That way, you can make sure to enforce it without any complications. You can get rid of such problems with great ease. The occurrence of such cases is minimal. But, it is better to look out for the possible mistakes and issues. It will help you to understand these models better.

Customization of the SaaS data

The web-based software can modify the business uses and their users. You can change the feel and look of their program by customizing the user interface. You can also modify areas like data fields to understand what happens next. It also allows to turn off and on the features of the business process. You can manage your workspace and show others only what you want them to see. 

You can also customize the SaaS systems and the on-premise from every corner for client deals. The cloud-based software will provide better flexibility and agility for the companies in such matters. Therefore, it will give the users a lot to learn and understand. You can create a professional workspace wherein you can choose the way you want to deal with things. So why wait for more? Go online and check out various sites to know more about them and their services.

Everything You Need To Know About SAAS And Its Benefits For Your Business

We live in an age where most of our work is done through computers. Technology is growing at such a fast pace that the whole world is getting digitalized. Saas or software as a service is something that has made this lot easier and affordable. Cloud computing is an example of the saas. 

Gone are the days where you needed a server for all your business applications, manage your finances, human resources, managing your supply chain, and so on. Though it seemed fine back then, it is now an outdated thought. With saas, you can do all this over the internet and pay as you use. You need not buy expensive servers or other software or hardware for your business needs; it is done through the internet.

What is saas?

Saas is the process of using any software you need to gain access to your required data through an internet connection. You can access the data through any device. The saas application has several names like web-based software, on-demand software, or hosted software, and they are run on the saas provider’s servers. The service provider manages all that is needed for smooth performance, like easy access to the application, security, availability of data, and performance.

The characteristics of saas

  • Protects the privacy of each customer

The privacy of every customer is protected by providing reliable and secure service. The users do not have to worry about any third party accessing their account.

  • The SAAS has a multitenantmultitenant architecture

 The SAAS uses multitenant architecture as all the users use a common infrastructure and code base maintained centrally.

  • Easy customization

The user can easily customize applications according to his business needs without affecting the main infrastructure. The SAAS providers keep the users up to date through regular updates.

  • Improved access

The user gets better access to any data through any device, and it also makes it easier for the user to manage and monitor data use.

How does SAAS help you?

Software as a service is completely different from the traditional methods. If you are a user of SAAS: 

  • You have to pay a monthly or annual subscription to the cloud provider, and you get the software through the internet. It all happens in their data centers and servers, and they are responsible for maintaining it so that you can use it without any complications.
  • Your monthly subscription includes patching, security, maintenance, and upgrades. You don’t need to worry about any of it, and it is all the responsibility of the cloud provider.
  • You are always up to date as the provider updates it regularly. These updates provide you with new functions and capabilities.

So SAAS has all that you need, minus the headaches. No need to reprogram old software so that it can handle the current situations. You are always using the new version with SAAS.

What makes SAAS different?

Usually, you can buy software on a perpetual license basis, where you can pay for a single license and use it as much as you want. You need to pay the software vendors a small maintenance fee yearly. But when it comes to SAAS, you need to pay as a subscription on a monthly or yearly basis. But why do people still prefer SAAS?

There are many reasons for this. A few of them are:

  • Perpetual license software depends a lot on operating systems, and they do not work on any other operating systems other than the one they are designed for.
  • There is no or very little incentive for developers to update the software to a newer version. So when a new update comes, the software companies usually drop the older version and go for the newer ones.
  • Many applications need expensive hardware or servers to run the application internally. And most of the applications require a specialist to run the program or enable it to run internally. If something goes wrong, it needs to be fixed immediately. Otherwise, the business may lose valuable data.

So with all these problems, the business ends up spending a lot of money on operating costs. SAAs, on the other hand, can be a perfect solution to all of these problems.

The benefits of SAAS

  • The software is delivered via a web browser, so there is no need for any operating system. If your device can run a web browser, then SAAS can help you with anything.
  • SAAS runs all the software on its data centers and servers in the cloud or internet, so the user need not spend any money to maintain any expensive hardware and no need to hire an IT specialist to do the work. SAAS has its team of support staff, so the users save both time and money.
  • SAAS updates its software frequently, and the subscription you provide makes them respond immediately to any bug problem or any other issues.
  • The privacy risk is also reduced as the software is affordable and cannot be stolen. It is a straight forward policy of pay and use. If you do not pay, you will not be able to access it.

A few examples where SAAS is used effectively

  • Zen desk
  • Shopify
  • Dropbox
  • Hub spot
  • G suite
  • Adobe creative cloud
  • Microsoft office 365

Great for any business

SAAS can be used for any business. It is not complicated or does not need any specialist to work it out. It is also cheaper and faster than any other traditional method. So it is being used for many business needs. With more and more business owners opting for cloud-based computing, SAAS is the perfect solution. The software vendors need to keep their software always updated to remain in the competition. As the competition grows, the cloud-based products will become cheaper automatically, making it affordable for new startup companies to start their business without any worries. To stay ahead in the competition and subscribe for SAAS today and make your business ready for this competitive market.

Beginner’s Know It All Guide To SAAS

The Internet provides people with advanced features that are being used widely to increase various processes’ efficiency. One such feature is SaaS, which is a part of the cloud computing system. If you know what cloud computing is, then knowing about SaaS is also essential for you. You may not know about SaaS right now; however, after learning about the term in detail, you will understand how it can prove extremely beneficial in various contexts.

The SaaS (Software as a Service) technology has gained a lot of popularity over the years, so various businesses are already using this service. You might not know it, but you would have also used various SaaS services in your day to day life.

What is the SaaS technology?

Software as a Service is a technology that allows for a specific model that promotes software distribution or delivery in the form of service over the Internet. It will enable the third-party host to deliver an application service online without the user having to download the software and maintaining it throughout. The users can access the cloud-based application on the Internet by just visiting a particular website or server. This lets the users avoid dealing with the complex systems of software management.

In terms of cloud computing, SaaS is not the only cloud computing category that could be used online. Two more types are known as PaaS and IaaS. The SaaS technology is connected to the ASPs (application service providers). This is a convenient form of accessing the applications as it doesn’t require much maintenance and provides security, performance, and other benefits.

Some examples of SaaS technology-based online applications are Email clients, online office tools, calendar systems, and more. You might have already used some of these apps but only now do you know that these are based on SaaS technologies.

How do the typical applications work over with the SaaS technology?

As with the popular email clients and other SaaS applications, their functioning is quite simple. All you have to do to use these services is to have a mandatory internet connection. You also need to have a device that lets you access the Internet. These services are not directly downloaded to your system, but they exist over the host company’s servers. As you access their servers through your web browser, you will be able to use the application as intended. For example, in an email client, you can quickly sign in to your email ID and promptly read all your emails.

Generally, these applications may be free-to-use. However, they have their ‘premium’ versions that might charge you some sort of fee for advanced features. It also may charge a fee for additional features and the license to use them for corporate purposes.

There are various advantages of using SaaS applications as a consumer. It is a technology that has relatively fewer shortcomings and a large number of benefits to the users. Some of them have been listed below:

  • Pay for the specific service that you have received:

The SaaS model of applications lets the users avoid spending money on unnecessary services that they do not even require. The users are allowed to pay only for those services that may be of use while avoiding any payments related to the services they do not use. For example, you can choose whether you want a premium service or not, and you will only be required to pay if you willingly opt for the premium plans.

  • Access your data from anywhere through any platform:

The SaaS applications are available to be accessed through the Internet. As long as you have a device with internet access and a web browser, you should be able to open the SaaS applications. This means that your data can be access from any device, no matter where you are. You can start doing your work on your laptop in your office and later switch to working on your phone when you reach your home at your convenience.

  • Receive updates regularly:

As these applications generally exist over the cloud computing systems and exist virtually on the host’s servers, it is easy to keep these services updated. The host can integrate all the updated services right into the application online. When the user visits it, they will be able to access the updated model without any issues.

  • Ease of use:

The SaaS applications are easy to use as they generally have a user-friendly interface. They are efficient and convenient for users as they don’t need to regularly maintain or download any complicated software. They also do not have to integrate a proper software management system for these applications.

  • Flexibility and Scalability:

The SaaS system is flexible and scalable as the host party can make any changes in the application over the cloud system online. They can quickly get features on-demand and customize their services as they like, depending on the user requirements. With low costs of software maintenance, it is possible to make changes on the go easily. The host party can also maintain their software with hardly any expenses. This makes it easy to scale the software if required. This also makes the service flexible as the changes can be made instantly whenever the need arises.

  • Free software usage:

The SaaS applications over the Internet are mostly free-to-use for anyone who is not interested in the premium services. For example, most online email clients are free for the people as they can check their emails online without making any payment.

The SaaS technology seems to be thriving in recent years due to the large number of benefits it provides. It is the right way of starting an applications service and very convenient for the consumers. Learn more about SaaS now!

Cubic Bézier representation in Sass

It all started when Tim Severien showed me a pen where he managed to display a Bezier curve with nothing but Sass. After a couple of hours of fiddling, between his math/geometry knowledge and my love of Sass, we came up with a neat little tool to display a Cubic Bezier function in Sass. This is the story of how we built that tool.

But before we get too far, let me turn it over to Tim to catch us up on some basic knowledge regarding Bezier functions. Tim, please.

(Note: if you’re only interested in the code, please head straight to CodePen.)

What is a Bézier curve?

In computer graphics, creating curves was quite a complex task. In 1959, physiscist and mathematician Paul de Casteljau, who worked at Citroën, developed an algorithm that helped create curves for car designs. Mathematician Pierre Bézier adopted the algorithm to design the curvatures for Renault. In 1962 Pierre widely publicised what we now know as the Bézier curve.

The curve is used across many fields in computer graphics. Most digitally produced curves are made using this algorithm. Think of your car, phone or the font you’re reading. It was also adapted in less visible fields, like easing transitions.

The most known implementations are vector paths in 2D and 3D graphics software. A path usually consists of many points connected by lines. Each line gets one or two “control points” to that determine the curvature.

To create Bézier curves, a basic understanding of linear interpolation is required.

Linear interpolation (or lerping), is finding a point between two points (or along a line). It’s likely you’ve done this before, but in one dimension.

Imagine you have two numbers, 3 and 7. Supose you needed to find the number exactly between these numbers. The difference between 7 and 3 is 4. Adding half of 4 to 3 makes 5. So 5 is the correct answer. That’s exactly how linear interpolation works, but instead of dealing with numbers, we’re dealing with points in a 2D or 3D space, thus you have to do this two or three times.

To lerp, we need to know two points, and a number that indicates the progress along the line. This number is a decimal between 0 and 1 and indicates how far along the line the result should be. Just multiply this number with the difference between the two points. The start would be 0, the end is 1 and 0.5 would be halfway on the line.

The first step is to get the difference between the two points:

(p1 - p0)

Then we need to multiply the difference with that third number I just explained:

(p1 - p0) * t

Finally, the minimal value is added:

p = (p1 - p0) * t + p0
Lerping

To get a point along a curved path, we do this for every line along the path. If the path consists of more than two lines, we get two or more interpolated points, and multiple points makes a line which can be lerped as well. This simply repeats until we have one single point left.

Lets try this with three points:

p0 = (0,   0)
p1 = (0.4, 0.8)
p2 = (1,   1)

t = 0.4

// First iteration
i0 = lerp(p0, p1, t)
i1 = lerp(p1, p2, t)

// Second, final iteration
p = lerp(i0, i1, t)

A Bézier of three points is called a Quadratic Bézier.

Quadratic bezier

We can do this for four points as well which requires a third iteration:

p0 = (0,   0)
p1 = (0.3, 0)
p2 = (0.6, 0.8)
p3 = (1,   1)

t = 0.6

// First iteration
i00 = lerp(p0, p1, t)
i01 = lerp(p1, p2, t)
i02 = lerp(p2, p3, t)

// Second iteration
i10 = lerp(i00, i01, t)
i11 = lerp(i01, i02, t)

// Third, final iteration
p = lerp(i10, i11)

A curve of four points is called a Cubic Bézier.

Cubic bezier

As stated before, the amount of points is irrelevant, so we can use five points, or six, or seven!

High order bezier

As you add more points, the more coordinates play a part in the final curve, making it increasingly difficult to add desired detail. This is why the Cubic Bézier curve, the curve with four points is most common. If you’re familiar with software like Illustrator, you will know that between two points, you get two control points, which makes four.

Note: if you haven’t already, I highly recommand you to watch this 4 minute video about the way Bézier curves are drawn by a computer. Fair warning: ah-ha moment triggerer.

Coming back to Sass

Okay, at this point you should be in a pretty good shape to understand cubic Bézier functions. But why is this related to Sass in any way? Well, CSS transitions and animations heavily rely on cubic Bezier functions. Both transition-timing-function and animation-timing-function properties support a cubic Bézier function described with cubic-bezier().

Such a function can be reprensented on a 2-axis plan with the transition/animation progression along the Y axis, and the time along the X axis. A curve is then drawen on the graph, representing the timing function.

What we'll come up with

This is what we wanted to achieve. Although we wanted a very simple API, something like:

.grid {
  @include cubic-bezier(.32, 1, .53, .8);
}

Basically exactly like the cubic-bezier function from CSS. We can also add an extra argument to pass a map of options if defaults are not convenient enough (see below for an explanation of the available options):

.grid {
  @include cubic-bezier(.32, 1, .53, .8, (
    'control-points': true,
    'informations': true,
    'size': 300px,
    'color': #999,
    'details': 64
  ));
}

Let’s see how we did it.

Implementing the math part

Luckily, Sass provides basic mathematical operations like addition, subtraction, multiplication and division. Enough to create some basic curves. Because CSS lacks a drawing API to draw lines, I chose to use box-shadow on one element to mark some points along the path, generated using Sass.

It all starts with linear interpolation. I already showed you how that works.

/// Linear interpolation
/// @author Tim Severien
/// @param {Number} $a
/// @param {Number} $b
/// @param {Number} $p
/// @return {Number} Return a number between `$a` and `$b`, based on `$p`
@function lerp($a, $b, $p) {
  @return ($b - $a) * $p + $a;
}

However, Sass doesn’t do arithmetic operations on maps or lists. Linear interpolation only works with numbers, so an extra function is required to lerp on each axis, assuming a point is a list of two numbers:

/// Linear interpolation points
/// Arithmatic operators only work for numbers, so lerp the X and Y axis seperately
/// @author Tim Severien
/// @param {Number} $a
/// @param {Number} $b
/// @param {Number} $p
/// @return {List}
@function lerp-point($a, $b, $p) {
  @return lerp(nth($a, 1), nth($b, 1), $p), lerp(nth($a, 2), nth($b, 2), $p);
}

At this point, we have to apply the interpolation. Remember that a the amount of points for a curve is irrelevant, and that you can recursively calculate the interpolated points? This all looks very similar to the well-known reduce() function; just do [something] until there’s one left. In this case, that something is lerping.

/// Bezier Reduce
/// @author Tim Severien
/// @param {List} $points
/// @param {Number} $p
/// @return {Number}
@function bezier-reduce($points, $p) {
  // Keep lerping until one point is left
  @while length($points) > 1 {
    // Temporary list containing the newly lerped points
    $tmp: ();

    // Iterate through all (current) points
    @for $i from 1 to length($points) {
      // Add lerped point to the temporary list
      $tmp: append($tmp, lerp-point(nth($points, $i), nth($points, $i + 1), $p));
    }

    // Replace old points by new interpolated list
    $points: $tmp;
  }

  @return nth($points, 1);
}

All that remains now is generating a sequence of points to display the graph and to generate the shadows:

/// Bezier shadow
/// @param {List} $points - List of points from Bezier
/// @param {Number} $detail - Number of particles
/// @output box-shadow
/// @author Tim Severien
@mixin bezier-shadow($points, $detail) {
  // Create a list of shadows
  $shadow: ();

  @for $i from 0 to $detail {
    // Get the point at $i / $detail
    $point: bezier-reduce($points, $i / $detail);

    // Create a new shadow for current point
    $shadow: append($shadow, nth($point, 1) nth($point, 2), comma);
  }

  box-shadow: $shadow;
}

Implementing the API

I won’t dig too much into the code since it’s mostly writing CSS at this point, still I’ll explain the logic behind our API, especially the cubic-bezier mixin, dealing with configuration, and such.

@mixin cubic-bezier($x1, $y1, $x2, $y2, $options: ()) {
  $options: map-merge((
    // Enable/disable control-points
    'control-points': true,
    // Extra informations
    'informations': true,
    // Size of the grid
    'size': 300px,
    // Color scheme
    'color': #999,
    // Points from the curve
    'points': ($x1, $y1, $x2, $y2),
    // Number of dots on the curve
    'detail': 30
  ), $options);

  @include draw-system($options);
}

As you can see, this mixin only deals with configuration. All it does is merging the given configuration, if any, with the default one. Then, it calls the draw-system mixin with the configuration as only parameter.

@mixin draw-system($conf) {
  width: map-get($conf, 'size');
  height: map-get($conf, 'size');
  position: relative;
  color: map-get($conf, 'color');
  border-left: 2px solid;
  border-bottom: 2px solid;
  border-top: 1px dashed;
  border-right: 1px dashed;

  @if map-get($conf, 'informations') {
    &::after,
    &::before {
      position: absolute;
      bottom: -1.75em;
      text-transform: uppercase;
      font-size: .75em;
    }

    @if map-has-key($conf, 'name') {
      // Display name
      &::before {
        content: "#{map-get($conf, 'name')}";
        left: 0;
      }
    }

    // Display values
    &::after {
      content: "#{map-get($conf, 'points')}";
      right: 0;
    }
  }

  // Print the curve
  > * {
    @include draw-curve($conf);
  }
}

If the informations key from options map is truthy, it means we have to display function’s informations under the graph. To do this, nothing like pseudo-elements: ::before for the name (if there is a name), and ::after for the function parameters (e.g. 0.42, 0, 0.58, 1).

Then, it calls draw-curve mixin.

@mixin draw-curve($conf) {
  // Print the wrapper
  @include draw-curve-wrapper($conf);

  // Print the dots
  @include draw-dots($conf);

  // Print the control-points
  @if map-get($conf, 'control-points') {
    @include draw-control-points($conf);
  }
}

We’ll skip draw-curve-wrapper since it does nothing more than a couple of boring CSS lines. Moving on to draw-dots. This is where Tim’s work and mine meet.

@mixin draw-dots($conf) {
  $points: map-get($conf, 'points');
  $size: map-get($conf, 'size');

  &::after {
    content: '';
    @include circle(4px);
    @include absolute($left: 0, $top: 0);
    @include bezier-shadow((
      0 $size,
      (nth($points, 1) * $size) ((1 - nth($points, 2)) * $size),
      (nth($points, 3) * $size) ((1 - nth($points, 4)) * $size),
      $size 0
    ), map-get($conf, 'detail'));
  }
}

Regarding draw-control-points now, it gets called only if control-points key from map is truthy. Controls points are the blue and red dots, as well as the lines joining the dots to the corners of the graph.

The way they are drawn are kind of tricky I must say (also quite complicated, so I won’t display the code here). Basically, it consists on two pseudo-elements with their diagonal displayed thanks to a linear-gradient and some geometry magic using atan function (from Compass).

(Note: if you don’t use Compass, you can use this (Ruby) implementation from Sassy-Math, or this (Sass) one from Ana Tudor.)

Final thoughts

This expirement was fun, but really not very useful in practice. It can give you an idea of what a besier curve looks like and how it is manipulated, but it probably won’t change your life if you write Sass for your day job.

If you need to create your own cubic-bezier animation function,this tool from Lea Verou would probably be more useful.

I hope you enjoyed this experiment. You can play with the code on CodePen:

See the Pen Cubic Bezier functions visualize by Hugo Giraudel (@HugoGiraudel) on CodePen.

Inverse trigonometric functions with Sass

You might think that math doesn’t have a lot to do with writing stylesheets, but you can actually do some amazing things with a little math in CSS. Math (particularly trigonometry) can help you model the real world. You’ll need it if you want to do something complicated with 3D transforms. And it can be a lot of fun if you just want to impress your friends.

Here’s an example:

See the Pen Pure CSS 3D animated icosidodecahedron (pentagonal gyrobirotunda) by Ana Tudor (@thebabydino) on CodePen.

his rotating icosidodecahedron is an advanced example of what you can do with trigonometry in CSS. If that’s over your head, check out Mason Wendell‘s Sassy Mother Effing Text Shadow demos. Mason makes great use of Compass’s sin() and cos() functions to do some fun stuff with CSS shadows.

I’m a bit of a trigonometry nerd. (Okay, that’s probably an understatement!) Sometimes the standard trig functions aren’t enough for me. While working on a couple of 2D and 3D CSS demos, I found myself needing to compute the values for angles whose sine, cosine, or tangent was known. I needed asin()acos(), and atan(). Unfortunately, Compass doesn’t provide these functions so I was left with two options:

  1. Manually compute the values I needed with a calculator (boring!)
  2. Write my own functions with Sass!

Naturally, I chose the second option!

Fortunately for me, I stumbled across an article about writing sine and cosine functions in Sass using Taylor expansions. It occurred to me that I could adapt the same method to create the functions I needed.

Disclaimer: This is about to get super Math heavy. If you just want to see how the final implementation, skip ahead and look at this pen.

Trigonometry 101

Before we get too far let’s go back and review some basic high school math.

right triangle
A right triangle

This diagram should look somewhat familiar. (If it doesn’t, check out MathBFF’s video on YouTube: Basic Trigonometry: Sin, Cos, Tan.)

Let’s review a couple of formulas. In the right triangle diagram above:

In radians, that’s:

Most people will also remember that the Pythagorean theorem tells us:

Our basic trigonometry functions are defined as follows:

Knowing this, we can derive a few additional formulas:

Head spinning yet? Hold on to your hats…

The arcsine function

So what is an arcsine? Well, if:

Then, the arcsine is the inverse of this:

In other words, given an angle’s sine, arcsine can tell you the angle. Arccosine and arctangent are similar in that they give you the angle based on a cosine or tangent.

We are going to build an asin() function in Sass to give us the arcsine. And we’re going to do it using series expansion. Taylor series expansion is complicated if you are not a math wiz. I’ll do my best to explain. For arcsine it looks something like this:

Now don’t freak out on me. Let’s deconstruct this: =$z$= is the value of the sine of the =$\alpha$= angle we want to get. The entire sum is the radian value of =$\alpha$=. =$z$= should be a value in the =$[-1, 1]$= interval, while the sum is going to be in the =$[-\pi/2, \pi/2]$= interval.

Every term – including the first one, which you can also write as =$(1) \cdot z$= – is made up out of two parts: the first one is the part inside the parentheses and the second one is the part outside the parentheses.

For every =$i$=-th term but the first one, the first part is the first part of the previous term multiplied with =$(2i – 1)/(2i)$=. The numerator of the second part is =$z$= raised to the power =$2i + 1$=, while the denominator is =$2i + 1$=.

This may be an infinite sum, but once we get to a certain term, the values for the terms after it become so small they are really negligible which (for our purposes) means we can safely ignore them.

But where do we stop? Let’s say at a tenth of a degree. The value of one degree in radians is =$\pi/180 \approx 3.14/180 \approx .0175$=. So a tenth of that is =$.00175$=. So when we get to a term that’s smaller than =$.00175$=, we stop and whatever value we got up to that point is good enough.

Let’s take a few examples.

=$z = 0$=. This is a really easy one because all the terms are =$0$=. So the unitless radian value computed with the help of the series expansion is =$0$= and the degree value is =$0\cdot180°/\pi = 0°$=.

=$z = 1$=. The first term is =$1$=, the second one =$1/6 = .167$=, the third one =$3/40 = 0.075$=, the fourth one =$.045$=, the fifth one =$.030$=, the sixth =$.022$=, the seventh =$.017$=, the eighth =$.014$= and we notice we have a problem. While the terms are obviously decreasing, this decrease is really slowing down and we’re still pretty far from our threshold value of =$.00175$= that would allow us to stop.

But how far are we at this point from the correct value? Well, if we sum up the terms we have so far:

This radian value translates into =$85°$=. Not worlds apart from the correct value, which is =$90°$=, but now it’s starting to be increasingly harder to get closer. This leads to too much looping and a slower function. It’s one problem that, although to a lesser extent than in this particular case, we have in every situation where the result in absolute value should be in the upper half of the =$[0, π/2]$= interval.

What we can do to solve it is first check if the resulting angle in absolute value is over =$\pi/4$= and, if it is, we compute its complement (the =$\pi/2 – |\alpha|$=) using this method. Since the sine function is a monotonically increasing function over the =$[0, \pi/2]$= interval, what we actually check is whether the absolute value of =$z$= is greater than =$\sin(\pi/4)$=.

But how do we know the sine of the complement of our =$α$= in absolute value? Well, it’s equal to the cosine of =$\alpha$= in absolute value: =$\sin(\pi/2 – |\alpha|) = \cos(|\alpha|)$=. And since =$\sin^2(|\alpha|) + \cos^2(|\alpha|) = 1$=, we get that =$\cos^2(|\alpha|) = 1 – \sin^2(|\alpha|) = 1 – z^2$=.

Coding the asin() function

Whew! That’s a lot of math! Let’s take a look at some code.

First of all, we set a default threshold value for the terms of our sum:

$default-threshold: pi()/180/10;

Then we start to write our function:

@function asin($z) {
  $sum: 0;

  @if abs($z) > sin(pi()/4) {
    $z: sqrt(1 - pow($z, 2));
  }

  @return $sum;
}

We set the sum to be initially 0 and make sure we’ll compute the complement if our angle in absolute value is greater than pi()/4. But after that, how do we know we’ve computed the complement in order to switch to our initial angle?

In order to keep track of that, we introduce a boolean variable, $complement, which is initially false, but gets switched to true inside the @if block. Also, before returning $sum, we check if the $complement variable is true and, if it is, we return pi()/2 - $sum.

@function asin($z) {
  $sum: 0;
  $complement: false;

  @if abs($z) > sin(pi()/4) {
    $complement: true;
    $z: sqrt(1 - pow($z, 2));
  }

  @return if($complement, pi()/2 - $sum, $sum);
}

But this only works right for positive values, so we need to introduce a $sign variable that can be 1 or -1. We also make $z equal to its absolute value for all intermediate computations and multiply with the sign at the end. So our code becomes:

@function asin($z) {
  $sum: 0;
  $complement: false;
  $sign: $z/abs($z);
  $z: abs($z);

  @if $z > sin(pi()/4) {
    $complement: true;
    $z: sqrt(1 - pow($z, 2));
  }

  @return $sign * (if($complement, pi()/2 - $sum, $sum));
}

Now let’s start to actually add up terms to the sum and set the condition that we stop once we got to a term whose value is smaller than the threshold value which we pass to the function. The first term is $z, so we set that before our @while loop.

@function asin($z, $threshold: $default-threshold) {
  $sum: 0;
  $complement: false;
  $sign: $z/abs($z);
  $z: abs($z);

  @if $z > sin(pi()/4) {
    $complement: true;
    $z: sqrt(1 - pow($z, 2));
  }

  $term: $z;

  @while $term > $threshold {
    $sum: $sum + $term;
  }

  @return $sign * (if($complement, pi()/2 - $sum, $sum));
}

At this point, unless the starting value for $term happens to be smaller than $threshold, our @while loop is an infinite one because we’re not changing $term inside. So let’s compute a new one with each iteration. In order to do that, we initialize two more variables before the loop. One is $i, the current term’s index, while the second one is $k, the part inside the parentheses for the previous term. After that, inside the loop, we keep incrementing $i and recomputing $k and $term.

@function asin($z, $threshold: $default-threshold) {
  $sum: 0;
  $complement: false;
  $sign: $z/abs($z);
  $z: abs($z);

  @if $z > sin(pi()/4) {
    $complement: true;
    $z: sqrt(1 - pow($z, 2));
  }

  $term: $z;
  $i: 0;
  $k: 1;

  @while $term > $threshold {
    $sum: $sum + $term;

    $i: $i + 1;
    $k: $k*(2*$i - 1)/(2*$i);
    $j: 2*$i + 1;

    $term: $k*pow($z, $j)/$j;
  }

  @return $sign * (if($complement, pi()/2 - $sum, $sum));
}

And this is it! We now have a working asin() function in Sass!

One thing more we could do to improve this is to check whether abs($z) <= 1 and throw an error if it returns false because, in such a case, our $term won’t get under the $threshold value and, we’ll have an infinite loop.

Coding the acos() function

Now that we have a function to calculate the arcsine, it’s actually pretty easy to code an acos() function. We can use the fact that, in the case of an angle =$\alpha$= in the =$[0, \pi]$= interval, =$\cos(\alpha) = \sin(\pi/2 – \alpha)$=. If we know =$\cos(\alpha) = z$=, then =$\arcsin(z) = \pi/2 – \alpha$=, which gives us that =$\alpha = \pi/2 – \arcsin(z)$=.

@function acos($z, $threshold: $default-threshold) {
  @return pi()/2 - asin($z, $threshold);
}

Coding the atan() function

For the atan() function, we start from the fact that =$\tan(\alpha) = \sin(\alpha)/\cos(\alpha)$=. We also know that =$\sin^2(\alpha) + \cos^2(\alpha) = 1$=, so we have that =$\tan^2(\alpha) = \sin^2(\alpha)/(1 – \sin^2(\alpha))$=. From this equality, we extract the sine depending on the tangent:

But we also know that =$\tan(\alpha) = z$=, so:

Which can be simplified to:

So our atan() function is:

@function atan($z, $threshold: $default-threshold) {
  @return asin($z/sqrt(1 + pow($z, 2)), $threshold);
}

Making these functions easier to use in CSS

Remember, the values returned by these functions are unitless radian values. We can’t use them as they are in our CSS, we need to at least multiply with 1rad or even do some sort of unit conversion. But what if we could specify the unit when we call the function? For example:

transform: rotate(asin(.5, 'deg'));

In order to do that, we first need an angle conversion function that takes a unitless radian value and converts it to a unit we specify. For example:

$in-degrees: convert-angle(pi()/4, 'deg');
$in-turns: convert-angle(pi()/2, turn); // works with both the unit name quoted or unquoted

Coding an angle conversion function

We start by creating a table of conversion factors from the unitless radian value to the CSS angular units. With Sass, this table becomes a map:

$factors: (
  rad: 1rad,
  deg: 180deg/pi(),
  turn: .5turn/pi(),
  grad: 200grad/pi()
);

Then we only need to multiply our initial unitless radian value to the appropriate factor. Which means that our function is just:

@function convert-angle($value, $unit-name) {
  $factors: (
    rad: 1rad,
    deg: 180deg/pi(),
    turn: .5turn/pi(),
    grad: 200grad/pi()
  );

  @return $value*map-get($factors, $unit-name);
}

This fails if $unit-name isn’t a key of the $factors map and isn’t valid in our CSS if $value already has a unit, so let’s take care of that as well.

@function convert-angle($value, $unit-name) {
  $factors: (
    rad: 1rad,
    deg: 180deg/pi(),
    grad: 200grad/pi(),
    turn: .5turn/pi()
  );

  @if not unitless($value) {
    @warn '`#{$value}` should be unitless';
    @return false;
  }

  @if not map-has-key($factors, $unit-name) {
    @warn 'unit `#{$unit-name}` is not a valid unit - please make sure it is either `deg`, `rad`, `grad` or `turn`';
    @return false;
  }

  @return $value*map-get($factors, $unit-name);
}

Improving the inverse trigonometric functions

Now we just need to change our inverse trigonometric functions to take care of unit conversion as well:

@function asin($z, $unit-name: deg, $threshold: $default-threshold) {
  // same as before, nothing changes here

  @return convert-angle($sign*(if($complement, pi()/2 - $sum, $sum)), $unit-name);
}

@function acos($z, $unit-name: deg, $threshold: $default-threshold) {
  @return convert-angle(pi()/2, $unit-name) - asin($z, $unit-name, $threshold);
}

@function atan($z, $unit-name: deg, $threshold: $default-threshold) {
  @return asin($z/sqrt(1 + pow($z, 2)), $unit-name, $threshold);
}

I’ve chosen to use degrees as the default because that’s probably the one most people understand best and use. I’ve also placed it before $threshold because it’s still more likely that somebody might want to change the unit.

Final words

Well, you’ve been a real trooper if you’ve made it this far! The complete functions can be found in this pen:

See the Pen Inverse trigonometric functions by Ana Tudor (@thebabydino) on CodePen.

I’ll leave you with two additional CodePen demos to inspire you:

More can be found on my CodePen page.

How Sass can shape the future of CSS

The rise in popularity of CSS extensions, such as Sass, in recent years has not gone unnoticed by the people who work on proposing and standardizing modules for CSS3 (and CSS4).

Sass Features Being Adapted for Submission

Many of the key features found in Sass are being adapted for submission to the W3C. Variables, Mixins, and Nesting are all mooted for inclusion in CSS, and we may see some of them appear in the near future.

Then again, we may not; resistance to the proposals is quite strong from certain members – for example, Bert Bos wrote a long article on why he considers CSS Variables to be harmful. But I thought it would be interesting for the Sass community to see how the software to which you develop and contribute to (Sass) is being used to discuss the future of the web.

The Variables Proposal

This proposal should look very familiar to you – it’s the same syntax that Sass uses, with one addition. Each variable is defined using a three-part syntax: first you set up the declaration using the @var at-rule, then you provide a unique name with the $ character before it, then you set the value:

@var $foo #F00;

Once set up like this, you can reference your variable by using the unique name as a value:

h1 { color: $foo; }

This proposal has already been put forward to the W3C, and I’ll tell you the result of that shortly.

The Mixins Proposal

As with Variables, you should be very familiar with the Mixins proposal – the syntax used in Sass was the inspiration. You create a declaration block using the @mixin at-rule, assign a unique id, and then add your rules:

@mixin foo { color: #F00; font-weight: bold; }

When you need to use that code block you call it using the @mix directive and the unique id you previously assigned:

h1 { font-size: 2em; @mix foo; }

As you can see, the only difference is that the CSS proposal uses @mix in place of Sass’s @include. As with Sass, you can also use parameters with Mixins:

@mixin foo($bar #F00) {
  border-color: $bar;
  color: $bar;
}
h1 {
  @mix foo(#00F);
}

An Alternative Variables Syntax

Recently, an alternative syntax for Variables has been proposed. This syntax looks and acts somewhat similarly to the HTML data attribute, although it’s not the same. In this proposal variables are scoped to elements (for global scope, you’d use the :root selector) and the variable name is prefixed with data-:

:root {
  data-foo: #F00;
}

Then you reference the variable by using the unique name in the data function:

h1 {
  color: data(foo);
}

This has the advantage of allowing scoped variables, and integrating better with the CSSOM, JavaScript, as well as inspector tools like Firebug or Dragonfly.

It must be stressed, however, that this is still only at the discussion stage.

So When Will We See Them?

As I said, maybe never. As I understand it, the first Variables proposal was not well received by the W3C – but the module author, Tab Atkins, is continuing to refine it anyway. Tab is also key to the creation of the alternative syntax. You can follow along with Tab and his writing at his personal blog where he shares his thoughts on web standards as well as details surrounding discussions on the future of CSS.

As for Mixins, they were rejected out of hand and probably won’t be pursued. The reason given? Lack of use cases. But I can’t imagine that you, as Sass creators, developers and users are short of use cases for Mixins. So, if you have them I’d love to read them – please leave a comment below sharing your thoughts if that’s the case.

If work does continue on these proposals, or any part of them, I think that it would be a matter of little time before browsers started to implement them; I believe, in fact, that WebKit already implemented Variables, only to remove them after feedback from the W3C.

Conclusion

I have to confess that I’ve only briefly experimented with Sass, and have not used it in any production websites, but what I like about it is the ease with which it’s been possible to adapt the syntax into CSS itself. It’s great to see community-created language extensions influence the evolution of the web, and even if none of these proposals ever make it to the implementation stage, you can be sure that at the very least they form part of the standards conversation.

Sass Twitter Bootstrap

Twitter’s “Bootstrap” is a HOT topic, especially in the Sass community. Sadly, they used LESS instead of Sass. Well, fellow staff member John W. Long changed that with Sass Twitter Bootstrap.

bootstrap.scss

Thanks John for stepping out and porting this for all of us Sass-lovers to enjoy!

/*!
 * Bootstrap v1.1.0
 *
 * Copyright 2011 Twitter, Inc
 * Licensed under the Apache License v2.0
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Designed and built with all the love in the world @twitter by @mdo and @fat.
 *
 * Converted to Sass by @johnwlong.
 *
 * Date: @DATE
 */

// CSS Reset
@import "reset.scss";

// Core
@import "preboot.scss";
@import "scaffolding.scss";

// Styled patterns and elements
@import "type.scss";
@import "forms.scss";
@import "tables.scss";
@import "patterns.scss";

Social