Nothing To Lose

If you don’t have it, how can you lose it!
Subscribe

Archive for the ‘Tutorial’

Jigsaw Sphere With Text

April 13, 2009 By: Dexter Category: GIMP, Tutorial, Web Graphics

Here is a very simple way to have a sphere made out of jigsaw pieces with text on it using GIMP

1) Start with a square canvas, I have taken 256×256 pixels size. Go to filters — Render — Jigsaw. select the curved style from jigsaw options and increase number of vertical and horizontal pieces to 9, or whatever you like. You should get something similar to IMAGE 1

Jigsaw Pattern

IMAGE 1 Jigsaw Pattern

2) Add required text in few of the pieces, Since you have to place text in different pieces you will have to put each character one at a time. You should have something similar to IMAGE 2

IMAGE 2 - Jigsaw with text in it

IMAGE 2 - Jigsaw with text in it

3) Finally on this image run filters — Map — Map Objects - Select Sphere as the object to be mapped to. Play around with the orientation tab to move the sphere in x y or z axis etc. Once you are satisfied with the settings click ok. You should get you sphere ready. See IMAGE 3

IMAGE 3 - mapped to sphere

IMAGE 3 - mapped to sphere

Little Shiny Blue Button

April 09, 2009 By: Dexter Category: GIMP, Tutorial, Web Graphics

For last few day had been doing some designing. Had to make some buttons, so here is a tutorial for making a rounded cornered shiny button. And of course using GIMP Blue Button
  • Start with a canvas of comfortable size, say around 400×600. Even though our button is going to be small, its some times easier to work on a bigger canvas and then to crop to the actual size.
  • Now we will make a square selection, from the tool box, select rectangular selection tool. Set the following in its setting, Anti-aliasing, Rounded Corners: Radius 20 and Fixed size: 150×150px.
  • Now do a selection in center of the canvas, you should get a selection of 150×150px automatically with rounded corners. ( See Image 1 )

IMAGE 01

