mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-10 05:35:05 +08:00
Bug: chromium:1011811 Change-Id: Ie18a64b6cdf84e3d53e594cd88f7c4431d9c78f6 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2450294 Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org> Commit-Queue: Paul Lewis <aerotwist@chromium.org>
44 lines
1.5 KiB
JavaScript
44 lines
1.5 KiB
JavaScript
// Copyright 2019 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import {AudioParamRadius, InputPortRadius, LeftSideTopPadding, Point, Size, TotalInputPortHeight, TotalOutputPortHeight, TotalParamPortHeight} from './GraphStyle.js'; // eslint-disable-line no-unused-vars
|
|
|
|
/**
|
|
* Calculate the x, y value of input port.
|
|
* Input ports are placed near the top of the left-side border.
|
|
* @param {number} portIndex
|
|
* @return {!Point}
|
|
*/
|
|
export const calculateInputPortXY = portIndex => {
|
|
const y = InputPortRadius + LeftSideTopPadding + portIndex * TotalInputPortHeight;
|
|
return {x: 0, y: y};
|
|
};
|
|
|
|
/**
|
|
* Calculate the x, y value of output port.
|
|
* Output ports are placed near the center of the right-side border.
|
|
* @param {number} portIndex
|
|
* @param {!Size} nodeSize
|
|
* @param {number} numberOfOutputs
|
|
* @return {!Point}
|
|
*/
|
|
export const calculateOutputPortXY = (portIndex, nodeSize, numberOfOutputs) => {
|
|
const {width, height} = nodeSize;
|
|
const outputPortY = (height / 2) + (2 * portIndex - numberOfOutputs + 1) * TotalOutputPortHeight / 2;
|
|
|
|
return {x: width, y: outputPortY};
|
|
};
|
|
|
|
/**
|
|
* Calculate the x, y value of param port.
|
|
* Param ports are placed near the bottom of the left-side border.
|
|
* @param {number} portIndex
|
|
* @param {number} offsetY
|
|
* @return {!Point}
|
|
*/
|
|
export const calculateParamPortXY = (portIndex, offsetY) => {
|
|
const paramPortY = offsetY + TotalParamPortHeight * (portIndex + 1) - AudioParamRadius;
|
|
return {x: 0, y: paramPortY};
|
|
};
|