Skip to content

Commit

Permalink
svg-new-center7
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinatzo committed Sep 3, 2024
1 parent f6a9d76 commit d480433
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions packages/abstract-3d/src/renderers/svg/svg-encoding.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Vec2, vec2Add, vec2Scale } from "../../abstract-3d";

export const svg = (width: number, height: number, center: Vec2, children: string): string =>
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${(-(-center.x + width / 2)).toFixed()} ${(-(
center.y +
height / 2
)).toFixed(0)} ${width.toFixed(0)} ${height.toFixed(0)}" width="${width.toFixed(0)}px" height="${height.toFixed(
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${(center.x * 2 - width / 2).toFixed()} ${(
-center.y * 2 +
-height / 2
).toFixed(0)} ${width.toFixed(0)} ${height.toFixed(0)}" width="${width.toFixed(0)}px" height="${height.toFixed(
0
)}px">${children} </svg>`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export function Abstract3DExample(): React.ReactNode {
</button>
</div>
<div
dangerouslySetInnerHTML={{ __html: A3D.toSvg(scene, "front", 2, { size: 300, scaleByWidth: true }).image }}
dangerouslySetInnerHTML={{
__html: A3D.toSvg(scene, "front", 3, { size: 300, scaleByWidth: true }, true, false).image,
}}
/>
{/* <div style={{ height: "calc(100% - 20px)" }}>
<A3D.toReact scene={scene} />
Expand All @@ -35,7 +37,7 @@ export function Abstract3DExample(): React.ReactNode {
);
}

const scene: A3D.Scene = {
const scene2: A3D.Scene = {
center_deprecated: A3D.vec3(100, 100, 100),
size_deprecated: A3D.vec3(300, 300, 300),
groups: [
Expand Down Expand Up @@ -95,7 +97,7 @@ const scene3: A3D.Scene = {
],
};

const scene2 = {
const scene = {
center_deprecated: {
x: 50,
y: 425.00000000000006,
Expand Down

0 comments on commit d480433

Please sign in to comment.