How Cloning a Mac Hard Drive Benefits the Users

Cloning a hard drive simply means creating an exact copy of hard drive; the copy consists of all contents of the drive. Now, imagine a situation when you are working on a Macintosh computer system and all of a sudden OS or hard drive crashes. In such situations, cloning the hard drive is the best solution. If you are an aware user, backing up the data must be your priority. Data backup includes cloning as an important backup plan, which also benefits when your system software, applications etc. get corrupt.


As mentioned above, the term ‘clone’ is typically referred to backing up the boot drive of a computer system, which is indeed one of the most important tasks. Below is a closer look at the advantages of cloning hard drive on a Mac based computer system:

Backup the Entire System

Cloning helps you keep a copy of your computer system that clearly implies that you are taking a functional backup of your system. The backup includes OS files, structure of partition table and the home directories. Apart from this, you can use the clone copy as boot drive because it is a replica of Hard Drive of your Mac computer. To do this, you need to plug in the Clone Drive and during boot-up, keep the ‘Options’ key pressed. Cloning differs from the conventional backup systems (for example, Time Machine) that keep more than one versions of files, whereas cloning creates a single copy of files on disk.

Test and Troubleshoot the Problems

With the help of the Clone Drive, you can perform the testing of new software, their updates and applications before their installation on your Mac system. Moreover, if there are issues with the system, you can troubleshoot them by booting off the Clone.

Stay in Touch with your Work

Not surprisingly, you could face problems with the Hard Drive that may lead to its corruption or failure. Subsequently, your work may grind to the halt for hours or days. To prevent such situation, you can boot off the Clone Drive to get back to your tasks.

As a frequent Mac user, you must know that your Mac computer offers an inbuilt utility named ‘Disk Utility’ to clone the Hard Drive. However, the method to use the utility requires a sound understanding, and you might not find it easy to perform the task.

Not to worry! In this case, you can use a commercial software program that facilitates cloning in an easy way. These software are written by Mac experts using comprehensive algorithms. Moreover, you can also image a hard drive on Mac system using such application. Imaging the Hard Drive includes creating image of any volume or the entire Hard Drive in order to restore the data if data loss occurs.

Create a Captcha with PHP

We’re going to learn how how CAPTCHA (CompletelyAutomated Public Turing test to tell Computers and Humans Apart) works and how it minimizes automatic sign-up of forms. We will also be creating a simple CAPTCHA script in PHP to illustrate this.

Basically CAPTCHA works in the following manner:

  1. Create Random Value: Some random string is generated, random values are often hard to guess and predict.
  2. Generate an Image: Images are used as these are generally a lot harder to read for computers while being nice and readable to humans. This is also the most important step as simple text in images can be read (and CAPTCHA cracked) quite easily. To make it difficult for them, developers employ different techniques so that the text in the image becomes hard to read for computers. Some create zig-zag lines for background while others twist-and-turn individual characters in the image. Possibilities are many and new techniques are being developed all the time as crackers are always into finding ways to break them.
  3. Store it: The random string generated (which is also in the image) is stored for matching the user input. The easiest way to do so is to use the Session variables.
  4. Matching: After the above step, the CAPTCHA image is generated and shown on some form which we want to protect from being abused. The users fills in the form along with the CAPTCHA text and submits it. Now we have the following:
    1. All submitted form data.
    2. CAPTCHA string (from form), input by user.
    3. CAPTCHA string (real one, generated by us), from session variable. Session variable is generally used as it can keep stored values across page requests. Here, we needed to preserve stored values from one page (form page) to another (action page-that receives form data).
  5. If both match, it’s okay otherwise not, in that case we can give the user a message that the CAPTCHA they had entered was wrong and their form could not be submitted. You could also ask them to verify it again.

The following image might illustrates this better:

CAPTCHA Generation and Matching

CAPTCHA Generation and Matching

From the above image it’s quite clear that when someone requests the form page, the CAPTCHA text is generated and sent back to requesting user, but only in the form of an image. If the requester is a human he’d not have much difficulty reading the image and inputting the text when asked but if it’s a bot it might face difficulties guessing whats in the image. In the next step when we match the string generated and the one the user had input, we can restrict automated form submissions.

The following is the code that does this, it’ll just output the CAPTCHA image to the browser when the script is requested:

Awesome Content Curation Tools

Have you been ever stuck finding the most accurate content related to your search criteria? Do you think content should be compiled in a way that enables you to find the right piece of information over internet without having to waste time reading the unwanted information? Yes, Content Curation is the answer to your query. This enables you to swim across the ocean of websites over internet and reach the right direction via filtering online content based on the subject of information. This is usually inform of status updates, tweets, articles and more. Listed here are some great Content Curation tools that might come handy for you anytime anywhere.

