Jump to content

randomColor


Recommended Posts

Posted

السلام عليكم وحمه الله وبركاته
سئ انا في المقدمات فبدون مقدمات
الكود عباره عن 5 ارقام عشوائيه
خلنا اول في السورس كود

function randomColor ( speed )
	function iColor ( )
		iC1, iC2, iC3, iC4, iC5, iC = iC1 or 255, iC2 or 255, iC3 or 255, iC4 or 255, iC5 or 255, math.random ( 1, 10 )
	end
	iC1, iC2, iC3, iC4, iC5, iC = iC1 or 255, iC2 or 255, iC3 or 255, iC4 or 255, iC5 or 255, iC or math.random ( 1, 10 )
	if		iC == 1 	then iC1 = iC1 + speed if iC1 >= 255 	then iColor ( ) iC1 = 255 	end
	elseif	iC == 2 	then iC1 = iC1 - speed if iC1 <= 0 		then iColor ( ) iC1 = 0 	end
	elseif	iC == 3 	then iC2 = iC2 + speed if iC2 >= 255 	then iColor ( ) iC2 = 255 	end
	elseif	iC == 4 	then iC2 = iC2 - speed if iC2 <= 0 		then iColor ( ) iC2 = 0 	end
	elseif	iC == 5 	then iC3 = iC3 + speed if iC3 >= 255 	then iColor ( ) iC3 = 255 	end
	elseif	iC == 6 	then iC3 = iC3 - speed if iC3 <= 0 		then iColor ( ) iC3 = 0 	end
	elseif	iC == 7 	then iC4 = iC4 + speed if iC4 >= 255 	then iColor ( ) iC4 = 255 	end
	elseif	iC == 8 	then iC4 = iC4 - speed if iC4 <= 0 		then iColor ( ) iC4 = 0 	end
	elseif	iC == 9		then iC5 = iC5 + speed if iC5 >= 255 	then iColor ( ) iC5 = 255 	end
	elseif	iC == 10	then iC5 = iC5 - speed if iC5 <= 0 		then iColor ( ) iC5 = 0 end	end
	return iC1, iC2, iC3, iC4, iC5
end

التركيبه

rc1, rc2, rc3, rc4, rc5 = randomColor ( speed ) -- تحتاج رندر او مؤقت

rc1, rc2, rc3, rc4, rc5 -- ارقام عشوائيه

speed -- سرعه تحرك اللون من لون لأخر

--[[
مثلاً سرعه 1
رح ينقص اللون 1
سرعه 2 رح ينقص اللون 2 مضروبه في الرندر او المؤقت
--]]

مثال

function render ()
	rc1, rc2, rc3, rc4, rc5 = randomColor ( 5 )
	outputChatBox ( "killerProject", rc2, rc5, rc3 )
	setWaterColor ( rc3, rc4, rc1 )
	dxDrawText("killerProject", 70, 550, 220, 575, tocolor(rc1,rc3,rc5, 255), 3.00, "default", "center", "center", false, false, false, false, false)
	dxDrawText("killerProject", 70, 450, 220, 575, tocolor(rc2,rc3,rc4, 255), 3.00, "default", "center", "center", false, false, false, false, false)
	dxDrawText("killerProject", 70, 350, 220, 575, tocolor(rc1,rc5,rc2, 255), 3.00, "default", "center", "center", false, false, false, false, false)
	dxDrawText("killerProject", 70, 250, 220, 575, tocolor(rc5,rc3,rc4, 255), 3.00, "default", "center", "center", false, false, false, false, false)
	dxDrawRectangle( 755, 500, 225, 225, tocolor(rc2,rc4,rc3, 200), false)
	if getPedOccupiedVehicle( localPlayer ) then
		setVehicleColor( getPedOccupiedVehicle( localPlayer ),rc1,rc2,rc3,rc4,rc5,rc1,rc2,rc3,rc4,rc5,rc1,rc2 )
	end
end
addEventHandler("onClientRender", root, render )

فيديو توضيحي سريع ذو جوده سيئه بسبب ضعف جهازي

والسلام عليكم ورحمة الله وبركاته ... تجارب تجارب

  • Like 2

 

 


April 25, 2016, THE BEGINNING OF MY JOURNEY ?

Check my apps in playStore


 

Posted

وظيفة منتازة , ويصلح تستعملها في تلوين السيارات ..

جميل جداً لكن ي كيلر بروجكت حاول تحط الفنكشنات ذي في الموضوع التالي :