IMAGE 01

  • Select some dark blue (I used #0000E2) as you foreground color, the select the gradient fill tool. In the settings choose, Mode: Multiply, Gradient: foreground to background RGB. Offset: 20, Shape: linear, Check Dithering and Adaptive supersampling.
  • Now using the gradient fill tool click at the bottom of the selected square selection and drag till the upper part of the selection. You should see an image similar to IMAGE 2
  • Run the previous step again but this time start from a bit out side the upper part of the square selection and drag just almost till the blue start to appear and leave the mouse button. You should get some thing similar to IMAGE 3.
  • Now just cut and paste the selected area againl (^c and ^v). Press ^L to invoke the layer dialouge box, you will see a floating layer, click on the lower left icon/button (create new layer) of the dialog box, this will make the floating layer as a new seperate layer. Name this layer as (button-gradient)
  • Next select the button-gradient layer to work on from layer dialog box, press ^a and ^c, this will select that layer and paste a copy of the layer again.
  • Now select a even darker blue (#000080) as foreground color, go to edit menu and click on “Fill with foreground color”. Your image should be filled with the new blue color, Go to the layer dialog box and paste this as a new layer. Lets call it as the dark-border layer.
  • Next select your latest layer to work on, use “fuzzy select tool” to select all, it should select the outside of the box. Next from “select” menu choose, “shrink”. Use shrink value of 5px. You should get an image similar to IMAGE 4.
  • Hit the delete key, and you will be able to see the gradient layer!!!!.
    IMAGE 5
  • Now the button is ready. But it looks a bit flat. So lets add some shadow to the button. Select the dark-border layer to work upon. Go to filters, select “light and shadow” => “Drop Shadow”, set parameter to x and y offset to 0 (zero), and hit ok.
  • And your button is ready. Enjoy.
    IMAGE 6
  • For actual usage, its better to delete the background (White) layer, and then re-size the image to the Shadow layer.

IMAGE 2

IMAGE 2

IMAGE 3

IMAGE 3

IMAGE 4

IMAGE 4

IMAGE 5

IMAGE 5

IMAGE 6

IMAGE 6

There is a easy way to create more buttons of similar type in different colors, merging the layers of the image and then using the “Hue-Saturation” from “color” menu. Play around with it and enjoy.

Here are some sample buttons in different colors and gradients.

Blue Button

Blue Button

Red Button

Red Button

Green Button

Green Button

Brown Button

Brown Button

[end]

Counting occurences of a words/pattern using grep and wc

March 29, 2009 By: Dexter Category: Regular Expressions, Tutorial

Some times you will come across the requirement of counting how many times a word/pattern has occurred in a file (text).
Here is a simple usage of the command grep and wc to do the same.
lets use the following file for example. (I have named it sample.txt)

Linux is a nice operating system.
Many people thing Linux just has a text based interface.
When people see the GUI on Linux they are really amazed.
Linux was developed by Linus Torvalds.
Linux is to UNIX, so if you have worked on Linux you will be able to work on UNIX also.

Now to count how many time “Linux” occurred in the text you can use:

grep -o ‘Linux’ sample.txt | wc -l

Explaination:
The grep command with -o option searches for the pattern in quotes, in this case ‘Linux’, If you just run the command like that you will get an output like

grep -o ‘Linux’ sample.txt
Linux
Linux
Linux
Linux
Linux
Linux

Now in the actual command

grep -o ‘Linux’ sample.txt | wc -l

When this output is piped to wc -l, which is a word counter tool, with the option -l it counts the number of lines that it receives, and since the output of grep gives each match in a different line, the number of lines are equal to number of occurrences of the text/pattern/word.

Remember grep is case sensitive so use the -i option to ignore case

grep -io ‘Linux’ sample.txt | wc -l

else only ‘Linux’ will be selected all other occurrences will be ignored.

Of course if you are just looking for how many lines have a particular pattern/word occurring and not the count of the word/pattern it self use

grep -c ‘Linux’ sample.txt
OR
grep -ic ‘Linux’ sample.txt // to ignore case

Of course if you are familiar with patterns matching, you can replace ‘Linux’ with your regular expression to look for occurrences of a particular pattern

e.g  ‘(Linux|UNIX|AIX)’  will look for occurrence of Linux or UNIX or AIX.

Note if you are going to use grep do not forge to escape the brackets and the pipe symbol.

Hope that was useful.

NOTE: This explanation is with respect to BASH Shell (GNU bash, version 3.1.17(2)) with grep (GNU grep) 2.5

[end]

Regular Expression — Using of \b and \B together. Part 3

March 18, 2009 By: Dexter Category: Regular Expressions, Tutorial

Using \B and \b together: Finding pattern at the NOT at RIGHT edge of words.

Continues from Previous Post: Regular Expression — Use of \B (Not Word Edges) Part 2

For ‘\B’ at the beginning of the pattern and ‘\b’ at the end of the pattern


$grep ‘\Bcat\b’ wordedge.txt
Be unique do not be a copycat.


when ‘\B’ is at the beginning of the pattern and ‘\b’ at the end of the pattern, ‘\B’ makes sure that the pattern is not at the beginning of the word and ‘\b’ on the end make sure the word is on the right edge of the word.
So in this case you will find the patterns always at the right edge of the word.
This is different than using just ‘\b’ at the end of the pattern because just using ‘\b’ allows us to select the whole word itself if it is the pattern.

Now vice-versa:

For ‘\b’ at the beginning of the pattern and ‘\B’ at the end of the pattern.


$grep ‘\bcat\B’ wordedge.txt
old weapon used to hit birds is catapult.


when ‘\b’ is at the beginning of the pattern and ‘\B’ at the end of the pattern, ‘\b’ makes sure that the pattern is at the beginning of the word and ‘\B’ on the end make sure the word is NOT on the right edge of the word.
So in this case you will find the patterns always at the left edge of the word.
This is different than using just ‘\b’ at the beginning of the pattern because just using ‘\b’ allows us to select the whole word itself if it is the pattern.

Hope this was useful.

[enough]