Difference between revisions of "Chroma"

From GiderosMobile
(5 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
<!-- GIDEROSOBJ:chroma -->
 
<!-- GIDEROSOBJ:chroma -->
 
'''<translate>Supported platforms</translate>:''' [[File:Platform html5.png]][[File:Platform pc.png]]<br/>
 
'''<translate>Supported platforms</translate>:''' [[File:Platform html5.png]][[File:Platform pc.png]]<br/>
'''<translate>Available since</translate>:''' Gideros 2020.6<br/>
+
'''<translate>Available since</translate>:''' Gideros 2020.7<br/>
 
=== <translate>Description</translate> ===
 
=== <translate>Description</translate> ===
 
<translate>An interface for the RΛZΞR Chroma SDK<br/><br/>
 
<translate>An interface for the RΛZΞR Chroma SDK<br/><br/>
 
Device can be any of: "keyboard","mouse","headset","mousepad","keypad" or "chromalink".   
 
Device can be any of: "keyboard","mouse","headset","mousepad","keypad" or "chromalink".   
 
A special hybrid device called "chars" can be used to light up a key, setting it's LED colour to -1 will show the keyboard colour instead.</translate>
 
A special hybrid device called "chars" can be used to light up a key, setting it's LED colour to -1 will show the keyboard colour instead.</translate>
 +
 +
An emulator for the Chroma devices can be downloaded from here: https://developer.razer.com/works-with-chroma/download/
 +
 +
[[File:Razer.png|thumb|Screenshot of the plugin working with Razer Chroma emulator]]
 +
<br/>
 +
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===
 
'''Example'''<br/>
 
'''Example'''<br/>
Line 54: Line 60:
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Methods</translate> ===
 
=== <translate>Methods</translate> ===
[[Special:MyLanguage/chroma.new|chroma.new]] ''<translate>Initialises the plugin.</translate>''<br/><!-- GIDEROSMTD:camera.new(devices,title,description,name,contact,category) Initialises the plugin. -->
+
[[Special:MyLanguage/Chroma.new|chroma.new]] ''<translate>Initialises the plugin.</translate>''<br/><!-- GIDEROSMTD:Chroma.new(devices,title,description,name,contact,category) Initialises the plugin. -->
[[Special:MyLanguage/chroma.getSession|chroma.getSession]] ''<translate>Gets the session id</translate>''<br/><!-- GIDEROSMTD:chroma.getSession() Gets the session id -->
+
[[Special:MyLanguage/Chroma:getSession|Chroma:getSession]] ''<translate>Gets the session id</translate>''<br/><!-- GIDEROSMTD:Chroma:getSession() Gets the session id -->
[[Special:MyLanguage/chroma.getTicks|chroma.getTicks]] ''<translate>Gets the number of ticks (seconds) from the razer chroma server that you have been connected.</translate>''<br/><!-- GIDEROSMTD:chroma.getTicks() Gets the number of ticks (seconds) from the razer chroma server that you have been connected. -->
+
[[Special:MyLanguage/Chroma:getTicks|Chroma:getTicks]] ''<translate>Gets the number of ticks (seconds) from the razer chroma server that you have been connected.</translate>''<br/><!-- GIDEROSMTD:Chroma:getTicks() Gets the number of ticks (seconds) from the razer chroma server that you have been connected. -->
[[Special:MyLanguage/chroma.isReady|chroma.isReady]] ''<translate>Returns true if Chroma has started and is ready to accept commands.</translate>''<br/><!-- GIDEROSMTD:chroma.isReady() Returns true if Chroma has started and is ready to accept commands. -->
+
[[Special:MyLanguage/Chroma:isReady|Chroma:isReady]] ''<translate>Returns true if Chroma has started and is ready to accept commands.</translate>''<br/><!-- GIDEROSMTD:Chroma:isReady() Returns true if Chroma has started and is ready to accept commands. -->
[[Special:MyLanguage/chroma.getLastError|chroma.getLastError]] ''<translate>Returns the last error number.</translate>''<br/><!-- GIDEROSMTD:chroma.getLastErrory() Returns the last error number. -->
+
[[Special:MyLanguage/Chroma:getLastError|Chroma:getLastError]] ''<translate>Returns the last error number.</translate>''<br/><!-- GIDEROSMTD:Chroma:getLastErrory() Returns the last error number. -->
[[Special:MyLanguage/chroma.getErrorText|chroma.getErrorText]] ''<translate>Returns the text representation of the error number.</translate>''<br/><!-- GIDEROSMTD:chroma.getErrorText(number) Returns the text representation of the error number. -->
+
[[Special:MyLanguage/Chroma:getErrorText|Chroma:getErrorText]] ''<translate>Returns the text representation of the error number.</translate>''<br/><!-- GIDEROSMTD:Chroma:getErrorText(number) Returns the text representation of the error number. -->
[[Special:MyLanguage/chroma.getWidth|chroma.getWidth]] ''<translate>Returns the number of LED columns.</translate>''<br/><!-- GIDEROSMTD:chroma.getWidth(device) Returns the number of LED columns. -->
+
[[Special:MyLanguage/Chroma:getWidth|Chroma:getWidth]] ''<translate>Returns the number of LED columns.</translate>''<br/><!-- GIDEROSMTD:Chroma:getWidth(device) Returns the number of LED columns. -->
[[Special:MyLanguage/chroma.getHeight|chroma.getHeight]] ''<translate>Returns the number of LED rows.</translate>''<br/><!-- GIDEROSMTD:chroma.getHeight(device) Returns the number of LED rows. -->
+
[[Special:MyLanguage/Chroma:getHeight|Chroma:getHeight]] ''<translate>Returns the number of LED rows.</translate>''<br/><!-- GIDEROSMTD:Chroma:getHeight(device) Returns the number of LED rows. -->
[[Special:MyLanguage/chroma.setKey|chroma.setKey]] ''<translate>Sets the LED colour for a specific key.</translate>''<br/><!-- GIDEROSMTD:chroma.setKey(keys,colors,flush) Sets the LED colour for a specific key. -->
+
[[Special:MyLanguage/Chroma:setKey|Chroma:setKey]] ''<translate>Sets the LED colour for a specific key.</translate>''<br/><!-- GIDEROSMTD:Chroma:setKey(keys,colors,flush) Sets the LED colour for a specific key. -->
[[Special:MyLanguage/chroma.setColor|chroma.setColor]] ''<translate>Basically this sets the colour for the LED at x,y on the device.</translate>''<br/><!-- GIDEROSMTD:chroma.setColor(device,x,y,colors,flush) Basically this sets the colour for the LED at x,y on the device. -->
+
[[Special:MyLanguage/Chroma:setColor|Chroma:setColor]] ''<translate>Basically this sets the colour for the LED at x,y on the device.</translate>''<br/><!-- GIDEROSMTD:Chroma:setColor(device,x,y,colors,flush) Basically this sets the colour for the LED at x,y on the device. -->
[[Special:MyLanguage/chroma.getColor|chroma.getColor]] ''<translate>Returns the colour of the LED at x,y on the device.</translate>''<br/><!-- GIDEROSMTD:chroma.getColor(device,x,y) Returns the colour of the LED at x,y on the device. -->
+
[[Special:MyLanguage/Chroma:getColor|Chroma:getColor]] ''<translate>Returns the colour of the LED at x,y on the device.</translate>''<br/><!-- GIDEROSMTD:Chroma:getColor(device,x,y) Returns the colour of the LED at x,y on the device. -->
[[Special:MyLanguage/chroma.clear|chroma.clear]] ''<translate>Basically sets all the LED colours on the device to a specific colour.</translate>''<br/><!-- GIDEROSMTD:chroma.clear(device,color,flush) Basically sets all the LED colours on the device to a specific colour. -->
+
[[Special:MyLanguage/Chroma:clear|Chroma:clear]] ''<translate>Basically sets all the LED colours on the device to a specific colour.</translate>''<br/><!-- GIDEROSMTD:Chroma:clear(device,color,flush) Basically sets all the LED colours on the device to a specific colour. -->
[[Special:MyLanguage/chroma.flush|chroma.flush]] ''<translate>Sends the wanted colours of the LEDs to the device.</translate>''<br/><!-- GIDEROSMTD:chroma.flush(device) Sends the wanted colours of the LEDs to the device. -->
+
[[Special:MyLanguage/Chroma:flush|Chroma:flush]] ''<translate>Sends the wanted colours of the LEDs to the device.</translate>''<br/><!-- GIDEROSMTD:Chroma:flush(device) Sends the wanted colours of the LEDs to the device. -->
[[Special:MyLanguage/chroma.color|chroma.color]] ''<translate>This sets all the LED colours very quickly to a specific colour.</translate>''<br/><!-- GIDEROSMTD:chroma.color(devices,color) This sets all the LED colours very quickly to a specific colour. -->
+
[[Special:MyLanguage/Chroma:color|Chroma:color]] ''<translate>This sets all the LED colours very quickly to a specific colour.</translate>''<br/><!-- GIDEROSMTD:Chroma:color(devices,color) This sets all the LED colours very quickly to a specific colour. -->
[[Special:MyLanguage/chroma.colorScroll|chroma.colorScroll]] ''<translate>Scrolls the LED colours in a given direction.</translate>''<br/><!-- GIDEROSMTD:chroma.colorScroll(device,dirX,dirY,flush) Scrolls the LED colours in a given direction. -->
+
[[Special:MyLanguage/Chroma:colorScroll|Chroma:colorScroll]] ''<translate>Scrolls the LED colours in a given direction.</translate>''<br/><!-- GIDEROSMTD:Chroma:colorScroll(device,dirX,dirY,flush) Scrolls the LED colours in a given direction. -->
[[Special:MyLanguage/chroma.effect|chroma.effect]] ''<translate>Sends raw effect data to the Chroma server.</translate>''<br/><!-- GIDEROSMTD:chroma.effect(device,effect,para) Sends raw effect data to the Chroma server. -->
+
[[Special:MyLanguage/Chroma:effect|Chroma:effect]] ''<translate>Sends raw effect data to the Chroma server.</translate>''<br/><!-- GIDEROSMTD:Chroma:effect(device,effect,para) Sends raw effect data to the Chroma server. -->
  
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|

Revision as of 17:20, 3 July 2020


Supported platforms: Platform html5.pngPlatform pc.png
Available since: Gideros 2020.7

Description

An interface for the RΛZΞR Chroma SDK

Device can be any of: "keyboard","mouse","headset","mousepad","keypad" or "chromalink". A special hybrid device called "chars" can be used to light up a key, setting it's LED colour to -1 will show the keyboard colour instead.

An emulator for the Chroma devices can be downloaded from here: https://developer.razer.com/works-with-chroma/download/

Screenshot of the plugin working with Razer Chroma emulator


Examples

Example

pcall(function() require "json" end)

pcall(function() require "chroma" end)
if Chroma then
	print("Chroma successfully loaded")
	
	chroma=Chroma.new()

	chroma:clear("keyboard")
	local h=chroma:getHeight("keyboard")
	for y=1,h do
		for x=1,0xf do
			chroma:setColor("keyboard",x,y,(x*16)<<16)
			chroma:setColor("keyboard",31-x,y,(x*16)<<16)
		end
	end
	for loop=1,12 do
		chroma:setKey("f"..loop,0x100-(loop*0x10))
	end
	chroma:setKey({"w","up"},0xffffff)
	chroma:setKey({"z","down"},0xffffff)
	chroma:setKey({"a","left"},0xffffff)
	chroma:setKey({"s","right"},0xffffff)
end

frameCounter=0
test1=false

function gameLoop(e)
	frameCounter+=1
	if chroma and chroma:isReady() then
		if not test1 then
			chroma:effect("mouse","static",255<<8)
			chroma:effect("mousepad","static",255<<16)
			test1=true
		end
		chroma:colorScroll("keyboard",1,0,true)
	end
end

stage:addEventListener(Event.ENTER_FRAME,gameLoop)

Methods

chroma.new Initialises the plugin.
Chroma:getSession Gets the session id
Chroma:getTicks Gets the number of ticks (seconds) from the razer chroma server that you have been connected.
Chroma:isReady Returns true if Chroma has started and is ready to accept commands.
Chroma:getLastError Returns the last error number.
Chroma:getErrorText Returns the text representation of the error number.
Chroma:getWidth Returns the number of LED columns.
Chroma:getHeight Returns the number of LED rows.
Chroma:setKey Sets the LED colour for a specific key.
Chroma:setColor Basically this sets the colour for the LED at x,y on the device.
Chroma:getColor Returns the colour of the LED at x,y on the device.
Chroma:clear Basically sets all the LED colours on the device to a specific colour.
Chroma:flush Sends the wanted colours of the LEDs to the device.
Chroma:color This sets all the LED colours very quickly to a specific colour.
Chroma:colorScroll Scrolls the LED colours in a given direction.
Chroma:effect Sends raw effect data to the Chroma server.

Events

Constants