This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function getControlPointCoords(points, edge) { | |
| const affectedPoints = edge.points.map((i) => points[i]); | |
| const otherAxis = edge.axis === 'y' ? 'x' : 'y'; | |
| return { | |
| [otherAxis]: affectedPoints[0][otherAxis] + (affectedPoints[1][otherAxis] - affectedPoints[0][otherAxis]) / 2, | |
| [edge.axis]: affectedPoints[0][edge.axis], | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function getControlPointAxis(point1, point2) { | |
| if (point1.y === point2.y && point1.x !== point2.x) { | |
| return "y"; | |
| } | |
| return "x"; | |
| } | |
| function calculateExtrudableEdges(points) { | |
| const endPoints = [points.length - 2, points.length - 1]; | |
| return [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState } from "react"; | |
| import { render } from "react-dom"; | |
| import { Stage, Layer, Rect, Text, Line } from "react-konva"; | |
| import { INITIAL_STATE, SIZE } from "./config"; | |
| import { Border } from "./Border"; | |
| function createConnectionPoints(source, destination) { | |
| return [source.x, source.y, destination.x, destination.y]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState } from "react"; | |
| import { render } from "react-dom"; | |
| import { Stage, Layer, Rect, Text, Line } from "react-konva"; | |
| import { INITIAL_STATE, SIZE } from "./config"; | |
| import { Border } from "./Border"; | |
| function createConnectionPoints(source, destination) { | |
| return [source.x, source.y, destination.x, destination.y]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { Line, Circle } from "react-konva"; | |
| const SIZE = 50 | |
| const points = [0, 0, SIZE, 0, SIZE, SIZE, 0, SIZE, 0, 0]; | |
| function getAnchorPoints(x, y) { | |
| const halfSize = SIZE / 2; | |
| return [ | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { Stage, Layer, Rect, Text, Line } from "react-konva"; | |
| const SIZE = 50; | |
| const points = [0, 0, SIZE, 0, SIZE, SIZE, 0, SIZE, 0, 0]; | |
| function Border({ step, id }) { | |
| const { x, y } = step; | |
| return ( | |
| <Line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "to": "object-1", | |
| "from": "object-2", | |
| "offsets": { | |
| "to": { | |
| "x": -15, | |
| "y": 305 | |
| }, | |
| "from": { | |
| "x": 170, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function addItem(e) { | |
| e.preventDefault(); | |
| const stage = stageRef.current; | |
| setItems([ | |
| ...items, | |
| { | |
| x: stage.width() / 2, | |
| y: stage.height() / 2, | |
| type: 'circle' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, useRef } from "react"; | |
| import { Stage, Layer, Circle, Rect } from "react-konva"; | |
| function getItem(item) { | |
| if (item.type === "circle") { | |
| return <Circle x={item.x} y={item.y} fill="red" radius={20} />; | |
| } | |
| return <Rect x={item.x} y={item.y} fill="green" width={20} height={20} />; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .card.hide { | |
| opacity: 0; | |
| } |