gpt4 book ai didi

haskell - 修复箭头轴(图表库)

转载 作者:行者123 更新时间:2023-12-04 12:39:04 24 4
gpt4 key购买 nike

我做了一个数据存储使用 B.difference 的符号和 B.union .中间有红点的那个。

dataStorage :: Diagram B
dataStorage = (strokePath $ B.difference Winding combined block1) # translateX (-0.3)
where block1 = (circle 0.5) # scaleX 0.5 # translateX (-1)
block2 = rect 2 1
block3 = (circle 0.5) # translateX (1)
combined = B.union Winding $ block2 <> block3

enter image description here

我已经尝试了几个小时,但无法在 Previous Estimate 之间做出直线箭头写在那个符号里面和 Signal Decomposition (SSA) .目标是从符号右侧的中心开始绘制箭头。欢迎任何帮助。非常感谢。

编辑 1:添加了想要的结果。

enter image description here

这是完整的代码。
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}

module FlowChartTR where

import System.Process
--import Graphics.SVGFonts
import Diagrams.Backend.SVG.CmdLine
import Diagrams.Prelude
import Diagrams.TwoD.Arrow
import qualified Diagrams.TwoD.Path.Boolean as B

oneLineText txt = text txt
twoLineText txt1 txt2 = center $ (text txt1) === strutY 0.2 === (text txt2)
threeLineText txt1 txt2 txt3 = center $
(text txt1) === strutY 0.2 === (text txt2) === strutY 0.2 === (text txt3)

terminal writeText w h r = (writeText <> roundedRect w h r) # lwL 0.02 # fontSize (local 0.2)
--terminalInput = (text "Input Data" <> roundedRect 1 0.3 0.3) # lwL 0.02 # fontSize (local 0.2)


--process txt w h = (text txt <> rect w h) # lwL 0.02 # fontSize (local 0.2)
process writeText w h = (writeText <> rect w h) # lwL 0.02 # fontSize (local 0.2)

dataStorage :: Diagram B
dataStorage = (strokePath $ B.difference Winding combined block1) # translateX (-0.3)
where block1 = (circle 0.5) # scaleX 0.5 # translateX (-1)
block2 = rect 2 1
block3 = (circle 0.5) # translateX (1)
combined = B.union Winding $ block2 <> block3

--decision :: Diagram B
--decision = (text "BPM" <> rect 0.4 0.3) # lwL 0.02 # fontSize (local 0.2)

input = (terminal (oneLineText "Input Data") 1.2 0.3 0.3) # named "terminalInput"
bandpass = (process (twoLineText "Bandpass" "Filtering") 1.5 0.5) # named "bandpass"
ssa = (process (threeLineText "Signal" "Decomposition" "(SSA)") 1.5 1) # translateY (-0.3) # named "ssa" # showOrigin
td = (process (twoLineText "Temporal" "Difference") 1 0.5) # named "td"
focuss = (process (threeLineText "Sparse Signal" "Reconstruction" "(FOCUSS)") 1.5 0.8) # named "focuss"
outputBPM = (terminal (oneLineText "Output BPM") 1.2 0.3 0.3) # named "terminalOutput"
spt = (process (threeLineText "Spectral Peak" "Tracking" "Select & Verif") 1.5 0.8) # named "spt"
prior = (oneLineText "Previous Estimate" <> dataStorage) # fontSize (local 0.2) # named "prior" #showOrigin # translateY 1

arrowStyle = (with & arrowHead .~ dart & headLength .~ large & tailLength .~ veryLarge)
ushaft = trailFromVertices (map p2 [(0, 0), (0.5, 0), (0.5, 1), (1, 1)])
arrowStyleU = (with & arrowHead .~ dart & headLength .~ large & tailLength .~ veryLarge & arrowShaft .~ ushaft)


decision :: Diagram B
decision = square 5 # rotate (45 @@ deg) # scaleY 0.5

placeBlocks :: Diagram B
placeBlocks = atPoints [ P (V2 0 0), -- input
P (V2 4 0), -- bandpass
P (V2 8 0), -- ssa
P (V2 8 (-2)), -- td
P (V2 8 (-4)), -- focuss
P (V2 4 (-4)), -- spt
P (V2 0 (-4)), -- outputBPM
P (V2 4 (-2)) -- prior
] [input, bandpass,ssa, td, focuss, spt, outputBPM, prior]

flowChart :: Diagram B
flowChart = placeBlocks # connectOutside' arrowStyle "terminalInput" "bandpass"
# connectOutside' arrowStyle "bandpass" "ssa"
# connectOutside' arrowStyle "ssa" "td"
# connectOutside' arrowStyle "td" "focuss"
# connectOutside' arrowStyle "focuss" "spt"
# connectOutside' arrowStyle "spt" "terminalOutput"
# connectOutside' arrowStyle "prior" "spt"
# connectOutside' arrowStyleU "prior" "ssa"
# pad 1.1

flowChartTR :: IO ()
flowChartTR = mainWith flowChart

最佳答案

我知道了。缩小符号后,调整连接变得更容易。

enter image description here

这是变化。

...
[input, bandpass,ssa, td, focuss, spt, outputBPM, (prior # scale 0.7)]
...
# connectPerim' arrowStyleU "prior" "ssa" (0 @@ deg) (205 @@ deg)
...

注意:
- 添加 arrowTail .~ lineTail很关键。

关于haskell - 修复箭头轴(图表库),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52385447/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com