Saturday, June 20, 2015

Circular Fragment Shader with Qt 5

Circular guage in qt can be attained by GLSL sharers. Include this piece of code for your Image source.

ShaderEffect{
                property variant  source: ..
                property real value: ..
                property real thicknessvalue: ..
                property real radiusvalue: ..
                ...

                fragmentShader: "
                                uniform sampler2D source;
                                varying highp vec2 qt_TexCoord0;
                                uniform lowp float qt_Opacity;
                                uniform highp float value;
                                uniform highp float radiusvalue;
                                uniform highp float thicknessvalue;
                                const float kInvPi = 1.0 / 3.141592;
                                void main()
                                {
                                    float bluriness = 1.0;
                                    float radius = radiusvalue; //0.01 to 2.00 (0.90)
                                    float thickness = thicknessvalue; // 0.001 to 1.00
                                    float len = value;  // 0.001 to 0.760;
                                    float offset =  0.37; // Start of Arc
                                    vec2 uv = vec2(qt_TexCoord0.y,  qt_TexCoord0.x);
                                    uv = 2.0 * uv - 1.0;
                                    uv.x *= 1.0;
                                    float d = length( uv );
                                    float angle = atan( uv.x, uv. y ) * kInvPi * 0.5;
                                    angle = fract( angle - offset );
                                    float w = bluriness * fwidth( d );
                                    float circle = smoothstep( radius + w, radius - w, d );
                                    float inner = radius - thickness;
                                    circle -= smoothstep( inner + w, inner - w, d );
                                    float segment = smoothstep( len + 0.002, len, angle );
                                    segment *= smoothstep( 0.0, 0.002, angle );
                                    circle *= mix( segment, 1.0, step( 1.0, len ) );
                                    gl_FragColor = qt_Opacity * texture2D(source, uv) * circle;
                                }"
            }




Sunday, June 14, 2015

Install Ubuntu 14.04 in USB (PWE - Portable Work Environment)

Do you want to create a portable work environment in your pocket? If so install Linux distribution in a portable USB.


For that what you need

1) Ubuntu 14.xx or Windows 8.x
2) USB (formatted with FAT or NTFS)
3) Virtual Box installed
4) Iso image for the Ubuntu xx.xx or any Linux distributions

Here it is achieved by using Ubuntu 14.04 and virtual machine with the same.

Install Virtual Machine:

First you need to install a virtual box 

$ sudo apt-get install virtual box        

After installing and set up the virtual machine, choose the Ubuntu 14.04 iso image which is already downloaded from Ubuntu official site.

Create a new Virtual Machine  load storage for its in settings with the Ubuntu 14.04 iso.

Settings > Storage > Controller:IDE > (Attributes>CD/DVD Drive with ISO).

Do start the VM for Ubuntu 14.04 & Choose "Try Ubuntu".




Note: Some times you may not be able to access the usb stick to be available in your virtual machine. To get access for that install dkms.

$ sudo apt-get install dkms              
$ sudo apt-get install gnome-system-tools

Open "Users and Groups" > "Manage groups" > vboxusers > "Properties" > add to main user or check for the user.


Once you have able to access USB from your virtual machine continue installing your Ubuntu 14.04 on to flash drive.





(Avoid connection to internet or else the entire process will have un-stability on installation and will be longer)


To configure and install in flash drive choose the option "something else" .


Choose /dev/sdb. Choose the usb drive for boot loader installation. Also do the partition on /dev/sdb (fat32)




Don't forget to choose "Ext4journaling file system".

 

 Also don't forget to choose mount point as root '/'.





This will continue to usual Linux installation.  You can boot the system and press "F12" (may vary) to choose the usb device to boot.