Eyeon:Script/Reference/Applications/Fuse/Classes/ColorMatrixFull/Constructor

From VFXPedia

< Eyeon:Script | Reference | Applications | Fuse | Classes | ColorMatrixFull
Revision as of 23:40, 27 February 2008 by Izyk (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents


Summary

The ColorMatrixFull function is used to create a Matrix object with four elements, used to manipulate the Red, Green, Blue and Alpha channels. For a three element Matrix, see ColorMatrix instead.

For a description of what a ColorMatrix is, and where it might be useful, see : Using the ColorMatrix.


Usage

ColorMatrixFull()


Example

The following example uses a ColorMatrixFull object to perform a contrast operation on an image.

--[[--
Mimics the Contrast function of the Brightness Contrast tool.
--]]--
 
FuRegisterClass("SimpleContrast", CT_Tool, {
	REGS_Name = "Contrast",
	REGS_Category = "Fuses\\eyeon\\Color",
	REGS_OpIconString = "sCon",
	REGS_OpDescription = "Contrast",
	})
	
function Create()
 
	InContrast = self:AddInput("Contrast", "Contrast", {
		LINKID_DataType = "Number",
		INPID_InputControl = "SliderControl",
		INP_MaxScale = 1.0,
		INP_MinScale = -1.0,
		INP_Default = 0.0,
		})
	
	InImage = self:AddInput("Input", "Input", {
		LINKID_DataType = "Image",
		LINK_Main = 1,
		})
 
	OutImage = self:AddOutput("Output", "Output", {
		LINKID_DataType = "Image",
		LINK_Main = 1,
		})	
 
end
 
function Process(req)
	local img = InImage:GetValue(req)
	local contrast = InContrast:GetValue(req).Value + 1
	
	if contrast == 0 then
		-- no change, go ahead and bypass this tool
		img:Use()
		OutImage:Set(req, img)
	else
	 
		-- create a matrix
		local m = ColorMatrixFull()
		m:Offset(-0.5, -0.5, -0.5, -0.5)
		m:Scale(contrast, contrast, contrast, contrast)
		m:Offset(0.5, 0.5, 0.5, 0.5)
		
		out = img:ApplyMatrixOf(m, {})
		
		OutImage:Set(req, out)
	end
end


Tips for Constructor (edit)

EyeonTips:Script/Reference/Applications/Fuse/Classes/ColorMatrixFull/Constructor