^ ما اتوقع المشرف 24 ساعة راح ينقل مواضيعك ._.

+
الكود تقدر تختصره وحاول تختصره بنفسك .. عشان تقدر تتطور اكثر : )
 

Experienced MTA developer for 4 years. | MTA خبرة 4 سنين في برمجة

ليس عليك اسعاد الجميع ,
ولكن عليك بإن لا تؤذي أحداً 

=========
You do not have to make everyone happy,
But you should not hurt anyone

 

Want to contact with me?

 

Discord: JustCarry#2616 (Always there)
Skype: Live:JustCarry10 (Not always)

Posted

طريقتك عجيبة

لكن وش رآيك ب حقتي :P

function RGBToHex(red, green, blue, alpha)
  if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then
    return nil
  end
  if(alpha) then
    return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha)
  else
    return string.format("#%.2X%.2X%.2X", red,green,blue)
  end
end
function rainbowString(text)
  local noColors = string.gsub(text, "#%x%x%x%x%x%x", "")
  local endString = {}
  for i=1,string.len(noColors) do
    local r = math.sin(0.3*i)*(math.cos(co.tick/25)*127)+128 
    local g = math.sin(0.3*i+(2*math.pi/3))*(math.sin(co.tick/25)*127)+128
    local b = math.sin(0.3*i+(4*math.pi/3))*(math.cos(co.tick/25)*127)+128
    local h = RGBToHex(r,g,b)
    local s = noColors:sub(i,i)
    endString[i] = h..s
  end
  return table.concat(endString,"")
end

الأكواد مو كاملة ، ادري

@killerProject

  • Like 1

IT Projet Manager

 

Posted
Just now, #,+( _xiRoc[K]; > said:

ما شفتها واتوقع فيه فرق بين الاكواد

1 hour ago, iMr.WiFi..! said:

وظيفة منتازة , ويصلح تستعملها في تلوين السيارات ..

جميل جداً لكن ي كيلر بروجكت حاول تحط الفنكشنات ذي في الموضوع التالي :

^ ما اتوقع المشرف 24 ساعة راح ينقل مواضيعك ._.

+
الكود تقدر تختصره وحاول تختصره بنفسك .. عشان تقدر تتطور اكثر : )
 

اوكي واي فاي ... اسف على هذا الشي

Just now, coNolel said:

طريقتك عجيبة

لكن وش رآيك ب حقتي :P


function RGBToHex(red, green, blue, alpha)
  if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then
    return nil
  end
  if(alpha) then
    return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha)
  else
    return string.format("#%.2X%.2X%.2X", red,green,blue)
  end
end
function rainbowString(text)
  local noColors = string.gsub(text, "#%x%x%x%x%x%x", "")
  local endString = {}
  for i=1,string.len(noColors) do
    local r = math.sin(0.3*i)*(math.cos(co.tick/25)*127)+128 
    local g = math.sin(0.3*i+(2*math.pi/3))*(math.sin(co.tick/25)*127)+128
    local b = math.sin(0.3*i+(4*math.pi/3))*(math.cos(co.tick/25)*127)+128
    local h = RGBToHex(r,g,b)
    local s = noColors:sub(i,i)
    endString[i] = h..s
  end
  return table.concat(endString,"")
end

الأكواد مو كاملة ، ادري

@killerProject

صراحة مب فاهم وش العلاقه بين الكودين :lol:

المهم نورتوا الموضوع يا طيبين :D

 

 


April 25, 2016, THE BEGINNING OF MY JOURNEY ?

Check my apps in playStore


 

Posted
5 hours ago, killerProject said:

والسلام عليكم ورحمة الله وبركاته ... تجارب تجارب

وعليكم السلام ورحمة الله وبركاته شغل كويس لكن كان يفضل تستخدم اللوكال قبل الفنكشن

iColor

عشان ما تصير مشاكل لو واحد سوا فنكشن بنفس الاسم

بحيث يصبح السورس كود  كذا

