선

Line

두 점을 잇는 선을 그리고 굵기와 실선·점선·파선 스타일을 조절합니다.

다른 이름: LineStraight lineLine segment

WebGPU 를 지원하는 브라우저에서 움직입니다

이 기기에서는 데모를 그리지 못해 정지 화면을 보여 줍니다

React
// WebGPU 를 지원하는 브라우저에서만 그립니다.
import { Shader, Line } from 'shaders/react'

export default function ShaderEffect() {
  return (
    <Shader style={{ width: '100%', height: 320 }} disableTelemetry>
      <Line />
    </Shader>
  )
}
Vue
<!-- WebGPU 를 지원하는 브라우저에서만 그립니다. -->
<script setup lang="ts">
import { Shader, Line } from 'shaders/vue'
</script>

<template>
  <Shader style="width: 100%; height: 320px" :disable-telemetry="true">
    <Line/>
  </Shader>
</template>
Svelte
<!-- WebGPU 를 지원하는 브라우저에서만 그립니다. -->
<script>
  import { Shader, Line } from 'shaders/svelte'
</script>

<Shader style="width: 100%; height: 320px" disableTelemetry>
  <Line />
</Shader>
Solid
// WebGPU 를 지원하는 브라우저에서만 그립니다.
import { Shader, Line } from 'shaders/solid'

export default function ShaderEffect() {
  return (
    <Shader style={{ width: '100%', height: '320px' }} disableTelemetry>
      <Line />
    </Shader>
  )
}
JavaScript
// WebGPU 를 지원하는 브라우저에서만 그립니다.
// <canvas id="canvas" style="width:100%;height:320px"></canvas> 가 페이지에 있어야 한다
import { createShader } from 'shaders/js'

const shader = await createShader(document.getElementById("canvas"), {
  components: [
    {
      type: 'Line',
    }
  ]
}, { disableTelemetry: true })

속성(props) · Line

값을 바꾸면 위 데모와 코드 탭에 바로 반영됩니다. 설명은 라이브러리 레지스트리의 영어 원문(MIT)입니다.

이름값기본값범위·선택지설명(원문)
colorColor#ffffff—The color of the line
pointAPoint A
x0.2y0.5
{"x":0.2,"y":0.5}x, y: 0 – 1The start point of the line
pointBPoint B
x0.8y0.5
{"x":0.8,"y":0.5}x, y: 0 – 1The end point of the line
thicknessThickness0.010 – 0.25 (step 0.001)The thickness of the line. A value of one (1) matches the canvas height.
styleStylesolidsolid · dashed · dottedThe line style: solid, dashed, or dotted. Dashes and dots are spaced to land exactly on both endpoints.
dashLengthDash Length0.050 – 0.5 (step 0.001)The length of each dash, including its caps
gapLengthGap Length0.0250 – 0.5 (step 0.001)The gap between dashes, or the spacing between dots
capStartStart Caproundedsquare · roundedCap shape at the start of the line (point A). Rounded caps center on the endpoint; square caps end flat exactly at it. Also shapes the A-facing end of each dash and dot.
capEndEnd Caproundedsquare · roundedCap shape at the end of the line (point B). Rounded caps center on the endpoint; square caps end flat exactly at it. Also shapes the B-facing end of each dash and dot.

모든 컴포넌트 공통: blendMode · opacity · visible · maskSource/maskType · boundingBox · id

선은 시작점과 끝점을 직접 정하는 직선입니다. 구분선이나 연결선, 도식의 경로처럼 두 위치 사이의 관계를 간단하게 보여 줍니다.

`pointA`와 `pointB`가 시작점과 끝점을 정합니다. `thickness`는 0–0.25 범위의 굵기이고, `style`은 `solid`, `dashed`, `dotted` 중에서 고릅니다. 파선 간격은 `gapLength`로 0–0.5 범위에서 조절합니다.

점선이나 파선은 양 끝점에 맞춰 배치되므로 간격을 바꿔도 끝에 어색한 반쪽 조각이 남지 않도록 설계되어 있습니다. `Circle`이나 `Polygon`과 조합해 도식에 연결선을 넣되, 선이 겹치는 부분이 도형의 외곽을 가리지 않는지 확인하세요.

언제 쓰나

도식의 연결선·구분선·진행 경로에 좋습니다. 실선·파선·점선으로 연결 관계의 종류를 구분할 수 있습니다. 곡선이나 두께가 변하는 브러시 획이 필요하면 피하세요.

페이지로 열기 ↗