OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 image.onload = function() { | 110 image.onload = function() { |
111 draw(imageContainer); | 111 draw(imageContainer); |
112 }; | 112 }; |
113 return; | 113 return; |
114 } | 114 } |
115 | 115 |
116 canvas.width = imageContainer.clientWidth; | 116 canvas.width = imageContainer.clientWidth; |
117 canvas.height = imageContainer.clientHeight; | 117 canvas.height = imageContainer.clientHeight; |
118 | 118 |
119 var ctx = canvas.getContext('2d'); | 119 var ctx = canvas.getContext('2d'); |
120 ctx.webkitImageSmoothingEnabled = false; | |
121 ctx.mozImageSmoothingEnabled = false; | 120 ctx.mozImageSmoothingEnabled = false; |
122 ctx.imageSmoothingEnabled = false; | 121 ctx.imageSmoothingEnabled = false; |
123 ctx.translate(imageContainer.clientWidth / 2, imageContainer.clientHeight /
2); | 122 ctx.translate(imageContainer.clientWidth / 2, imageContainer.clientHeight /
2); |
124 ctx.translate(-pixelzoomer._percentX * kZoomedResultWidth, -pixelzoomer._per
centY * kZoomedResultHeight); | 123 ctx.translate(-pixelzoomer._percentX * kZoomedResultWidth, -pixelzoomer._per
centY * kZoomedResultHeight); |
125 ctx.strokeRect(-1.5, -1.5, kZoomedResultWidth + 2, kZoomedResultHeight + 2); | 124 ctx.strokeRect(-1.5, -1.5, kZoomedResultWidth + 2, kZoomedResultHeight + 2); |
126 ctx.scale(kZoomFactor, kZoomFactor); | 125 ctx.scale(kZoomFactor, kZoomFactor); |
127 ctx.drawImage(image, 0, 0); | 126 ctx.drawImage(image, 0, 0); |
128 } | 127 } |
129 | 128 |
130 function drawAll() | 129 function drawAll() |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 178 |
180 pixelzoomer.showOnDelay = true; | 179 pixelzoomer.showOnDelay = true; |
181 | 180 |
182 pixelzoomer.installEventListeners = function() | 181 pixelzoomer.installEventListeners = function() |
183 { | 182 { |
184 document.addEventListener('mousemove', handleMouseMove, false); | 183 document.addEventListener('mousemove', handleMouseMove, false); |
185 document.addEventListener('mouseout', handleMouseOut, false); | 184 document.addEventListener('mouseout', handleMouseOut, false); |
186 }; | 185 }; |
187 | 186 |
188 })(); | 187 })(); |
OLD | NEW |