---
title: "vec2(): IR builder function in typeshade/core/ir, TypeShade"
description: "vec2, an IR builder function in typeshade/core/ir. A vec2<f32> constructor, WGSL-style: vec2(x, y)."
url: https://typeshade.dev/api/vec2/
language: en
---

# `vec2()`

Function in Builtins

A `vec2<f32>` constructor, WGSL-style: `vec2`(x, y).

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

This export returns an IR node. A `"use typeshade"` file calls the builtin itself: [`vec2()`](https://typeshade.dev/reference/functions/vec2/)

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

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

## Parameters

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

## Return value

`Node<'vec2<f32>'>`

## Description

A bare number component lifts to `f32`, so `vec2(pos.x, 0)` emits an `f32` zero with no `f32()` wrapper. [`construct`](https://typeshade.dev/api/construct/) is the untyped primitive this and every other vector and struct constructor is built on.

## Examples

### Example

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

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

## In the guide

- [Your first shader](https://typeshade.dev/guide/internals/your-first-shader/)
- [Values and mutation](https://typeshade.dev/guide/internals/values-and-mutation/)
- [Layouts and resources](https://typeshade.dev/guide/internals/layouts-and-resources/)
- [The CPU oracle](https://typeshade.dev/guide/internals/the-cpu-oracle/)
- [fp64](https://typeshade.dev/guide/internals/fp64/)
- [Production emit](https://typeshade.dev/guide/internals/production-emit/)
- [Migrating a GLSL shader](https://typeshade.dev/guide/internals/migrating-a-glsl-shader/)

## See also

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

## Source

[`src/core/ir/node.ts`, line 2216](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L2216), at commit af54ddad5
