border radius
This commit is contained in:
@@ -49,6 +49,8 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
|
||||
};
|
||||
|
||||
const renderObject = (obj: EditorObject, index: number) => {
|
||||
const actualStrokeWidth = obj.strokeWidth ?? 0;
|
||||
const hasStroke = actualStrokeWidth > 0;
|
||||
const baseStyle: React.CSSProperties = {
|
||||
position: 'absolute',
|
||||
left: `${(obj.x || 0) * scale}px`,
|
||||
@@ -220,8 +222,8 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
|
||||
height: `${radius * 2}px`,
|
||||
borderRadius: '50%',
|
||||
backgroundColor: obj.fill || 'transparent',
|
||||
border: obj.stroke
|
||||
? `${(obj.strokeWidth || 1) * scale}px solid ${obj.stroke}`
|
||||
border: hasStroke && obj.stroke
|
||||
? `${actualStrokeWidth * scale}px solid ${obj.stroke}`
|
||||
: 'none',
|
||||
opacity: obj.opacity ?? 1,
|
||||
transform: obj.rotation ? `rotate(${obj.rotation}deg)` : undefined,
|
||||
@@ -261,7 +263,7 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
|
||||
const bottomLeftX = halfSize - halfWidth;
|
||||
const bottomRightX = halfSize + halfWidth;
|
||||
|
||||
const strokeWidth = obj.stroke ? (obj.strokeWidth || 1) * scale : 0;
|
||||
const strokeWidth = hasStroke && obj.stroke ? actualStrokeWidth * scale : 0;
|
||||
const fillColor = obj.fill || '#000000';
|
||||
const strokeColor = obj.stroke || 'transparent';
|
||||
|
||||
@@ -330,8 +332,9 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
|
||||
width: `${(obj.width || 100) * scale}px`,
|
||||
height: `${(obj.height || 100) * scale}px`,
|
||||
backgroundColor: obj.fill || 'transparent',
|
||||
border: obj.stroke
|
||||
? `${(obj.strokeWidth || 1) * scale}px solid ${obj.stroke}`
|
||||
borderRadius: `${Math.max(0, (obj.borderRadius || 0) * scale)}px`,
|
||||
border: hasStroke && obj.stroke
|
||||
? `${actualStrokeWidth * scale}px solid ${obj.stroke}`
|
||||
: 'none',
|
||||
zIndex: index, // برای حفظ ترتیب رندر
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@ type ViewerDataPage = {
|
||||
stroke?: string;
|
||||
strokeWidth?: number;
|
||||
shapeType?: string;
|
||||
borderRadius?: number;
|
||||
imageUrl?: string;
|
||||
videoUrl?: string;
|
||||
linkUrl?: string;
|
||||
@@ -93,6 +94,9 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
|
||||
if (obj.type === "rectangle" && obj.shapeType) {
|
||||
baseObject.shapeType = obj.shapeType as EditorObject["shapeType"];
|
||||
}
|
||||
if (obj.type === "rectangle" && obj.borderRadius !== undefined) {
|
||||
baseObject.borderRadius = obj.borderRadius;
|
||||
}
|
||||
|
||||
if (obj.type === "image" && obj.imageUrl) {
|
||||
baseObject.imageUrl = obj.imageUrl;
|
||||
|
||||
Reference in New Issue
Block a user