Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Mon Jan 09, 2023 10:15 pm Post subject: |
|
|
[quote="Dark Byte"]i guess you could load an image with a gradient picture and then modify it's shape property with a shape bitmap or polygons /quote]
Yes DB, that is the easiest way
EDIT : I tried but no success (don't know where is the mistake)
Code: | function RGB(red, green, blue)
if( ( red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255 ) ) then
return nil
end
return string.format("0x%.2X%.2X%.2X%", red, green, blue)
end
min = math.min
max = math.max
abs = math.abs
local function HSV2RGB (h, s, v)
local k1 = v*(1-s)
local k2 = v - k1
local r = min (max (3*abs (((h )/180)%2-1)-1, 0), 1)
local g = min (max (3*abs (((h -120)/180)%2-1)-1, 0), 1)
local b = min (max (3*abs (((h +120)/180)%2-1)-1, 0), 1)
return k1 + k2 * r, k1 + k2 * g, k1 + k2 * b
end
function Gradient(Object, R1, G1, B1, R2, G2, B2, Direction)
B = 0
G = 0
R = 0
BI = 0
GI = 0
RI = 0
Hypotenuse = 0
Calc = 0
Radius = 0
Y = 0
X = 0
Z = 0
A = 0
R = R1
G = G1
B = B1
col = 0
if Direction == 0 then goto Horizontal end
if Direction == 1 then goto Vertical end
if Direction == 2 then goto Sphere end
if Direction == 3 then goto Angle end
Object.Canvas.Clear()
col = HSV2RGB(R, G, B)
::Horizontal::
RI = (R2 - R1) / Object.Height
GI = (G2 - G1) / Object.Height
BI = (B2 - B1) / Object.Height
repeat
col = RGB(R, G, B)
Object.Canvas.Pen.Color = col
Object.Canvas.Line(0, Y, Object.Width, Y)
Y = Y + 1
R = R + RI
G = G + GI
B = B + BI
until(Y >= Object.Height)
::Vertical::
RI = (R2 - R1) / Object.Width
GI = (G2 - G1) / Object.Width
BI = (B2 - B1) / Object.Width
repeat
col = RGB(R, G, B)
Object.Canvas.Pen.Color = col
Object.Line (Y, 0, Y, Object.Height)
Y = Y + 1
R = R + RI
G = G + GI
B = B + BI
until(Y >= Object.Width)
::Sphere::
RI = (R2 - R1) / Object.Width
GI = (G2 - G1) / Object.Width
BI = (B2 - B1) / Object.Width
Radius = 1
Xpos = Object.Width / 2
Ypos = Object.Height / 2
repeat
Object.Canvas.Pen.Color = HSV2RGB(R, G, B)
Object.Canvas.Ellipse(Xpos, Ypos, Radius, 0)
Object.Canvas.Pen.Color = HSV2RGB(R + 1, G + 1, B + 1)
Object.Canvas.Ellipse(Xpos, Ypos, Radius + 1, 0)
Object.Canvas.Pen.Color = HSV2RGB(R + 1, G + 1, B + 1)
Object.Canvas.Ellipse(Xpos, Ypos, Radius + 2, 0)
Radius = Radius + 3
R = R + (RI * 3)
G = G + (GI * 3)
B = B + (BI * 3)
until(Radius >= Object.Width)
::Angle::
Calc = (Object.Width ^ 2 + Object.Height ^ 2)
Hypotenuse = math.sqrt(Calc) + ((Object.Height / 100) * 12)
RI = (R2 - R1) / Hypotenuse
GI = (G2 - G1) / Hypotenuse
BI = (B2 - B1) / Hypotenuse
repeat
col = RGB(R, G, B)
Object.Canvas.Pen.Color = col
Object.Canvas.Line(X, Z, A, Y)
R = R + (RI)
G = G + (GI)
B = B + (BI)
Y = Y + 1
X = X + 1
if X >= Object.Width then Z = Z + 1 end
if Y >= Object.Height then A = A + 1 end
until(Z >= Object.Height and A >= Object.Width)
end
if f then f.destroy() end
f = createForm()
f.OnPaint = Gradient(f, 30, 30, 30, 100, 100, 100, 2)
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|