content-dictionary1. Digg

Sharing news of interest within your own community is all about Digg. This social networking platform allows you to share content with a specific group who can then rank your content value In this process, the higher the rate or ranking of your content, greater are the views you receive. This results in increased clicks or higher site traffic. For instance, as an e-commerce related content, your information will fall under either business or technology. And if you happen to chose a different and specific classification for your content, undoubtedly you would increase your site’s relevance as a tool for social media.

2. Equentia

Reaching your target audience and influencing your prospects and current clients with all the information that is useful and engaging is all synonymous to Equentia. You can dig the most relevant information and flesh out the most crisp and pertinent content as per your requirement. Equentia also helps you socialize the same content by allowing you to re-publish or use it privately.

3. Technorati

The world of internet is full of bloggers and Technorati is their friend. It is a blog search engine to serve as a content purifier. It is a directory that scans and indexes content from over a million blogs. Technorati was founded in 2002 and was the first among social networking platforms like Facebook and Twitter. In case you are the one who wants to be included in Technorati’s information bank, you will have to create an account and submit the blog’s website address. You can create a personal profile and use this tool to ignite the social media. It helps you to become critical and relevant amongst your readership.


Remember you should exploit the content curation tools to benefit you directly. The ideal curation solution can be achieved when you actually index your information into your private CMS. This way your traffic is not diverted to a third party site however your searchers stay and view your own site. There are more tools like Sphinn, BizSugar, PaperLi among many more who can help you get organized on this online bank of information. You need to find the most appropriate way to filter information to suit your needs in your own special way. Share socially for increased social capital.

Snow Theme Website design with Photoshop

Get your Photoshop on and follow this step by step tutorial of building a snowboarding themed website layout. The design we’ll be creating takes inspiration from the typical style of the snowboarding culture, with grungy textures and distressed brush marks adding detail to the design. We’ll start by producing a core grid to base the design elements on, then use a mix of photography and Photoshop manipulation to create a concept web design for a fictional brand named ‘Snow Candy’.


Snowboard themed website design

Ideas, Research and Sketches

A good place to start any design project is in your sketchbook. Before opening up Photoshop, I took the time to jot down some keywords and create a brand persona for Snow Candy. The website would aim to present a few key elements of information such as upcoming events, latest video and focus areas that could send the user deeper into the website. I then sketched out a potential layout that balanced out the page elements, and outlined my idea of using a large header graphic to catch and draw in the viewer’s attention.

Creating an underlying grid

Using a grid to base your design on is one of the core design principles that helps bring out balance and cohesion in your designs. This particular design is based on a simple 12 column layout making up a total width of 970px, and a uses a baseline of 24px;

A useful tool for generating a grid for your design is the Grid System Generator, where you can create a template and steal the handy pink column graphic to paste it into Photoshop! To create a baseline, create a 24x24px document in Photoshop, and draw a single pixel line across the bottom. Go to Edit > Define Pattern, then in your main document fill a black layer with this pattern to give a baseline template to set your text and page items to.

Let’s shred the gnar!

