mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-10-24 16:34:24 +02:00
Binding highlight rotation support + image support
This commit is contained in:
@@ -119,20 +119,21 @@ export class ShapeCache {
|
|||||||
embedsValidationStatus: EmbedsValidationStatus;
|
embedsValidationStatus: EmbedsValidationStatus;
|
||||||
},
|
},
|
||||||
) => {
|
) => {
|
||||||
const shape = generateElementShape(
|
let shape =
|
||||||
element,
|
(ShapeCache.get(element) as Drawable | null) ||
|
||||||
ShapeCache.rg,
|
(ShapeCache.rg.rectangle(0, 0, element.width, element.height, {
|
||||||
renderConfig || {
|
roughness: 0,
|
||||||
isExporting: false,
|
strokeWidth: 2,
|
||||||
canvasBackgroundColor: COLOR_PALETTE.white,
|
}) as Drawable);
|
||||||
embedsValidationStatus: null,
|
|
||||||
},
|
// Clone the shape from the cache
|
||||||
) as Drawable;
|
shape = {
|
||||||
|
...shape,
|
||||||
|
};
|
||||||
|
|
||||||
shape.options.fill = "transparent";
|
shape.options.fill = "transparent";
|
||||||
shape.options.stroke =
|
shape.options.stroke =
|
||||||
appState.theme === THEME.DARK ? "#035da1" : "#6abdfc";
|
appState.theme === THEME.DARK ? "#035da1" : "#6abdfc";
|
||||||
shape.options.strokeWidth = shape.options.strokeWidth * 1.1;
|
|
||||||
|
|
||||||
return shape;
|
return shape;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -254,12 +254,22 @@ const renderBindingHighlight = (
|
|||||||
appState: InteractiveCanvasAppState,
|
appState: InteractiveCanvasAppState,
|
||||||
suggestedBinding: NonNullable<InteractiveCanvasAppState["suggestedBinding"]>,
|
suggestedBinding: NonNullable<InteractiveCanvasAppState["suggestedBinding"]>,
|
||||||
) => {
|
) => {
|
||||||
|
const cx =
|
||||||
|
(suggestedBinding.x + suggestedBinding.width / 2 + appState.scrollX) *
|
||||||
|
window.devicePixelRatio;
|
||||||
|
const cy =
|
||||||
|
(suggestedBinding.y + suggestedBinding.height / 2 + appState.scrollY) *
|
||||||
|
window.devicePixelRatio;
|
||||||
context.save();
|
context.save();
|
||||||
|
|
||||||
|
context.translate(cx, cy);
|
||||||
|
context.rotate(suggestedBinding.angle);
|
||||||
|
context.translate(-cx, -cy);
|
||||||
context.translate(
|
context.translate(
|
||||||
appState.scrollX + suggestedBinding.x,
|
appState.scrollX + suggestedBinding.x,
|
||||||
appState.scrollY + suggestedBinding.y,
|
appState.scrollY + suggestedBinding.y,
|
||||||
);
|
);
|
||||||
|
context.scale(1 / window.devicePixelRatio, 1 / window.devicePixelRatio);
|
||||||
|
|
||||||
const drawable = ShapeCache.generateBindableElementHighlight(
|
const drawable = ShapeCache.generateBindableElementHighlight(
|
||||||
suggestedBinding,
|
suggestedBinding,
|
||||||
|
|||||||
Reference in New Issue
Block a user