Thursday, December 27, 2007

Dynamically create SVG with javascript

Following is an example of dynamically created SVG pattern with javascript and DOM. The name space part is tricky and can be frustrating for people not familiar with it. The hard parts are high lighted in red.

=============================



<?xml version="1.0" ?>

<html xmlns="http://www.w3.org/1999/xhtml" 

                 xmlns:svg="http://www.w3.org/2000/svg"

     xmlns:xlink="http://www.w3.org/1999/xlink"

     lang="en-US">

 <head>

  <meta http-equiv="Content-Type" content="application/xhtml+xml;charset=utf-8"/>

  <title>SVG</title>

  <style type="text/css">

   #drawingPad{

    width:100px;

    height:100px;

    overflow:hidden;

    border:1px solid black;

    position:absolute

   }
  </style>

  <script type="text/javascript">

  <![CDATA[

//________________________________

var xhtmlNS = "http://www.w3.org/1999/xhtml";

var svgNS = "http://www.w3.org/2000/svg";

var xlinkNS ="http://www.w3.org/1999/xlink";

function makeCircle(x, y, r){

 var vCircle = document.createElementNS(svgNS, "svg:circle")

 vCircle.setAttributeNS( null, "cx", new String( x  ) + "px" );

 vCircle.setAttributeNS( null, "cy", new String( y  ) + "px" );

 vCircle.setAttributeNS( null, "r", new String( r ) +"px");

 vCircle.setAttributeNS( null, "style", "fill:blue");

 return vCircle;

}

function makeLine(x1, y1, x2, y2){

 var vLine = document.createElementNS(svgNS, "svg:line")

 vLine.setAttributeNS( null, "x1", new String( x1  ) + "px" );

 vLine.setAttributeNS( null, "y1", new String( y1  ) + "px" );

 vLine.setAttributeNS( null, "x2", new String( x2  ) + "px" );

 vLine.setAttributeNS( null, "y2", new String( y2  ) + "px" );

 vLine.setAttributeNS( null, "style", "stroke-width:2;stroke:red");

 return vLine;

}



function drawPattern(){

 var vPad = document.getElementById( "drawingPad" );

 var vSVGElem = document.createElementNS(svgNS, "svg:svg");

 var i;

 var r = 20;

 var vAX = new Array();

 var vAY = new Array();

 for( i = 0 ; i < 7 ; i ++ ){

  var vAngle = Math.PI * 4 / 7 * i

  var vX = Math.cos(vAngle) * r + 50

  var vY = Math.sin( vAngle ) * r + 50

  var vC = makeCircle(vX, vY, 4);

  vSVGElem.appendChild( vC);

  vAX[ i ] = vX

  vAY[ i ] = vY

  if( i > 0 ){

   var vLine = makeLine(vX, vY, vAX[ i - 1 ], vAY[ i - 1 ]);

   vSVGElem.appendChild( vLine );

   

  }

 }

 vPad.appendChild(vSVGElem) 

}

 ]]>-->

</script>

</head>

<body>

<form>

 <input type="button" onclick="drawPattern(); return false;" value="Click"/>

</form>

<div id="drawingPad">

 

</div>



</body>

</html>
=============================

Labels: ,

Friday, December 21, 2007

Firefox bookmark recovery

Bookmark troubles with Firefox? Not to worry. There is a good article about lost Firefox bookmark at Mozillazine.

Labels: ,

Thursday, December 20, 2007

Firefox 3.0 beta 2

Release note. The SVG performance has been improved a lot since beta 1.

Wednesday, December 19, 2007

IE8 passed the acid2 test

IE8 passed the acid2 test. It's time for the acid3.

Labels:

Friday, December 14, 2007

Dancing of the CPUs

1971Intel 40044bit.
1972 CTC/Intel 8008 14bit
Intel 4040
1973 Intel 8080 16bit
1974 Intel 8080A 16bit
TI TMS 1000 4bit
AMD 9080
Motorola 6800
1975Mos Technology 6501/6502
Microchip Technology PIC 16X
1976 Intel 8085
Zilog Z80
RCA 1802
1977Motoroal 6809
Intel 8048
1978Intel 8086 AMD, Harris
Zilog Z8000
1979Intel 8088
Motorola 68000/6809
Zilog Z8
1980Intel 8051
1981NEC V20
Intel 432
1983Intel 80186
1982Intel 80286 AMD, IBM, Harris, Siemens, Fujitsu, Kruger
1984Intel 960
1985 ARM1
Zilog Z800/Z80000
MIPS R2000
1986 ARM2
SPARK V7
Fairchild Clipper C100
Zilog Z280/Z180
1988 AMD AM29000
Integraph Clipper C300
1987 Motorola 68030
Intel 386
MIPS R3000
1989 PA-7000
Intel 486
Intel 860
1990 Motorola 68040
Integraph Clipper C400
Sun SPARC
1991 MIPS R4000
IBM 386SLC
AM386
ARM6
1992 DEC Alpha 21064
PA-7100
Cyrix 486SLC/DLC
IBM 486SLC
1993Intel Pentium
MIPS R4400
IBM/Motorola PowerPC 601
1994AMD AM486
PA-7150/7200
MIPS R4600/R8000
SUN SPARC II
DEC Alpha 21164
Zilog Z380
IBM/Motorola PowerPC603
1995AMD AM5x86
Cyrix 5x86/6x86
MIPS R10000
Intel Pentium Pro
1996Cyrix MediaGX
PA-7300/8000
Alpha 21264
AMD K5
1997Intel Pentium MMX
PA-8200
AMD K6
Cyrix 6x86MX
Cyrix MediaGX
Intel Pentium II
1998Intel Celeron
PA-8500
Alpha 21264
MIPS R12000
AMD K6-2
1999Intel Pentium III
National Semiconductor Geode
AMD K6 III
AMD Athlon
2000Celeron II
PA-8600
VIA Cyrix III
AMD Duron
Pentium IV
2001 PA-8700
MIPS R14000
VIA C3
Zilog eZ80
Intel/HP Itanium
2002 Alpha 21364
MIPS R16000
AMD Geode
Xscale PXA250
Intel/HP Itanium 2
2003 PA-8800
Intel Pentium M
Intel Celeron M
Intel Pentium 4EE
AMD Athlon64/Opteron
2004 Intel Pentium 4E/4F
VIA Isaiah
AMD Sempron
2005 PA-8900
Zilog eZ8
VIA C7
Pentium D
2006 Zilog Z16
Intel Core Solo/Duo
Intel Core 2 Solo/Duo
2007 Intel CE 2110

Labels: ,