Page 1 of 1

### [Solved] Color Gradient maker Posted: Mon Jul 30, 2018 4:12 pm
Hello,

I try to create a gradient between 2 RGB colors.
This is my code:
Code: Select all   Expand viewCollapse view
`Sub GradientMe    nBeg = RGB(255, 51, 51) 'red    nEnd = RGB(102, 102, 255) 'blue    nSteps = 25    r1 = Red(nBeg) : g1 = Green(nBeg) : b1 = Blue(nBeg)    r2 = Red(nEnd) : g2 = Green(nEnd) : b2 = Blue(nEnd)    if ( nBeg < nEnd ) then        dr = Int((r2-r1) / nSteps)        dg = Int((g2-g1) / nSteps)        db = Int((b2-b1) / nSteps)    else        dr = Int((r1-r2) / nSteps)        dg = Int((g1-g2) / nSteps)        db = Int((b1-b2) / nSteps)    endif    oSheet = ThisComponent.CurrentController.ActiveSheet    For i = 0 to nSteps -1        oCell = oSheet.getCellByPosition(0,i)        oCell.setPropertyValue("CellBackColor", nBeg)        if ( nBeg > nEnd ) then            r1 = r1 - dr : g1 = g1 - dg : b1 = b1 - db        else            r1 = r1 + dr : g1 = g1 + dg : b1 = b1 + db        endif        nBeg = RGB(r1, g1, b1)    Next iEnd sub`

But in last cells, color is wrong.

### Re: Color Gradient maker Posted: Mon Jul 30, 2018 8:57 pm
change / to \

Code: Select all   Expand viewCollapse view
` dr = Int((r2-r1) \ nSteps)        dg = Int((g2-g1) \ nSteps)        db = Int((b2-b1) \ nSteps)    else        dr = Int((r1-r2) \ nSteps)        dg = Int((g1-g2) \ nSteps)        db = Int((b1-b2) \ nSteps)`

### Re: Color Gradient maker Posted: Thu Aug 02, 2018 2:41 pm JeJe

But, could you explain what is this weird operator?
I don't find in help file and dev guide.

### Re: [Solved] Color Gradient maker Posted: Thu Aug 02, 2018 5:47 pm
\ is division giving a whole number.

https://wiki.openoffice.org/wiki/Docume ... /Operators