---
tags:
    - "Map"
    - "Random"
---

# Perlin Noise 2D

[Math](../index.md) / [Arithmetic](index.md) / **Perlin Noise 2D**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

Returns the result of feeding a Vector2 into a Perlin Noise function

## Code

```cs
using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]
    
    [Title("Perlin Noise 2D")]
    [Category("Math/Arithmetic/Perlin Noise 2D")]
    
    [Description("Returns the result of feeding a Vector2 into a Perlin Noise function")]
    [Image(typeof(IconNoise), ColorTheme.Type.Yellow, typeof(Badge2D))]
    
    [Keywords("Map", "Random")]
    
    [Serializable]
    public class TypeNumberMathPerlinNoise2D : TypeNumber
    {
        [SerializeField] private GetVector2 m_Vector = new GetVector2();

        public override double GetPreview(GameObject source) =>
            Mathf.PerlinNoise(
                this.m_Vector.GetPreview(source).x,
                this.m_Vector.GetPreview(source).y
            );

        public override double Get(Args args)
        {
            Vector2 vector = this.m_Vector.Get(args); 
            return Mathf.PerlinNoise(vector.x, vector.y);
        }

        public override string ToString()
        {
            return $"Perlin Noise with {this.m_Vector}";
        }
        
        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
```