With the page template ready to rock, let’s get on with some creative Photoshop work. Start by filling the background with a light blue (#b9d2f8), then add a gradient spanning from a dark blue (#02357a) at the top through to a mid blue (#295ba6) then blending out to the #b9d2f8 background colour.

Head over to Bittbox and download one of the awesome noir grunge textures. Paste the texture into the document and scale down in size. Also change the blending mode to Luminosity and drop the opacity to 25%.

Add a layer mask to the texture, then use a large soft brush to blend out the texture so that it spans from the top center of the document. Black paint renders the area invisible while white represents the visible portions of the mask.

With Snow Candy being a fictional brand, we can quickly throw together a cool logo that fits into the overall style we’re aiming for. Download the flowing Black Rose font and set out the words in lower case. Remember to make the most of your grid by scaling and positioning the logo in relation to the columns and baseline.

Rough up the logo a little by adding a layer mask and brushing over it with some grungy Photoshop brushes. I’m using my paint stroke brushes that are available for download from Blog.SpoonGraphics. Set the opacity of the brush to 10% then slowly build up the layers of distress.

To draw focus to the logo add a soft and subtle drop shadow, then draw a white radial gradient on a new layer. Set the layer style to Overlay and move into position behind the logo. Once in place tone down the effect by dropping the opacity to 50%.

Type out a simple navigation list to the right of the logo, following on the same baseline. Use a widely available font such as Helvetica or Arial to allow the text to be rendered in HTML when coded up for real.

Create a visual clue to highlight the active menu item by adding a small brush stroke in white behind the navigation text. Reduce the opacity to keep the white text legible.

Draw a large content area that spans the whole 970px width and fill with white.

Reduce the opacity of the content area to 30%, and add a very subtle drop shadow. Alter the distance and spread to 0px, while setting the size to 10px. Drop the opacity down to 25% to maintain a subtle shading effect.

One of the main features of the design is a large heading that holds a Snowboarding action shot. This area could be used as a rotating slideshow of featured content on the final website build, but for now, we’ll just mockup one of these features. Paste in, rotate and scale a photograph. This particular shot can be found on SXC.

Add some design tweaks to the shot by dabbing some vibrant spots of colour over the image. Choose a bright pink, blue and yellow and paint them onto a layer above the photograph.

Set this colour layer to Overlay and set the opacity to 35%. The result is a subtle colour shift that spices up the photograph.

Use a range of Photoshop brushes to draw a rough border around the shot. Paint the brush marks in black, then change the blending mode to Overlay to allow the colours to interact.

Painting brush strokes on a couple of layers will also allow each layer to overlap, creating more depth and interest as different levels of transparency appear.

Next, we’ll create a creative typographic layout for some event details. Here I’m manipulating the text in Illustrator for ease, but there’s no real reason to move out of Photoshop. Use guides to aid the alignment of all the words.

A few snowboading vector graphics can be sourced from that help add the finishing touches to the styling of the event information.

Paste the text into the main web design document and scale into place. Position the words between the columns and lay it perfectly on the baseline grid.

Underneath this main feauture header the secondary content can appear. Use headers to create clear visual anchors to attract the eye and give immediate regonition of the content. Manipulate the text with tight tracking and lowercase appearance, and draw some small icons with the pencil and eraser tools to back up the wording with a visual clue.

A mockup of the featured video can be created with another Snowboarding action shot. Add a grungey border using the rough Photoshop brushes.

On a new layer, draw a circular mask and fill with black. Draw a triangle using the Polygonal Lasso Tool to represent the play icon, then delete this shape out of the circle. Drop the opacity to allow the video content to show through.

To the right of the video will be a short list of upcoming events. Write out the title and back this up with an icon. Zoom right in to adjust the finest details of the icon.

Set out the event information with style. Use a range of font sizes to create a hierarchy of importance.

When laying out the content, especially the text, remember to base everything on the baseline grid. With our baseline being 24px, use a line height of 24px on all paragraphs. Finish off the content area with the desired number of elements, and end each section with an anchor that links through to deeper levels of the website.

Below this content, we’ll lay out some elements that span the width of both columns. Lay out some portrait shots to build up the Meet the Team section. Add a small white stroke and subtle drop shadow to give the appearance of a tactile photographs.

Rotate each portrait shot to give the impression of a collection of photographs that have been roughly placed on the page.

Continue the casual theme of the design by typing out the names of each team member in a hand-drawn font.

To finish off the design, copy a selection of the texture used in the header area. Move it into position behind the lower portion of the content panel.

Alter the layer style and opacity to tone down the effect and blend the colours toghether, then use a layer mask to allow the texture to peek out from the center of the panel.

Snowboard themed website design

The visual concept is complete! The blue colour scheme helps tap into the coolness of the snowboarding scene, while the mix of textures and distressed brush strokes add some gnarliness that relates well to the culture and lifestyle of extreme sports in general.

Surreal, Abstract, Metallic Text Effect

With this tutorial, we will show you how to create a unique, Surreal and Abstract Text Effect with Metal Texture in Photoshop, step by step. This tutorial involves some steps which are a little tricky, but then, who said Photoshop was easy! ;)

The objective of this tutorial is to show how can you manipulate texture/stock image with layer masks and blending options to create an eye candy with special effect. Also we will show you how to use adjustment layer to add colours in the end.

Required Resources:

Step 1

Create a new document sized 800px * 1040px with black background. Create a new layer and use the space brush to paint a background pattern, compress it down and set some perspective to it as shown below:

1 persp1 500x676 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Create a new layer and further add some space pattern, reduce the layer opacity to around 80% and use a soft eraser to erase the centre portion as shown below:

Hint: by performing the above two things, we added some depth to the image and get ready for adding the text in the following step.

1 paint1 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Let’s add some simple light effect – create a new layer and use a big white brush to paint a dot light as shown below:

