Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Gradient Brush / Shapes

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon Jan 09, 2023 8:13 pm    Post subject: Gradient Brush / Shapes Reply with quote

Can CE graphics make shapes / draw shapes with gradient colour?
Since CE doesn't have gradient brush and gradientFill works only on components which have canvas.

e.q : How draw a circle with gradient fill colour? And DB, can you bring TBGRABitmap components to next CE update? Very Happy

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Mon Jan 09, 2023 9:59 pm    Post subject: Reply with quote

i guess you could load an image with a gradient picture and then modify it's shape property with a shape bitmap or polygons

argb components are messy so not sure

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon Jan 09, 2023 10:15 pm    Post subject: Reply with quote

[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 Very Happy

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)


Very Happy Very Happy Very Happy

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites