Set Trailing Cmma to (#525)

This commit is contained in:
Lipis 2020-01-24 12:04:54 +02:00 committed by GitHub
parent 25202aec11
commit ee68af0fd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 352 additions and 350 deletions

View file

@ -3,7 +3,7 @@ import { isTextElement } from "../element/typeChecks";
import {
getDiamondPoints,
getArrowPoints,
getLinePoints
getLinePoints,
} from "../element/bounds";
import { RoughCanvas } from "roughjs/bin/canvas";
import { Drawable } from "roughjs/bin/core";
@ -11,7 +11,7 @@ import { Drawable } from "roughjs/bin/core";
export function renderElement(
element: ExcalidrawElement,
rc: RoughCanvas,
context: CanvasRenderingContext2D
context: CanvasRenderingContext2D,
) {
const generator = rc.generator;
if (element.type === "selection") {
@ -30,7 +30,7 @@ export function renderElement(
fillStyle: element.fillStyle,
strokeWidth: element.strokeWidth,
roughness: element.roughness,
seed: element.seed
seed: element.seed,
});
}
@ -47,14 +47,14 @@ export function renderElement(
bottomX,
bottomY,
leftX,
leftY
leftY,
] = getDiamondPoints(element);
element.shape = generator.polygon(
[
[topX, topY],
[rightX, rightY],
[bottomX, bottomY],
[leftX, leftY]
[leftX, leftY],
],
{
stroke: element.strokeColor,
@ -65,8 +65,8 @@ export function renderElement(
fillStyle: element.fillStyle,
strokeWidth: element.strokeWidth,
roughness: element.roughness,
seed: element.seed
}
seed: element.seed,
},
);
}
@ -90,8 +90,8 @@ export function renderElement(
strokeWidth: element.strokeWidth,
roughness: element.roughness,
seed: element.seed,
curveFitting: 1
}
curveFitting: 1,
},
);
}
@ -104,7 +104,7 @@ export function renderElement(
stroke: element.strokeColor,
strokeWidth: element.strokeWidth,
roughness: element.roughness,
seed: element.seed
seed: element.seed,
};
if (!element.shape) {
@ -114,7 +114,7 @@ export function renderElement(
// -----
generator.line(x1, y1, x2, y2, options),
// /
generator.line(x4, y4, x2, y2, options)
generator.line(x4, y4, x2, y2, options),
];
}
@ -128,7 +128,7 @@ export function renderElement(
stroke: element.strokeColor,
strokeWidth: element.strokeWidth,
roughness: element.roughness,
seed: element.seed
seed: element.seed,
};
if (!element.shape) {
@ -147,7 +147,7 @@ export function renderElement(
context.fillText(
element.text,
0,
element.baseline || element.actualBoundingBoxAscent || 0
element.baseline || element.actualBoundingBoxAscent || 0,
);
context.fillStyle = fillStyle;
context.font = font;

View file

@ -8,7 +8,7 @@ import { SceneState } from "../scene/types";
import {
getScrollBars,
SCROLLBAR_COLOR,
SCROLLBAR_WIDTH
SCROLLBAR_WIDTH,
} from "../scene/scrollbars";
import { renderElement } from "./renderElement";
@ -23,13 +23,13 @@ export function renderScene(
offsetX,
offsetY,
renderScrollbars = true,
renderSelection = true
renderSelection = true,
}: {
offsetX?: number;
offsetY?: number;
renderScrollbars?: boolean;
renderSelection?: boolean;
} = {}
} = {},
) {
if (!canvas) return;
const context = canvas.getContext("2d")!;
@ -53,7 +53,7 @@ export function renderScene(
sceneState = {
...sceneState,
scrollX: typeof offsetX === "number" ? offsetX : sceneState.scrollX,
scrollY: typeof offsetY === "number" ? offsetY : sceneState.scrollY
scrollY: typeof offsetY === "number" ? offsetY : sceneState.scrollY,
};
elements.forEach(element => {
@ -65,19 +65,19 @@ export function renderScene(
// If canvas is scaled for high pixelDeviceRatio width and height
// setted in the `style` attribute
parseInt(canvas.style.width) || canvas.width,
parseInt(canvas.style.height) || canvas.height
parseInt(canvas.style.height) || canvas.height,
)
) {
return;
}
context.translate(
element.x + sceneState.scrollX,
element.y + sceneState.scrollY
element.y + sceneState.scrollY,
);
renderElement(element, rc, context);
context.translate(
-element.x - sceneState.scrollX,
-element.y - sceneState.scrollY
-element.y - sceneState.scrollY,
);
});
@ -91,7 +91,7 @@ export function renderScene(
elementX1,
elementY1,
elementX2,
elementY2
elementY2,
] = getElementAbsoluteCoords(element);
const lineDash = context.getLineDash();
context.setLineDash([8, 4]);
@ -99,7 +99,7 @@ export function renderScene(
elementX1 - margin + sceneState.scrollX,
elementY1 - margin + sceneState.scrollY,
elementX2 - elementX1 + margin * 2,
elementY2 - elementY1 + margin * 2
elementY2 - elementY1 + margin * 2,
);
context.setLineDash(lineDash);
});
@ -118,7 +118,7 @@ export function renderScene(
context.canvas.width / window.devicePixelRatio,
context.canvas.height / window.devicePixelRatio,
sceneState.scrollX,
sceneState.scrollY
sceneState.scrollY,
);
const strokeStyle = context.strokeStyle;
@ -132,7 +132,7 @@ export function renderScene(
scrollBar.y,
scrollBar.width,
scrollBar.height,
SCROLLBAR_WIDTH / 2
SCROLLBAR_WIDTH / 2,
);
});
context.strokeStyle = strokeStyle;
@ -145,7 +145,7 @@ function isVisibleElement(
scrollX: number,
scrollY: number,
canvasWidth: number,
canvasHeight: number
canvasHeight: number,
) {
let [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
x1 += scrollX;

View file

@ -14,7 +14,7 @@ export function roundRect(
y: number,
width: number,
height: number,
radius: number
radius: number,
) {
context.beginPath();
context.moveTo(x + radius, y);
@ -25,7 +25,7 @@ export function roundRect(
x + width,
y + height,
x + width - radius,
y + height
y + height,
);
context.lineTo(x + radius, y + height);
context.quadraticCurveTo(x, y + height, x, y + height - radius);