1 paint light 500x414 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Use a soft eraser with smaller brush size than the dot light, erase the top right part of the dot as shown below:

1 erase2 500x359 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Duplicate this layer and rotate the duplicated layer 180 degrees, you will have the following effect:

1 effect1 500x656 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Step 2

We can now work on the letter. Type a letter on the centre of the canvas, as shown below:

2 type1 500x633 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Load the “metal texture 1″ image into Photoshop. Then load this text layer selection and move it to the metal texture, copy and paste it back onto our text:

2 sel2 500x344 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Turn off the original text layer, and you will have the following effect:

2 paste2 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Open up the liquify filter, grab the forward warping tool and make sure you enable “Show Backdrop” and use the following setting: (this will make the background visible, easier to apply the liquify effect)

2 liquid sest Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Go crazy with the liquify tool, add some flowing effect around the text edges as shown below:

2 liq 500x595 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Then erase the following area with the a soft eraser:

2 erase Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Step 3

We can now apply some adjustments layers on the metal texture as clipping mask:

Black and White

3 bw2 Design Abstract Surreal Text Effect with Metal Texture in Photoshop


3 lv Design Abstract Surreal Text Effect with Metal Texture in Photoshop


3 curves Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Then use the Lasso Tool with 30px feather, draw a selection on the following area:

3 sel 500x370 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Then add another Levels adjustment layer as clipping mask: (this will darken the Lasso Selection)

3 levels Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Render or paint some cloud (with cloud or smoke brush, plenty of them on the internet) around the text to add dramatic effect:

3 cloud 500x583 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Step 4

We can now add some small metal particles into the image – load the “metal texture 2″ image into Photoshop and use the quick selection tool to select a few small pieces on the image:

4 quick sel 500x348 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Copy and paste the selection onto our document, erase the edges to blend those small pieces into the main text:

4 erase1 500x346 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Duplicate the selection a few times, attach them to different parts of the text, as shown below:

4 dup 500x532 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Merge the duplicated layers and apply the following black and white adjustments to it:

4 bw1 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

and here is the effect so far:

4 effect2 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

You can also further duplicate this metal texture layer a few more times, resize them to small scale and move them around the text, as shown below:

4 small part 500x618 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Step 5

To add some extra effect, I decided to use the Pen Tool to draw some red lines around the text. So let’s use the Pen Tool to draw a work path as shown below:

5 draw path 500x431 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Prior to stroking the path, go to the brush panel and set the brush size to 3px, hardness 95%, red colour as shown below:

5 colour 500x397 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Then go back to select the Pen Tool, right-click and choose “Stroke Path”:

5 stroke 500x389 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Stroke this path with the following settings:

5 stroke brush 500x272 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

and you will have the following effect:

5 effect1 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Duplicate this line layer a few more times and resize each duplicated layer and rotate them, attach the lines to different part of the text:

5 effect 2 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

You can also mix some yellow lines via adjusting the Colour Hue, in order to add some variety on the text:

5 yellow 500x255 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Step 6

OK we’re almost done! For some final retouches, we can flatten the image and apply the following Smart Sharpen filter to the image to sharpen the text a bit:

6 smart sha 500x317 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

To add some colour effect to image, I apply the following image adjustment layers to the image:

Selective Color

6 sel red Design Abstract Surreal Text Effect with Metal Texture in Photoshop

6 sel white Design Abstract Surreal Text Effect with Metal Texture in Photoshop

6 sel neu Design Abstract Surreal Text Effect with Metal Texture in Photoshop


6 curves Design Abstract Surreal Text Effect with Metal Texture in Photoshop

Brightness and Contrast

6 bc Design Abstract Surreal Text Effect with Metal Texture in Photoshop

I then further added some slight colour adjustment and here is the final effect I have: (click to enlarge)

metal text flatten 500x650 Design Abstract Surreal Text Effect with Metal Texture in Photoshop

That’s it for this tutorial! Hope you enjoy it and find it useful! Don’t forget to share!

Better Photography with your iPhone

Nowadays, Apple’s iPhone is considered as one of the most popular smartphone. More than its sleek, elegant design, smartphone users choose the iPhone because of its functionality. One of the best features of the iPhone is its ability to take quality photos and videos. In this article, we will tackle 13 tips that will enhance the quality of photos taken from your iPhone.

Iphone Photography1. Clean the Lens

People would commonly put their iPhones inside their bags or pockets. So, before taking any photos make sure that the lens of your camera is clear from any traces of dusts and fingerprints. Having a lens covered with dusts and fingerprints will affect the clarity and over-all quality of your photos.

