Eyeon:Script/Reference/Applications/Fuse/Classes/Input/SetSource
From VFXPedia
< Eyeon:Script | Reference | Applications | Fuse | Classes | Input
Contents |
Summary
The SetSource function is used to set an Input to a specified value.
Usage
Input:SetSource(various value, number time)
- value (object, required)
- The value which should be assigned to the input. The type will vary according to the inputs LINKID_DataType attribute. The value should by one of Fusion's datatypes, like Number, Text, or Point. This means a call like Input:SetSource("some text", 0) would fail, but Input:SetSource(Text("some text"), 0) would work.
- time (number, required)
- The frame at which to set the input value. If an input is animated, this will ensure the value sets the appropriate keyframe.
Example
The following example is a complete Fuse which analyzes all pixels in an image and sets the values of the sliders to match the values of the lowest values of the Red, Green and Blue channels.
------------------------------------------------------------------------------ -- MinFinder.scriptplugin -- -- This tool will find the minimum pixel value in an image and publish this -- to a control for use with scripts. -- -- Created by: Sean Konrad at Frantic Films -- ------------------------------------------------------------------------------ FuRegisterClass("MinFinder", CT_Tool, { REGS_Category = "Color", REGS_OpIconString = "MF", REGS_OpDescription = "Minimum Value Finder", REG_OpNoMask = true, REG_NoBlendCtrls = false, REG_NoObjMatCtrls = true, REG_NoMotionBlurCtrls = true, }) function Create() InRed = self:AddInput("Red", "Red", { INPID_InputControl = "SliderControl", INP_Default = 1.0, INP_DoNotifyChanged = true, INP_External = false }) InGreen = self:AddInput("Green", "Green", { INPID_InputControl = "SliderControl", INP_Default = 1.0, INP_DoNotifyChanged = true, INP_External = false }) InBlue = self:AddInput("Blue", "Blue", { INPID_InputControl = "SliderControl", INP_Default = 1.0, INP_DoNotifyChanged = true, INP_External = false, }) InAlpha = self:AddInput("Alpha", "Alpha", { INPID_InputControl = "SliderControl", INP_Default = 1.0, INP_DoNotifyChanged = true, INP_External = false }) InImage1 = self:AddInput("Input 1", "Input1", { LINKID_DataType = "Image", LINK_Main = 1, }) OutImage = self:AddOutput("Output", "Output", { LINKID_DataType = "Image", LINK_Main = 1, }) end -- Function table for our operations op_funcs = { [1] = function(x,y,p1) -- div if p1.G < gLow then gLow = p1.G end if p1.R < rLow then rLow = p1.R end if p1.B < bLow then bLow = p1.B end if p1.A < aLow then aLow = p1.A end return p1 end, } function Process(req) gLow = 100 bLow = 100 rLow = 100 aLow = 100 local img1 = InImage1:GetValue(req) local func = op_funcs[1] out = Image({IMG_Like = img1}) out:ProcessPixels(0,0, img1.Width, img1.Height, img1, func) InRed:SetSource(Number(rLow),0) InBlue:SetSource(Number(bLow),0) InGreen:SetSource(Number(gLow),0) InAlpha:SetSource(Number(aLow),0) OutImage:Set(req, out) end
Tips for SetSource (edit)
- SetSource will trigger the NotifyChanged event if the target input has INP_DoNotifyChanged enabled. If you want to prevent this, you can add a third parameter (set to zero) to SetSource:
InRed:SetSource(Number(rLow), 0, 0)