Skip to content

Commit

Permalink
Merge pull request #2 from gual/user-laser-opt
Browse files Browse the repository at this point in the history
Added option to use as pointer
  • Loading branch information
denniskniep authored Nov 2, 2018
2 parents fa0d7ab + 50f7aa0 commit 870ac7b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ Reveal.initialize({
presentingCursor: "none",

// true: cursor is always "none" except when spotlight is on.
presentingCursorOnlyVisibleWhenSpotlightVisible: true
presentingCursorOnlyVisibleWhenSpotlightVisible: true,

// enable pointer mode
useAsPointer: true,

// pointer color (If pointer mode enabled)
pointerColor
},
keyboard: {
// alternative to toggleSpotlightOnMouseDown:
Expand Down Expand Up @@ -86,6 +92,15 @@ When you are in presentation mode the cursor is always "none" except when spotli
`false`:
Configuration item `presentingCursor` is always used as cursor value, when you are in presentation mode.
#### useAsPointer
Default: false
Enables a mode where the screen is not dimmed and you can use the mouse as a pointer.
#### pointerColor
Default: `red`
Defines the pointer color if configuration item `useAsPointer` is true.
### Methods
Expand Down
18 changes: 15 additions & 3 deletions spotlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ var RevealSpotlight = window.RevealSpotlight || (function(){
var toggleOnMouseDown;
var presentingCursor;
var presentingCursorOnlyVisibleWhenSpotlightVisible;
var useAsPointer;
var pointerColor;

var drawBoard;
var isSpotlightOn = true;
Expand All @@ -30,6 +32,8 @@ var RevealSpotlight = window.RevealSpotlight || (function(){
var config = Reveal.getConfig().spotlight || {};
spotlightSize = config.size || 60;
presentingCursor = config.presentingCursor || "none";
useAsPointer = config.useAsPointer || false;
pointerColor = config.pointerColor || 'red';

if(config.hasOwnProperty("toggleSpotlightOnMouseDown")){
toggleOnMouseDown = config.toggleSpotlightOnMouseDown;
Expand Down Expand Up @@ -151,12 +155,20 @@ var RevealSpotlight = window.RevealSpotlight || (function(){
maskCanvas.width = canvas.width;
maskCanvas.height = canvas.height;

var maskCtx = maskCanvas.getContext('2d');
maskCtx.fillStyle = "#000000A8";
var maskCtx = maskCanvas.getContext('2d');

// If using as pointer draw a transparent background
var fillStyle = useAsPointer ? "rgba(0, 0, 0, 0)" : "#000000A8"

maskCtx.fillStyle = fillStyle;
maskCtx.fillRect(0, 0, maskCanvas.width, maskCanvas.height);
maskCtx.globalCompositeOperation = 'xor';

maskCtx.fillStyle = "#FFFFFFFF";

// If using as pointer draw specified color or default
var mouseFillStyle = useAsPointer ? pointerColor : "#FFFFFFFF"

maskCtx.fillStyle = mouseFillStyle;
maskCtx.arc(mousePos.x, mousePos.y, spotlightSize, 0, 2 * Math.PI);
maskCtx.fill();

Expand Down

0 comments on commit 870ac7b

Please sign in to comment.