2. Adjust the Settings According to Your Preference

Always remember that your iPhone already has built-in settings and modes that can aid you in taking pictures that will turn-out to be just the way you like them to be taken. Read the manual and maximize the use of your iPhone camera’s built-in features.

Iphone stand3. Try to Find an iPhone Stand

Keep in mind that it takes a few seconds for the iPhone to process shots into photos. If your hands are having a difficult time in staying still at a certain position position for around ten seconds, it is highly advisable for you to use an iPhone stand when taking photos. This will prevent your pictures from looking blurry because of slight hand movements while waiting for your shot to be processed.

4. Learn When to Use Flash

It is not wise to always activate your camera’s flash. There are only particular situations wherein taking shots with an enabled flash is advisable. Only turn on the flash when taking photos in broad daylight and utter darkness. Don’t use flash when taking photos of people, glasses, still objects, and events.

5. Refrain from Using the Zoom Function

If you want to take a good shot of something, move as close to it as you can before taking a shot. Don’t settle with taking a shot at a far distance by utilizing the zoom function because this will greatly compromise the quality of your photo by making it look grainy.

instagram6. Take Advantage of Apps

Oftentimes, the iPhone’s built-in features have limitations; but don’t fret, because the downloadable apps can make up for their insufficiencies. For instance, the TrueHDR is a good complement to the HDR feature of the iPhone.

7. The Rule of Thirds

The Rule of Thirds is one of the most basic techniques in photography. Luckily, the iPhone has a built-in function – the Grid Option – to help you take better shots. Once you have enabled the option, simply position your subject along the lines for maximum results.

8. Use HDR

Another great built-in feature of the iPhone is the HDR or High Dynamic Range. This feature allows you to take high-quality photos by putting together three photos taken in different modes into a singular picture with just one shot.

9.Position Your Subject

Every photo has a subject. As the photographer, it is up to you on how you wish to portray the subject in your photo. Experiment with different angles and position your subject properly to capture the best shot possible.

10. Find Good Lighting

Regardless of the technology that you are using for taking photos, lightning is an essential aspect of photography that must never be forgotten. Make sure that when taking photos with your iPhone, you have sufficient light to enable you to capture a visible subject. For best results, take photos with your iPhone when outdoors where sunlight is present.

iphone lens11. Buy Extra Lenses

If you are really serious with taking exceptional photos with your iPhone, it is highly encouraged that you buy magnetic wide lenses that can be attached to your iPhone. These lenses will help you take better quality shots and help you overcome the limitations of your iPhone’s built-in lenses.

12. Edit Your Photos

To enhance the pictures you have taken, you may want to edit your photos. Using available apps or any photo-editing software, you may enhance a photo by changing the color, tone, lighting, resolution, and many more.

13. It is a Camera: Treat it Like One

Your iPhone camera is not much different from the traditional camera you have always known. Therefore, treat it like one buy holding it as if you are holding a camera. Use your two hands and hold it firmly.

The iPhone in itself already has the capacity to take great photos. Follow the aforementioned tips and you are well on your way to become a professional photographer by simply using the camera of your iPhone.

QuickSort algorithm, code for Java, C++

Quicksort is a fast sorting algorithm, which is used not only for educational purposes, but widely applied in practice. On the average, it has O(n log n) complexity, making quicksort suitable for sorting big data volumes. The idea of the algorithm is quite simple and once you realize it, you can write quicksort as fast as bubble sort.


The divide-and-conquer strategy is used in quicksort. Below the recursion step is described:

  1. Choose a pivot value. We take the value of the middle element as pivot value, but it can be any value, which is in range of sorted values, even if it doesn’t present in the array.
  2. Partition. Rearrange elements in such a way, that all elements which are lesser than the pivot go to the left part of the array and all elements greater than the pivot, go to the right part of the array. Values equal to the pivot can stay in any part of the array. Notice, that array may be divided in non-equal parts.
  3. Sort both parts. Apply quicksort algorithm recursively to the left and the right parts.

Partition algorithm in detail

There are two indices i and j and at the very beginning of the partition algorithm i points to the first element in the array andj points to the last one. Then algorithm moves i forward, until an element with value greater or equal to the pivot is found. Index j is moved backward, until an element with value lesser or equal to the pivot is found. If i ≤ j then they are swapped and i steps to the next position (i + 1), j steps to the previous one (j – 1). Algorithm stops, when i becomes greater than j.

After partition, all values before i-th element are less or equal than the pivot and all values after j-th element are greater or equal to the pivot.

