Respects current ctx scale for mesh pattern
This commit is contained in:
parent
561683d2e9
commit
3595c2c360
@ -148,21 +148,21 @@ var createMeshCanvas = (function createMeshCanvasClosure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMeshCanvas(owner, bounds, coords, colors, figures,
|
function createMeshCanvas(bounds, combinesScale, coords, colors, figures,
|
||||||
backgroundColor) {
|
backgroundColor) {
|
||||||
// we will increase scale on some weird factor to let antialiasing take
|
// we will increase scale on some weird factor to let antialiasing take
|
||||||
// care of "rough" edges
|
// care of "rough" edges
|
||||||
var EXPECTED_SCALE = 1.5;
|
var EXPECTED_SCALE = 1.1;
|
||||||
// MAX_PATTERN_SIZE is used to avoid OOM situation.
|
// MAX_PATTERN_SIZE is used to avoid OOM situation.
|
||||||
var MAX_PATTERN_SIZE = 3000; // 10in @ 300dpi shall be enough
|
var MAX_PATTERN_SIZE = 3000; // 10in @ 300dpi shall be enough
|
||||||
|
|
||||||
var boundsWidth = bounds[2] - bounds[0];
|
var boundsWidth = bounds[2] - bounds[0];
|
||||||
var boundsHeight = bounds[3] - bounds[1];
|
var boundsHeight = bounds[3] - bounds[1];
|
||||||
|
|
||||||
var width = Math.min(Math.ceil(Math.abs(boundsWidth * EXPECTED_SCALE)),
|
var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] *
|
||||||
MAX_PATTERN_SIZE);
|
EXPECTED_SCALE)), MAX_PATTERN_SIZE);
|
||||||
var height = Math.min(Math.ceil(Math.abs(boundsHeight * EXPECTED_SCALE)),
|
var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] *
|
||||||
MAX_PATTERN_SIZE);
|
EXPECTED_SCALE)), MAX_PATTERN_SIZE);
|
||||||
var scaleX = width / boundsWidth;
|
var scaleX = width / boundsWidth;
|
||||||
var scaleY = height / boundsHeight;
|
var scaleY = height / boundsHeight;
|
||||||
|
|
||||||
@ -206,10 +206,24 @@ ShadingIRs.Mesh = {
|
|||||||
return {
|
return {
|
||||||
type: 'Pattern',
|
type: 'Pattern',
|
||||||
getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
|
getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
|
||||||
|
var combinedScale;
|
||||||
|
// Obtain scale from matrix and current transformation matrix.
|
||||||
|
if (shadingFill) {
|
||||||
|
combinedScale = Util.singularValueDecompose2dScale(
|
||||||
|
ctx.mozCurrentTransform);
|
||||||
|
} else {
|
||||||
|
var matrixScale = Util.singularValueDecompose2dScale(matrix);
|
||||||
|
var curMatrixScale = Util.singularValueDecompose2dScale(
|
||||||
|
owner.baseTransform);
|
||||||
|
combinedScale = [matrixScale[0] * curMatrixScale[0],
|
||||||
|
matrixScale[1] * curMatrixScale[1]];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Rasterizing on the main thread since sending/queue large canvases
|
// Rasterizing on the main thread since sending/queue large canvases
|
||||||
// might cause OOM.
|
// might cause OOM.
|
||||||
// TODO consider using WebGL or asm.js to perform rasterization
|
// TODO consider using WebGL or asm.js to perform rasterization
|
||||||
var temporaryPatternCanvas = createMeshCanvas(owner, bounds,
|
var temporaryPatternCanvas = createMeshCanvas(bounds, combinedScale,
|
||||||
coords, colors, figures, shadingFill ? null : background);
|
coords, colors, figures, shadingFill ? null : background);
|
||||||
|
|
||||||
if (!shadingFill) {
|
if (!shadingFill) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user