Ver Mensaje Individual
  #17 (permalink)  
Antiguo 20/01/2012, 08:53
Avatar de Yedi
Yedi
 
Fecha de Ingreso: junio-2006
Ubicación: México
Mensajes: 159
Antigüedad: 17 años, 10 meses
Puntos: 2
Respuesta: Salto de linea en un texto?

Gracias por el Interes


Aqui les va el codigo completo de la página

Código HTML:
Ver original
  1. <!DOCTYPE HTML>
  2. <title>Mapa de Sucursales y Oficinas</title>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  4.        <style>
  5.             body {
  6.                 margin: 0px;
  7.                 padding: 0px;
  8.                 font-family: Calibri;
  9.             }
  10.            
  11.             canvas {
  12.                 border: 1px solid #9C9898;
  13.             }
  14.            
  15.             #page {
  16.                 position: relative;
  17.                 width: 800px;
  18.                 height: 450px;
  19.             }
  20.            
  21.             #controls {
  22.                 position: absolute;
  23.                 right: 10px;
  24.                 top: 10px;
  25.                 z-index: 99999;
  26.             }
  27.            
  28.             label {
  29.                 color: white;
  30.                 vertical-align: top;
  31.             }
  32.         </style>
  33.         <script src="kinetic-v3.5.2.js">
  34.         </script>
  35.        <script>
  36.             function writeMessage(context, message){
  37.                 context.fillStyle = "white";
  38.                 context.fillRect(500, 20, 450, 200);
  39.                 context.font = "20pt Calibri";
  40.                 context.fillStyle = "blue";
  41.                 context.fillText(message, 500, 80);
  42.             }
  43.            
  44.             window.onload = function(){
  45.                 var stage = new Kinetic.Stage("container", 900, 500);
  46.                 var canvas = stage.getCanvas();
  47.                 var stageContext = stage.getContext();
  48.                 var showImageMap = false;
  49.                
  50.                 var baja = "Baja California '<br>' zzzz";
  51.                              
  52.                 var planets = {
  53.                     "SUCURSAL TIJUANA, B.C.": {
  54.                         x: 35,
  55.                         y: 35,
  56.                         radius: 11,
  57.                
  58.                     },
  59.                    "SUCURSAL MEXICALI, B.C.": {
  60.                         x: 179,
  61.                         y: 126,
  62.                         radius: 6
  63.                     },
  64.                     "OFICINA LA PAZ, B.C.": {
  65.                         x: 366,
  66.                         y: 127,
  67.                         radius: 6
  68.                     },
  69.                     "SUCURSAL HERMOSILLO, SON": {
  70.                         x: 515,
  71.                         y: 127,
  72.                         radius: 6
  73.                     },
  74.                     "Baja CaliforniaTel. 123": {
  75.                         x: 200,
  76.                         y: 100,
  77.                         radius: 6
  78.                     }
  79.                 };
  80.                
  81.                 var imageObj = new Image();
  82.                 imageObj.onload = function(){
  83.                     // draw planets
  84.                     stageContext.drawImage(imageObj, 0, 0, canvas.width, canvas.height);
  85.                    
  86.                     // draw shape overlays
  87.                     for (var pubKey in planets) {
  88.                         (function(){
  89.                             var key = pubKey;
  90.                             var planet = planets[key];
  91.                            
  92.                             var planetOverlay = new Kinetic.Shape(function(){
  93.                                 var context = this.getContext();
  94.                                 context.beginPath();
  95.                                 context.arc(planet.x, planet.y, planet.radius, 0, Math.PI * 2, false);
  96.                                 context.closePath();
  97.                                
  98.                                 if (this.fill) {
  99.                                     context.fillStyle = "red";
  100.                                     context.fill();
  101.                                 }
  102.                             });
  103.                            
  104.                             planetOverlay.on("mouseover", function(){
  105.                                 writeMessage(stageContext, key);
  106.                             });
  107.                             planetOverlay.on("mouseout", function(){
  108.                                 writeMessage(stageContext, "");
  109.                             });
  110.                            
  111.                            
  112.                             planetOverlay.fill = false;
  113.                             stage.add(planetOverlay);
  114.                         }());
  115.                     }
  116.                    
  117.                     var checkbox = document.getElementById("checkbox");
  118.                     checkbox.addEventListener("click", function(){
  119.                         showImageMap = !showImageMap;
  120.                         var shapes = stage.getShapes();
  121.                        
  122.                         // reset fill property
  123.                         for (var n = 0; n < shapes.length; n++) {
  124.                            var shape = shapes[n];
  125.                            shape.fill = showImageMap;
  126.                        }
  127.                        
  128.                        stage.draw();
  129.                    }, false);
  130.                    
  131.                };
  132.                imageObj.src = "images/mapasucyof.png";
  133.            };
  134.        </script>
  135. </head>
  136. <body onmousedown="return false;">
  137. <section>  
  138. <div id="page" >
  139.             <div id="container" class="back"></div>
  140.             <div id="controls">
  141.                 <input type="checkbox" id="checkbox">
  142.                 <label>
  143.                     Show map overlay
  144.                 </label>
  145.             </div>
  146.  
  147.         </div>
  148.  
  149. </body>
  150. </html>

El código de kinetic lo descargue de la siguiente liga:
http://www.html5canvastutorials.com/...etic-v3.6.0.js

Y el ejemplo original es el siguiente: http://www.html5canvastutorials.com/.../#comment-3113


Gracias