# Multisegment pattern

**URL:** <https://forum.electromage.com/t/multisegment-pattern/1103>\
**Category:** Patterns and Code\
**Created:** [March 24, 2021, 8:21pm UTC](https://forum.electromage.com/t/multisegment-pattern/1103 "2021-03-24T20:21:38Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Petros](https://forum.electromage.com/letter_avatar_proxy/v4/letter/p/f05b48/32.png) [@Petros](https://forum.electromage.com/u/Petros)\
**Post date:** [March 26, 2021, 4:29pm UTC](https://forum.electromage.com/t/multisegment-pattern/1103/7 "2021-03-26T16:29:54Z")

</div>

Here’s where I am at:

I discovered the “else if” statement, now I’m able to divide in as many segments as I want, and have gui access to them individually. It’s not a pretty way, as the hue pickers will be in the gui regardless of the segments I want active(I wonder, is it possible to use “if” statements to have the pickers appear depending on active segments?). I applied this method at zranger1’s Oasis pattern, and I’m able to divide it in 2 segments with different colours each, nice:)

The math is still wrong, I could use some help with that, please have a look at the code:

// Colour Picker 1  
export function hsvPickerHue1(h, s, v) {  
hue1 = h  
saturation1 = s  
value1 = v  
}

//Colour Picker 2  
export function hsvPickerHue2(h, s, v) {  
hue2 = h  
saturation2 = s  
value2 = v  
}

//Colour Picker 3  
export function hsvPickerHue3(h, s, v) {  
hue3 = h  
saturation3 = s  
value3 = v  
}

export var depth1  
export function sliderDepth1(v) {  
depth1 = floor(v \* 100 );  
}

export var depth2  
export function sliderDepth2(v) {  
depth2 = floor(v \* 100 );  
}

export function render(index) {  
if (index \< depth1 % pixelCount) {  
hue = hue1  
saturation = saturation1  
value = value1  
hsv(hue1, saturation1, value1)  
}  
else if (index \< (depth1 % pixelCount) + depth2) {  
hue = hue2  
saturation = saturation2  
value = value2  
hsv(hue2, saturation2, value2)

} else {  
hue = hue3  
saturation = saturation3  
value = value3  
hsv(hue3, saturation3, value3)  
}

}

I still don’t get how to properly paste code in here, sorry:)

---

_[View the full topic](https://forum.electromage.com/t/multisegment-pattern/1103)._
