---
title: "vec2(): typeshade/core/ir의 IR 빌더 함수, TypeShade 컴파일러 API"
description: "vec2, typeshade/core/ir의 IR 빌더 함수입니다. WGSL 방식의 vec2<f32> 생성자이다: vec2(x, y)."
url: https://typeshade.dev/ko/api/vec2/
language: ko
---

# `vec2()`

함수, 내장 함수 분류

WGSL 방식의 `vec2<f32>` 생성자이다: `vec2`(x, y).

`import { vec2 } from 'typeshade/core/ir'`

이 export는 IR 노드를 반환합니다. `"use typeshade"` 파일에서는 내장 함수 자체를 부릅니다: [`vec2()`](https://typeshade.dev/ko/reference/functions/vec2/)

설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.

## 구문

```ts
const vec2: (...a: NodeLike[]) => Node<"vec2<f32>">
```

## 매개변수

**`...a` `NodeLike[]`**

## 반환값

`Node<'vec2<f32>'>`

## 설명

일반 숫자 성분은 `f32`로 승격됩니다. 그래서 `vec2(pos.x, 0)`은 `f32()` 래퍼 없이 `f32` 0을 생성합니다.

[`construct`](https://typeshade.dev/ko/api/construct/)는 이 함수와 그 밖의 모든 벡터 및 구조체 생성자가 기반으로 삼는, 타입 없는 기본 함수입니다.

## 예제

### 예제

```ts
import { vec2 } from 'typeshade/core/ir'

const uv = vec2(0, 1)  // Node<'vec2<f32>'>
```

## 관련 가이드

- [첫 셰이더](https://typeshade.dev/ko/guide/internals/your-first-shader/)
- [값과 변경](https://typeshade.dev/ko/guide/internals/values-and-mutation/)
- [레이아웃과 리소스](https://typeshade.dev/ko/guide/internals/layouts-and-resources/)
- [CPU 오라클 안내서](https://typeshade.dev/ko/guide/internals/the-cpu-oracle/)
- [fp64](https://typeshade.dev/ko/guide/internals/fp64/)
- [배포용 생성](https://typeshade.dev/ko/guide/internals/production-emit/)
- [GLSL 셰이더 옮기기](https://typeshade.dev/ko/guide/internals/migrating-a-glsl-shader/)

## 함께 보기

- [`vec2()`](https://typeshade.dev/ko/reference/functions/vec2/)
- [`construct`](https://typeshade.dev/ko/api/construct/)

## 소스

[`src/core/ir/node.ts`, 2216행](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L2216), 커밋 af54ddad5 기준
