# Truncate a value to an integer

Hello:

I have an array with 10 patterns. I would like to use the slider function to manually shift to any of the 10 patterns. Multiplying the slider value by 10 gives me the integer portion for the arrayMode. How do I truncate everything to the right of the decimal point?

export var arrayMode = 0
export function sliderMyArraySlider(v) {
arrayMode = v * 10
}

modes = array(10)
modes = (f) => f % 1
modes = (f) => triangle(f)
modes = (f) => wave(f)
modes = (f) => square(f, .5)
modes = (f) => triangle(triangle(f))
modes = (f) => wave(triangle(f))
modes = (f) => triangle(wave(f))
modes = (f) => wave(wave(f))
modes = (f) => square(wave(triangle(f)), .7)
modes = (f) => wave(f) * triangle(f*1.3)

export function render(index) {

v = modes[arrayMode % 9](4 * index / pixelCount)
hsv(0, 0, v)
}

I’m not sure you actually need to truncate an index, but I’ve used the following for similar reasons

export function sliderOnRate(v) {rateval = floor(v*5)}

2 Likes

Thank you for the information.

1 Like