Example. Sort {1, 12, 5, 26, 7, 14, 3, 7, 2} using quicksort.

Quick Sort at Work

otice, that we show here only the first recursion step, in order not to make example too long. But, in fact, {1, 2, 5, 7, 3} and {14, 7, 26, 12} are sorted then recursively.

Why does it work?

On the partition step algorithm divides the array into two parts and every element a from the left part is less or equal than every element b from the right part. Also a and b satisfy a ≤ pivot ≤ b inequality. After completion of the recursion calls both of the parts become sorted and, taking into account arguments stated above, the whole array is sorted.

Complexity analysis

On the average quicksort has O(n log n) complexity, but strong proof of this fact is not trivial and not presented here. In worst case, quicksort runs O(n2) time, but on the most “practical” data it works just fine and outperforms other O(n log n) sorting algorithms.

Code snippets

Partition algorithm is important per se, therefore it may be carried out as a separate function. The code for C++ contains solid function for quicksort, but Java code contains two separate functions for partition and sort, accordingly.


Graphics in Turbo C/C++

Turbo C has a good collection of graphics libraries. If you know the basics of C, you can easily learn graphics programming. To start programming, let us write a small program that displays a circle on the screen.

    To run this program, you need graphics.h header file, graphics.lib library file and Graphics driver (BGI file) in the program folder. These files are part of Turbo C package. In all our programs we used 640×480 VGA monitor. So all the programs are according to that specification. You need to make necessary changes to your programs according to your screen resolution. For VGA monitor, graphics driver used is EGA.BGI or VGA.BGI.

Here, initgraph() function initializes the graphics mode and clears the screen. We will study the difference between text mode and graphics mode in detail latter.

Initializes the graphics system.Declaration:
void far initgraph(int far *graphdriver, int far *graphmode, char far *pathtodriver);Remarks: To start the graphics system, you must first call initgraph.

initgraph initializes the graphics system by loading a graphics driver from disk (or validating a registered driver) then putting the system into graphics mode.

initgraph also resets all graphics settings (color, palette, current position, viewport, etc.) to their defaults, then resets graphresult to 0.

*graphdriver: Integer that specifies the graphics driver to be used. You can give graphdriver a value using a constant of the graphics drivers enumeration type.

*graphmode : Integer that specifies the initial graphics mode (unless *graphdriver = DETECT). If *graphdriver = DETECT, initgraph sets *graphmode to the highest resolution available for the detected driver. You can give *graphmode a value using a constant of the graphics_modes enumeration type.

pathtodriver : Specifies the directory path where initgraph looks for graphics drivers (*.BGI) first.  If they’re not there, initgraph looks in the current directory.  If pathtodriver is null, the driver files must be in the current directory.  This is also the path settextstyle searches for the stroked character font files (*.CHR).

closegraph() function switches back the screen from graphcs mode to text mode. It clears the screen also. A graphics program should have a closegraph function at the end of graphics. Otherwise DOS screen will not go to text mode after running the program. Here, closegraph() is called after getch() since screen should not clear until user hits a key.

If you have the BGI file in the same folder of your program, you can just leave it as “” only. you need not mention *graphmode if you give *graphdriver as DETECT.

In graphics mode, all the screen co-ordinates are mentioned in terms of pixels. Number of pixels in the screen decides resolution of the screen. In the example 1.0,  circle is drawn with x-coordinate of the center 200, y-coordinate 100 and radius 150 pixels. All the coordinates are mentioned with respect to top-left corner of the screen.

Basic Shapes and Colors:

Now let us write a program to draw some basic shapes.


Here is the screenshot of output:

Here, circle() function takes x, y coordinates of the circle with respect to left top of the screen and radius of the circle in terms of pixels as arguments. Note that, in graphics, almost all the screen parameters are measured in terms of pixels.

Function outtextxy() displays a string in graphical mode. You can use different fonts, text sizes, alignments, colors and directions of the text that we will study later. Parameters passed are x and y coordinates of the position on the screen where text is to be displayed. There is another function outtext() that displayes a text in the current position. Current position is the place where last drawing is ended. These functions are declared as follows:

void far outtextxy(int x, int y, char *text);
void far outtext(char *text);

Circle, arc, pieslice are declared as follows:


  •  void far arc(int x, int y, int stangle, int endangle, int radius);
  •  void far circle(int x, int y, int radius);
  •  void far pieslice(int x, int y, int stangle, int endangle, int radius);


  • arc draws a circular arc in the current drawing color.
  • circle draws a circle in the current drawing color.
  • pieslice draws a pie slice in the current drawing color, then fills it using
    the current fill pattern and fill color.


  • (x,y): Center point of arc, circlew, or pie slice
  • stangle: Start angle in degrees
  • endangle: End angle in degrees
  • radius: Radius of arc, circle, and pieslice

