Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ http://chrome.google.com/webstore/detail/lciiccjdlhnedcpdpelgmdd

Demo video here:
http://www.youtube.com/watch?v=OmRuPiRgQFE

# Contributors
- [Allan Carroll](https://github.com/allanca)
Binary file added arrow_down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 0 additions & 80 deletions background.html

This file was deleted.

24 changes: 24 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.captureVisibleTab(null, function(img) {
var screenshotUrl = img;
var viewTabUrl = chrome.extension.getURL('pivotate.html');
chrome.tabs.create({url: viewTabUrl}, function(tab) {
var targetId = tab.id;
var addSnapshotImageToTab = function(tabId, changedProps) {
if (tabId != targetId || changedProps.status != "complete") {
return;
}
chrome.tabs.onUpdated.removeListener(addSnapshotImageToTab);
var views = chrome.extension.getViews();
for (var i = 0; i < views.length; i++) {
var view = views[i];
if (view.location.href == viewTabUrl) {
view.pivotate.init(screenshotUrl);
break;
}
}
};
chrome.tabs.onUpdated.addListener(addSnapshotImageToTab);
});
});
});
93 changes: 93 additions & 0 deletions canvas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
var ImgCanvas = function(canvas) {

var self = this,
draw;

this.canvas = canvas;
this.context = canvas.getContext("2d");
this.typeDraw = 'line';
draw = this[this.typeDraw]();
var mouseEvt = function(event) {
if (event.offsetX || event.offsetX == 0) {
event._x = event.offsetX;
event._y = event.offsetY;
}

var func = draw[event.type];
if (func) {
func(event);
}
};

this.canvas.addEventListener('mousedown', mouseEvt, false);
this.canvas.addEventListener('mousemove', mouseEvt, false);
this.canvas.addEventListener('mouseup', mouseEvt, false);
}


ImgCanvas.prototype = {
setBackground : function(background) {

var self = this;

if (!background) {
return;
}

var image = new Image();
image.src = background;
image.onload = function() {
self.context.drawImage(
image,
0,
0,
self.canvas.getAttribute("width").replace("px", ""),
self.canvas.getAttribute("height").replace("px", "")
);
}
},
line : function() {

var self = this;
this.start = false;

this._mousemove = function(event) {
if (!this.start) {
return;
}
this.context.strokeStyle = "#ff0000";
this.context.lineTo(event._x, event._y);
this.context.stroke();
};

this._mousedown = function(event) {
this.context.beginPath();
this.context.moveTo(event._x, event._y);
this.start = true;
};

this._mouseup = function(event) {
if (!this.start) {
return;
}
this._mousemove(event);
this.start = false;
};

return {
mousedown : function(event) {
self._mousedown(event);
},
mousemove : function(event) {
self._mousemove(event);
},
mouseup : function(event) {
self._mouseup(event);
}
}
},
getImg : function() {
var dataURL = this.canvas.toDataURL("image/png");
return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}
}
2 changes: 0 additions & 2 deletions canvasdestroy.js

This file was deleted.

Loading