Browse Source

Started some tweaking of CTRLPainter's render system... see if I can speed it up a little?

dev
Bryan Miller 5 years ago
parent
commit
54108ae3b8
1 changed files with 32 additions and 20 deletions
  1. +32
    -20
      app/js/ctrls/CTRLPainter.js

+ 32
- 20
app/js/ctrls/CTRLPainter.js View File

this.scale = Number(s); this.scale = Number(s);
} }


render(){
if (context === null){return this;}
if (this.__surface === null){
Renderer.clear(context, NESPalette.Default[4]);
return this;
}

// Drawing the surface to the canvas.
Renderer.render(
this.__surface,
0, 0,
this.__surface.width, this.__surface.height,
this.__scale,
context,
this.__offset[0], this.__offset[1],
!this.__onePaletteMode
);


context.save();
renderCursor(){
if (context === null || this.__surface === null){return this;}


// Draw the mouse position... if mouse is currently in bounds. // Draw the mouse position... if mouse is currently in bounds.
if (input.isMouseInBounds()){ if (input.isMouseInBounds()){
context.save();
context.fillStyle = "#AA9900"; context.fillStyle = "#AA9900";
var x = Math.floor((this.__brushPos[0] - this.__offset[0]) * (1.0/this.__scale)); var x = Math.floor((this.__brushPos[0] - this.__offset[0]) * (1.0/this.__scale));
var y = Math.floor((this.__brushPos[1] - this.__offset[1]) * (1.0/this.__scale)); var y = Math.floor((this.__brushPos[1] - this.__offset[1]) * (1.0/this.__scale));
context.fill(); context.fill();
context.closePath(); context.closePath();
} }
context.restore();
} }
return this;
}

renderGrid(){
if (context === null || this.__surface === null){return this;}
context.save();


// Draw grid. // Draw grid.
if (this.__gridEnabled && this.__scale > 0.5){ if (this.__gridEnabled && this.__scale > 0.5){


return this; return this;
} }

render(){
if (context === null){return this;}
if (this.__surface === null){
Renderer.clear(context, NESPalette.Default[4]);
return this;
}

// Drawing the surface to the canvas.
Renderer.render(
this.__surface,
0, 0,
this.__surface.width, this.__surface.height,
this.__scale,
context,
this.__offset[0], this.__offset[1],
!this.__onePaletteMode
);
return this.renderCursor().renderGrid();
}
} }





Loading…
Cancel
Save