javaScript-textBorder: samples

  1. Sample of embossed text
  2. Sample of sunken text
  3. Sample of border
  4. Sample of blur
  1. Sample of embossed text

    To make the text look embossed the first color should be darker than the second, here you can see some examples:
    Embossed text
    
    We can make the effect more exaggerated doing the copies completely opaque (opac1 values ​​and opac2 = 1):
    
    Embossed Text with more opacity
    
    We can give only one pixel instead of the two that are applied by default:
    
    One pixel Embossed Text
  2. Sample of sunken text

    To make the text appear to be sunk we pass the first color lighter than the second, examples:
    Sunken text
    
    We can exaggerate the effect by making the copies completely opaques (opac1 values ​​and opac2 = 1):
    
    Sunken text with more opacity
    
    Only one pixel and opacity 1:
    
    Sunken text of 1 pixel
  3. Sample of border

    To make the text appear to be surrounded by a border give same value to the two colors, examples:
    Two pixels border
    
    We can make copies completely opaque (opac1 values ​​and opac2 = 1):
    
    Text with opaque border
    
    Only 1 pixel and opacity 1:
    
    One pixel border
  4. Sample of blur

    To make the text look blurred we give the same value to the two colors and low opacity, examples:
    Opacidad 0.1
    
    
    Opacidad 0.3
    
    
    Opacidad 0.5

textBorder: add border effects to the HTML text with javaScript

textBorder.js creates raised, sunken and blur effects on the html texts.
The effect is achieved by displacing copies of the content object one and two pixels.
The function takes four arguments:

ArgumentTypeDescription
objHTML objectObject you apply the effect, applies to the content (innerHTML).
clr1 (Optional) HTML color Color applied to the right and below of the object. By default “#000″
clr2 (optional) HTML color Color applied to the left and above of the object. By default “#fff″
opts (optional)Object opac1: Opacity for the copys with 1 pixel offset. Decimal number from 0 to 1. By default: 0.5
opac2: Opacity for the copys with 2 pixels offset. Decimal number from 0 to 1. By default: 0.3
res: Determines how many times you copy the original text, one or two times. By default : 2

Test it:
div con ID=”idText”:

Sample text
textBorder(document.getElementById("idText"));
Change clr1:
Change clr2:
Change opac1:
Change opac2:
Download textBorder

php: more readable print_r

When debugging a script in php, the result of print_r with a large array may be unreadable, for example:
$testArray=array(
	"meses"=>array(
		1=>array("en"=>"january","es"=>"enero",
		2=>array("en"=>"february","es"=>"febrero",
		3=>array("en"=>"march","es"=>"marzo",
		4=>array("en"=>"april","es"=>"abril",
		5=>array("en"=>"mai","es"=>"mayo")
	),
	"colors"=>array(
		"#f00"=>array("en"=>"red","es"=>"rojo"),
		"#0f0"=>array("en"=>"green","es"=>"verde"),
		"#00f"=>array("en"=>"blue","es"=>"azul"),
		"#000"=>array("en"=>"black","es"=>"negro"),
		"#fff"=>array("en"=>"white","es"=>"blanco")
	)
);
By using print_r with this array:
print_r($testArray);
It returns:
Array ( [meses] => Array ( [1] => Array ( [en] => january [es] => enero )
[2] => Array ( [en] => february [es] => febrero ) [3] => Array ( [en] =>
march [es] => marzo ) [4] => Array ( [en] => april [es] => abril ) [5] =>
Array ( [en] => mai [es] => mayo ) ) [colors] => Array ( [#f00] => Array
( [en] => red [es] => rojo ) [#0f0] => Array ( [en] => green [es] => verde )
[#00f] => Array ( [en] => blue [es] => azul ) [#000] => Array ( [en] =>
 black [es] => negro ) [#fff] => Array ( [en] => white [es] => blanco ) ) ) 
Wrapping the result of print_r with a PRE tag, make the code more readable and easier to debug:
print "<pre>";
print_r($testArray);
print "</pre>";
It returns:
Array
(
    [meses] => Array
        (
            [1] => Array
                (
                    [en] => january
                    [es] => enero
                )
            [2] => Array
                (
                    [en] => february
                    [es] => febrero
                )
            [3] => Array
                (
                    [en] => march
                    [es] => marzo
                )
            [4] => Array
                (
                    [en] => april
                    [es] => abril
                )
            [5] => Array
                (
                    [en] => mai
                    [es] => mayo
                )

        )
    [colors] => Array
        (
            [#f00] => Array
                (
                    [en] => red
                    [es] => rojo
                )
            [#0f0] => Array
                (
                    [en] => green
                    [es] => verde
                )
            [#00f] => Array
                (
                    [en] => blue
                    [es] => azul
                )
            [#000] => Array
                (
                    [en] => black
                    [es] => negro
                )
            [#fff] => Array
                (
                    [en] => white
                    [es] => blanco
                )
        )
)
We can also make it a function if you frequently use:
function print_rPre($arr){
 print "<pre>";
 print_r($arr);
 print "</pre>";
}

JavaScript tricks: document.getElementById

When programming with the DOM the function document.getElementById function is frequently used, we can reduce the code making it a function with a name shorter and easier to remember:
gEle=function(a){
return ((typeof a==="string")?document.getElementById(a):a);
};

Parameters

This function only needs the string of the id of the object and returns the dom element with that id.

Sample usage

In our html source code we insert a DIV element with id “gEleSamp”
<div id="gEleSamp" style="border:solid 1px #ccc;">sample div</div>
The result of our code:
sample div
We access to the object with gEle using their id and we change the font color to red:
<span onclick="gEle('gEleSamp').style.color='#f00'">Test </span>
Test the code pressing the following link:Test

Blender render: X-mas

X-mas made with Blender

Blender renders: In the kitchen

Scene modelled and rendered with Blender