function randomColor ( speed )
	local function iColor ( )
		iC1, iC2, iC3, iC4, iC5, iC = iC1 or 255, iC2 or 255, iC3 or 255, iC4 or 255, iC5 or 255, math.random ( 1, 10 )
	end
	iC1, iC2, iC3, iC4, iC5, iC = iC1 or 255, iC2 or 255, iC3 or 255, iC4 or 255, iC5 or 255, iC or math.random ( 1, 10 )
	if		iC == 1 	then iC1 = iC1 + speed if iC1 >= 255 	then iColor ( ) iC1 = 255 	end
	elseif	iC == 2 	then iC1 = iC1 - speed if iC1 <= 0 		then iColor ( ) iC1 = 0 	end
	elseif	iC == 3 	then iC2 = iC2 + speed if iC2 >= 255 	then iColor ( ) iC2 = 255 	end
	elseif	iC == 4 	then iC2 = iC2 - speed if iC2 <= 0 		then iColor ( ) iC2 = 0 	end
	elseif	iC == 5 	then iC3 = iC3 + speed if iC3 >= 255 	then iColor ( ) iC3 = 255 	end
	elseif	iC == 6 	then iC3 = iC3 - speed if iC3 <= 0 		then iColor ( ) iC3 = 0 	end
	elseif	iC == 7 	then iC4 = iC4 + speed if iC4 >= 255 	then iColor ( ) iC4 = 255 	end
	elseif	iC == 8 	then iC4 = iC4 - speed if iC4 <= 0 		then iColor ( ) iC4 = 0 	end
	elseif	iC == 9		then iC5 = iC5 + speed if iC5 >= 255 	then iColor ( ) iC5 = 255 	end
	elseif	iC == 10	then iC5 = iC5 - speed if iC5 <= 0 		then iColor ( ) iC5 = 0 end	end
	return iC1, iC2, iC3, iC4, iC5
end

 

  • Like 1

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
Just now, Master_MTA said:

وعليكم السلام ورحمة الله وبركاته شغل كويس لكن كان يفضل تستخدم اللوكال قبل الفنكشن

iColor

عشان ما تصير مشاكل لو واحد سوا فنكشن بنفس الاسم

بحيث يصبح السورس كود  كذا


function randomColor ( speed )
	local function iColor ( )
		iC1, iC2, iC3, iC4, iC5, iC = iC1 or 255, iC2 or 255, iC3 or 255, iC4 or 255, iC5 or 255, math.random ( 1, 10 )
	end
	iC1, iC2, iC3, iC4, iC5, iC = iC1 or 255, iC2 or 255, iC3 or 255, iC4 or 255, iC5 or 255, iC or math.random ( 1, 10 )
	if		iC == 1 	then iC1 = iC1 + speed if iC1 >= 255 	then iColor ( ) iC1 = 255 	end
	elseif	iC == 2 	then iC1 = iC1 - speed if iC1 <= 0 		then iColor ( ) iC1 = 0 	end
	elseif	iC == 3 	then iC2 = iC2 + speed if iC2 >= 255 	then iColor ( ) iC2 = 255 	end
	elseif	iC == 4 	then iC2 = iC2 - speed if iC2 <= 0 		then iColor ( ) iC2 = 0 	end
	elseif	iC == 5 	then iC3 = iC3 + speed if iC3 >= 255 	then iColor ( ) iC3 = 255 	end
	elseif	iC == 6 	then iC3 = iC3 - speed if iC3 <= 0 		then iColor ( ) iC3 = 0 	end
	elseif	iC == 7 	then iC4 = iC4 + speed if iC4 >= 255 	then iColor ( ) iC4 = 255 	end
	elseif	iC == 8 	then iC4 = iC4 - speed if iC4 <= 0 		then iColor ( ) iC4 = 0 	end
	elseif	iC == 9		then iC5 = iC5 + speed if iC5 >= 255 	then iColor ( ) iC5 = 255 	end
	elseif	iC == 10	then iC5 = iC5 - speed if iC5 <= 0 		then iColor ( ) iC5 = 0 end	end
	return iC1, iC2, iC3, iC4, iC5
end

 

لاحظت هذا التنبيه في الـويكي لكن صراحه تجاهلته لأن اعتقد اذا شخص سوا نفس الفنكشن خارج الفنكشن الرئيسي مع نفس القيم بتتغير القيم

على العموم تنبيهك جميل و مفيد

منور الموضوع ماستر :D

  • Like 1

 

 


April 25, 2016, THE BEGINNING OF MY JOURNEY ?

Check my apps in playStore


 

Posted
3 minutes ago, killerProject said:

لاحظت هذا التنبيه في الـويكي لكن صراحه تجاهلته لأن اعتقد اذا شخص سوا نفس الفنكشن خارج الفنكشن الرئيسي مع نفس القيم بتتغير القيم

على العموم تنبيهك جميل و مفيد

منور الموضوع ماستر :D

النور نورك حبيب قلبي

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...