Here, stangle and endangle are in degrees starting from the +ve x-axis in the polar coordinate system in the anti-clockwise direction. if stangle is 0, endangle is 360, it will draw a full circle. Refer this figure for clear idea: For the details of current color, fill color and fill patterns, refer the sections Lines and Colors.

Another basic shape that we come across is a rectangle. To draw a border, use rectangle with the coordinates of outline, to draw a square use rectangle with same height and width. drawpoly() and fillpoly() are two functions useful to draw any polygons. To use these functions, store the coordinates of the shape in an array and pass the address of array as an argument to the function. By looking at the output of the previous program, you can understand what drawpoly is. fillpoly is similar except that it fills in the shape with current fill color.


  • void far rectangle(int left, int top, int right, int bottom);
  • void far drawpoly(int numpoints, int far *polypoints);
  • void far fillpoly(int numpoints, int far *polypoints);


  • rectangle draws a rectangle in the current line style, thickness, and drawing color.
  • drawpoly draws a polygon using the current line style and color.
  • fillpoly draws the outline of a polygon using the current line style and color, then fills the polygon using the current fill pattern and fill color.


  • (left,top) is the upper left corner of the rectangle, and (right,bottom) is its lower right corner.
  •  numpoints:  Specifies number of points
  • *polypoints: Points to a sequence of (numpoints x 2) integers. Each pair of integers gives the x and y coordinates of a point on the polygon.

To draw a closed polygon with N points, numpoints should be N+1 and the array polypoints[] should contain 2(N+1) integers with first 2 integers equal to last 2 integers.

Let us study more about shapes latter. Here is some idea about colors. There are 16 colors declared in graphics.h as listed bellow.

BLACK:                  0
BLUE:                     1
GREEN:                  2
CYAN:                       3
RED:                          4
MAGENTA:              5
BROWN:                   6
LIGHTGRAY:           7
DARKGRAY:            8
LIGHTBLUE:            9
LIGHTGREEN:        10
LIGHTCYAN:          11
LIGHTRED:             12
YELLOW:                14
WHITE:                    15

To use these colors, use functions setcolor(), setbkcolor() and setfillstyle(). setcolor() function sets the current drawing color. If we use setcolor(RED); and draw any shape, line or text after that, the drawing will be in red color. You can either use color as defined above or number like setcolor(4);. setbkcolor() sets background color for drawing. Setfillstyle sets fill pattern and fill colors. After calling setfillstyle, if we use functions like floodfill, fillpoly, bar etc, shpes will be filled with fill color and pattern set using setfillstyle. These function declarations are as follows.


  •  void far setfillstyle(int pattern, int color);
  • void far setcolor(int color);
  • void far setbkcolor(int color);


  • setfillstyle sets the current fill pattern and fill color.
  • setcolor sets the current drawing color to color, which can range from 0 to getmaxcolor.
  • setbkcolor sets the background to the color specified by color.

The parameter pattern in setfillstyle is as follows:

 Names Value Means  Fill With…
EMPTY_FILL 0 Background color
SOLID_FILL 1 Solid fill
SLASH_FILL 4 ///, thick lines
BKSLASH_FILL 5 \\\, thick lines
HATCH_FILL 7 Light hatch
XHATCH_FILL 8 Heavy crosshatch
INTERLEAVE_FILL 9 Interleaving lines
WIDE_DOT_FILL 10 Widely spaced dots
CLOSE_DOT_FILL 11 Closely spaced dots
USER_FILL 12 User-defined fill pattern

Here is an example program with colors, pixels, bar, cleardevice etc. stdlib.h is used for random number generation. We have a function random(no), it returns a random number between 0 an no. The effect is by drawing random radius, random color circles with same center and random pixels. kbhit() function(defined in conio.h) returns a nonzero value when a key is pressed in the keyboard. So, the loop will continue until a key is pressed.

Thank you for reading!

Make Content look Impactful with different Web Design Techniques

One of the unanimous truths of the web world is that content is the king. However, in order to present this content in the best possible manner, it is important to implement contemporary web designs in the website. A content marketing strategy is incomplete without powerful web design as the World Wide Web is full of information and a website can scores good only if the relevant information is portrayed in unique pattern. Even professional web content writers can’t deny the fact that website designing forms an integral part of content marketing. Mentioned below are the famous website designing trends that compliment content marketing strategies, have a look.

Implementation of Responsive Website Design

The present day generation has shifted from PCs to tablets and Smartphones and thus it is important that a website adjusts its dimensions as per different devices. With Responsive Website Design, one can create a web portal that fits well in all devices. This helps the website in enhancing its reach to the targeted market. The increasing use of tabs and Smartphones for browsing internet has led to the popularity of responsive design. If a website fails to fit in the gadget of the prospects, they take half a minute to switch to another portal.

Conveying Message via Embedded Videos

Embedded videos are one of the latest web design trends prevailing in the cyber space. Visitors today want everything quickly; they don’t have time to go through the entire text and there comes the role of videos. Videos are interactive and conveying information via this medium is best for getting a hold on the visitor’s attention.

The Magic of Special Effects

As mentioned before, it’s all about presenting the information in a unique pattern and what can be better than a pinch of special effects. The best part is that with the emergence of CSS3 and HTML5, it has become easy to embellish the website with feature of visual effects. Lightbox, slideshows and interactive buttons are a few effects that can be implemented to enhance the content marketing strategy of a web portal.

Use of Minimalist and User-friendly Design

One can avail custom web design services for incorporating minimalist and user friendly outlook for the website. Yes special effects and videos do leave an impact on the viewers, but the more professional the content looks the more prospects turn into leads. One live example of minimalist and user friendly design is Tumbler. It’s simple, it’s professional and thus attracts maximum amount of targeted audience.

Increasing the Role of Social Media Integration

The rising popularity of social media is not hidden from anyone. Social media is one of the biggest players of internet marketing and therefore it is important to use it wisely. The use of share buttons is not new; it’s just that with the spinning wheel of time its use is increasing.

This makes it crystal clear that getting proper website design is as important as availing professional web content writing services. Irrespective of the device on which the user is browsing a website, he always wants a beautifully laid down content to please his eyes and comfort his knowledge hunger. With these new emerging wed designs, it will become easy for the websites to serve exactly what their visitors expect from them.

Finding the Right License Scheme for your Software

Software companies rely on license fees for their revenues. A number of different licensing schemes are available and each type has its advantages. The exact choice of licence scheme will depend on the target user and their way of deriving utility from the software. Below, you will find a detailed explanation of six types of license schemes. As a producer or consumer, knowledge of these different forms will assist you to choose what is right for your personal or organizational licence

1. License by user
License by user infers that only one person has authorization to use the particular software. The user may use different devices but no other user is allowed to use the same software. If there are many employees in an organization, everyone has to get their own license. License per user works well with web-based software that does not tie a user to a particular physical location.

2. License by installation
This is different from the license by user because it does not restrict the number of users that can use the software. Instead, it restricts the usage of the software to only one device. If the software installation happens on a laptop or a tablet and the licensing also happens for that device, then any person who accesses the device will be able to use the software. Sellers prefer this license model when they expect very little mobility of the user and the software. The scheme works best for software bought for personal use.

3. License by client
When the software deployment takes place in a server environment where there are many server-clients, sellers may opt to licence by client. In this case, all devices that connect to the server to use the software will need a license. In addition, it is common for sellers to issue a license for the server that clients connect to, in the organization.

4. No license fees
Sometimes software can arise out of a voluntary effort and the creators may not have an inclination to earn from their work. In other cases, companies choose to not to sell their software license in the hope that, they will recoup their production costs when they provide paid support. Most open source software use a no license fees scheme.

5. Licence by developer
Just as some businesses only deal with other businesses, some software only works by assisting other software developers to create solutions for their customers. Development tools and libraries are critical software development components. The person using these tools may be compelled to acquire a developer license; however, the resulting software sold to end users will not be part of the license by developer.

6. License by site
Sometimes an organization has many employees with a high staff turnover. It does not make economic sense to buy every staff a user license. In addition, some employees might be working remotely and therefore need more than the license by installation, since they use more than one device. Such organizations and businesses can opt to acquire site licenses if the software seller offers them. The license by site allows anyone within the unit that qualifies as the site, to use the software. In most cases site can mean a physical local or an organization. For example, with organization as the site, the license may allow everyone who is an employee to access to the software irrespective of his or her location.

The exact limits of the rights of usage given by a specific license will always depend on the license scheme used. By following the description of each license scheme listed above you will be in a good position to select what will work best for your organization. The right license affords you the support that you need to keep your devices and organization secure. For sellers, choosing the right license scheme gives you the right options of marketing your software to clients.

1 2 3 4 52