/// <summary> /// Initializes a new instance of the <see cref="SimpleConcreteGestureInputPlayable"/> class. /// </summary> /// <param name="mst">The MST.</param> /// <param name="mask">The mask.</param> /// <param name="et">The et.</param> public SimpleConcreteGestureInputPlayable(GestureType gestureType, Action <GestureSample> mst = null, InputMask mask = InputMask.GSYSTEM, EntityType et = Input.EntityType.TOOLS) { this.GestureType = gestureType; this.GestureFired += mst; this.EntityType = et; this.mask = mask; }
override public bool computeOutput(ConnectionPoint connPoint, OutputGenerationParams parms) { if (!verifyInputConnections()) { return(false); } if (!gatherInputAndParameters(parms)) { return(false); } MaskParam mp = ((MaskParam)(connPoint.ParamType)); mp.Value = InputMask.Clone(); mp.Value.mConstraintMask = ConstraintMask; for (int x = 0; x < parms.Width; x++) { for (int y = 0; y < parms.Height; y++) { int tx = FlipHorizontal ? parms.Width - x - 1 : x; int ty = FlipVertical ? parms.Height - y - 1 : y; mp.Value[x, y] = InputMask[tx, ty]; } } return(true); }
private ComboBox CreateComboBox(InputMask mask, int i, IList data) { var comboBox = new ComboBox { Tag = mask, Name = "cb" + mask, Left = 85, Top = 25 * i, BindingContext = new BindingContext(), DisplayMember = "Key", ValueMember = "Value", DataSource = data }; var label = new Label { Text = mask.ToString(), Top = comboBox.Top + 3, Width = 60 }; Controls.Add(label); Controls.Add(comboBox); comboBox.SelectedValueChanged += ComboBox_SelectedValueChanged; return(comboBox); }
override public bool computeOutput(ConnectionPoint connPoint, OutputGenerationParams parms) { if (!verifyInputConnections()) { return(false); } if (!gatherInputAndParameters(parms)) { return(false); } MaskParam mp = ((MaskParam)(connPoint.ParamType)); mp.Value = InputMask.Clone(); mp.Value.mConstraintMask = ConstraintMask; for (int x = 0; x < parms.Width; x++) { for (int y = 0; y < parms.Height; y++) { mp.Value[x, y] = mp.Value[x, y] * Gain + Bias; } } return(true); }
private bool processMask(InputMask m) { if ((m & mask) == m) { return(true); } return(false); }
public SimpleConcreteMouseBottomInputPlayable(StateKey sk, EntityType et, MouseButtons mb, MouseStateChangeComplete mst = null, InputMask mask = Input.InputMask.GSYSTEM) { this.sk = sk; this.mb = mb; this.KeyStateChange += mst; this.et = et; this.mask = mask; }
public virtual void Process() { Vector3 axisDirection = Facade.SourceOfForwardDirection != null?ApplyForwardSourceToAxis(CurrentAxisData) : CurrentAxisData; float multiplier = Facade.AxisUsageType == AxesToVector3Facade.AxisUsage.Incremental ? (Time.inFixedTimeStep ? Time.fixedDeltaTime : Time.deltaTime) : 1f; CurrentMovement = InputMask.Transform(axisDirection) * multiplier; Facade.Processed?.Invoke(CurrentMovement); }
/// <summary> /// Initializes a new instance of the <see cref="SimpleConcreteKeyboardInputPlayable"/> class. /// For Combo /// </summary> /// <param name="state">The state.</param> /// <param name="key">The key.</param> /// <param name="callback">The callback.</param> /// <param name="mask">The mask.</param> /// <param name="type">The type.</param> public SimpleConcreteKeyboardInputPlayable(StateKey state, Keys[] key, KeyStateChange callback = null, InputMask mask = InputMask.GSYSTEM, EntityType type = Input.EntityType.TOOLS) { this.state = state; this.key = key; if (callback != null) { this.KeyStateChange += callback; } this.type = type; this.mask = mask; }
override public bool computeOutput(ConnectionPoint connPoint, OutputGenerationParams parms) { if (!verifyInputConnections()) { return(false); } if (!gatherInputAndParameters(parms)) { return(false); } MaskParam mp = ((MaskParam)(connPoint.ParamType)); mp.Value = InputMask.Clone(); mp.Value.mConstraintMask = ConstraintMask; int numTimesToRun = parms.Width >> 1; DAGMask outMask = InputMask.Clone();// DAGMask distMask = new DAGMask(parms.Width, parms.Height); int maxRange = 0; for (int i = 0; i < numTimesToRun; i++) { DAGMask smallerMask = new DAGMask(parms.Width, parms.Height); bool madeChange = contractSetValue(ref outMask, ref smallerMask, ref distMask, i); outMask = smallerMask.Clone(); if (madeChange) { maxRange = i; } else { break; } } //normalize our input now... for (int x = 0; x < parms.Width; x++) { for (int y = 0; y < parms.Height; y++) { mp.Value[x, y] = distMask[x, y] / (float)maxRange; } } outMask = null; return(true); }
override public bool computeOutput(ConnectionPoint connPoint, OutputGenerationParams parms) { if (!verifyInputConnections()) { return(false); } if (!gatherInputAndParameters(parms)) { return(false); } setNoiseParms(); MaskParam mp = ((MaskParam)(connPoint.ParamType)); mp.Value = InputMask.Clone(); mp.Value.mConstraintMask = ConstraintMask; for (int y = 0; y < parms.Height; y++) { for (int x = 0; x < parms.Width; x++) { float x0, y0; float x1, y1; float x2, y2; x0 = x + (12414.0f / 65536.0f); y0 = y + (65124.0f / 65536.0f); x1 = x + (26519.0f / 65536.0f); y1 = y + (18128.0f / 65536.0f); x2 = x + (53820.0f / 65536.0f); y2 = y + (11213.0f / 65536.0f); float xDistort = ((float)(mXDistort.getValue(x0, y0, 0) * Power)); float yDistort = ((float)(mYDistort.getValue(x1, y1, 0) * Power)); int kx = (int)BMathLib.Clamp(x + (int)(xDistort * parms.Width), 0, parms.Width - 1); int ky = (int)BMathLib.Clamp(y + (int)(yDistort * parms.Height), 0, parms.Height - 1); mp.Value[x, y] = InputMask[kx, ky]; } } return(true); }
public void UpdatePosition(InputMask mask) { bool HasFlag(InputMask flag) => (mask & flag) == flag; if (!Loaded) { return; } var camera = Process.Read <CSimpleCamera>(CameraPtr); float speed = MovementSpeed; if (HasFlag(InputMask.Fast)) { speed *= 2f; } if (HasFlag(InputMask.Slow)) { speed /= 2f; } if (HasFlag(InputMask.Forward)) { camera.Position += Vector3.Multiply(speed, camera.Forward); } if (HasFlag(InputMask.Backward)) { camera.Position -= Vector3.Multiply(speed, camera.Forward); } if (HasFlag(InputMask.Right)) { camera.Position -= Vector3.Multiply(speed, camera.Right); } if (HasFlag(InputMask.Left)) { camera.Position += Vector3.Multiply(speed, camera.Right); } if (HasFlag(InputMask.Ascend)) { camera.Position += Vector3.Multiply(speed, camera.Up); } if (HasFlag(InputMask.Descend)) { camera.Position -= Vector3.Multiply(speed, camera.Up); } Process.Write(CameraPtr + (uint)FieldOffsets.Position, camera.Position); }
void ProcessInputButton() { InputMask prev = m_Mask; m_Mask = 0; for (int i = 0; i < m_UsedInput.Length; i++) { if (Input.GetButton(m_UsedInput[i].m_InputAxis)) { m_Mask |= m_UsedInput[i].m_InputMask; } } m_DownMask = (prev ^ m_Mask) & m_Mask; m_UpMask = (prev ^ m_Mask) & prev; }
static void Main(string[] args) { Console.Title = "Input mask demo application"; #region Normal usage Console.WriteLine("Standard usage "); Console.Write("Enter password: "******"Password: {password}"); Console.WriteLine(); #endregion #region Usage with length restriction Console.WriteLine("Usage with length restriction"); Console.Write("Enter your password : "******"Password: {password}"); Console.WriteLine(); #endregion #region Usage with length restriction and custom mask Console.WriteLine("Usage with length restriction and custom mask"); Console.Write("Enter your password : "******"Password: {password}"); Console.WriteLine(); #endregion Console.WriteLine("Usage with custom termination behaviour"); Console.Write("Enter "); Console.ForegroundColor = ConsoleColor.Red; Console.Write("exit"); Console.ResetColor(); Console.Write(" : "); new InputMask { MaskingCompleted = WhenInputIsExit }.Read(4, '.'); Console.WriteLine(" ==> finished on exit"); Console.WriteLine(); Console.ReadLine(); }
public static InputMask ParseInputMask(string text, char split = BUTTON_COMBINE_MARK) { if (string.IsNullOrEmpty(text)) { return(0); } InputMask mask = 0; string[] spl = text.Split(split); for (int i = 0; i < spl.Length; i++) { InputMask m = (InputMask)System.Enum.Parse(typeof(InputMask), spl[i].Trim(), true); mask |= m; } return(mask); }
override public bool computeOutput(ConnectionPoint connPoint, OutputGenerationParams parms) { if (!verifyInputConnections()) { return(false); } gatherInputAndParameters(parms); MaskParam mp = ((MaskParam)(connPoint.ParamType)); // mp.Value = InputMask.Clone(); DAGMask baseMask = InputMask.Clone(); DAGMask addMask = new DAGMask(parms.Width, parms.Height); DAGMask subMask = new DAGMask(parms.Width, parms.Height); //if we're doing multiscale erosion if (MultiscaleEnable) { //subtract multiscale mask from our base mask before doing erosion multiscaleDisplace(ref baseMask, ref subMask, ref addMask); } //CLM it actually looks better (less noisy) w/o this high fidelity step! calculateErosion(baseMask, baseMask.Width, baseMask.Height, ref subMask, ref addMask, 0); //calculate our mask 'channels' for (int x = 0; x < parms.Width; x++) { for (int y = 0; y < parms.Height; y++) { baseMask[x, y] = baseMask[x, y] + addMask[x, y] - subMask[x, y]; } } //need to find which output this connection point is connected to... mp.Value = baseMask.Clone(); return(true); }
override public bool computeOutput(ConnectionPoint connPoint, OutputGenerationParams parms) { if (!verifyInputConnections()) { return(false); } if (!gatherInputAndParameters(parms)) { return(false); } MaskParam mp = ((MaskParam)(connPoint.ParamType)); mp.Value = InputMask.Clone(); mp.Value.mConstraintMask = ConstraintMask; if (ClampType == (int)eMethod.eScale) //scale between the values { float delta = MaxHeight - MinHeight; for (int x = 0; x < parms.Width; x++) { for (int y = 0; y < parms.Height; y++) { mp.Value[x, y] = MinHeight + (InputMask[x, y] * delta); } } } else if (ClampType == (int)eMethod.eClamp) //actually clamp { for (int x = 0; x < parms.Width; x++) { for (int y = 0; y < parms.Height; y++) { mp.Value[x, y] = BMathLib.Clamp(InputMask[x, y], MinHeight, MaxHeight); } } } return(true); }
override public bool computeOutput(ConnectionPoint connPoint, OutputGenerationParams parms) { if (!verifyInputConnections()) { return(false); } if (!gatherInputAndParameters(parms)) { return(false); } //this is a splitter, so we need to duplicate the input values.. MaskParam mp = ((MaskParam)(connPoint.ParamType)); mp.Value = InputMask.Clone(); return(true); }
public static void BindKey(InputMask input, Keys key) { if (input == InputMask.None || !Enum.IsDefined(typeof(InputMask), input)) { return; } if (TryGet(key, out var oInput)) { InputToKeys.Remove(oInput); } if (TryGet(input, out var oKey)) { KeysToInput.Remove(oKey); } InputToKeys[input] = key; KeysToInput[key] = input; }
public bool MatchKey(InputMask mask) { if (m_Combination == InputCombine.contains_all) { return((mask & m_Mask) == m_Mask); } else if (m_Combination == InputCombine.contains_any) { return((mask & m_Mask) != 0); } else if (m_Combination == InputCombine.just_all) { return(mask == m_Mask); } else { return(false); } }
override public bool computeOutput(ConnectionPoint connPoint, OutputGenerationParams parms) { if (!verifyInputConnections()) { return(false); } if (!gatherInputAndParameters(parms)) { return(false); } MaskParam mp = ((MaskParam)(connPoint.ParamType)); mp.Value = InputMask.Clone(); mp.Value.mConstraintMask = ConstraintMask; DAGMask outMask = InputMask.Clone(); for (int i = 0; i < NumPixels; i++) { DAGMask smallerMask = new DAGMask(parms.Width, parms.Height); contractSetValue(ref outMask, ref smallerMask); outMask = smallerMask.Clone(); } //normalize our input now... for (int x = 0; x < parms.Width; x++) { for (int y = 0; y < parms.Height; y++) { mp.Value[x, y] = outMask[x, y]; } } outMask = null; return(true); }
override public bool computeOutput(ConnectionPoint connPoint, OutputGenerationParams parms) { if (!verifyInputConnections()) { return(false); } if (!gatherInputAndParameters(parms)) { return(false); } MaskParam mp = ((MaskParam)(connPoint.ParamType)); mp.Value = InputMask.Clone(); mp.Value.mConstraintMask = ConstraintMask; SplineInterpolator interpolator = new SplineInterpolator(); for (int i = 0; i < ControlPointsKeys.Count; ++i) { interpolator.Add(ControlPointsKeys[i], ControlPointsValues[i]); } for (int x = 0; x < parms.Width; x++) { for (int y = 0; y < parms.Height; y++) { float v = mp.Value[x, y]; mp.Value[x, y] = (float)interpolator.Interpolate(v); } } interpolator.Clear(); interpolator = null; return(true); }
public static string MaskText(InputMask mask, char split = BUTTON_COMBINE_MARK) { builder.Remove(0, builder.Length); bool first = true; for (int i = 0; i < 32; i++) { InputMask m = (InputMask)(1u << i); if ((mask & m) != 0) { if (first) { first = false; } else { builder.Append(' ').Append(split).Append(' '); } builder.Append(m); } } return(builder.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="SimpleConcreteMousePositionInputPlayable"/> class. /// </summary> /// <param name="mst">The MST.</param> /// <param name="mask">The mask.</param> /// <param name="et">The et.</param> public SimpleConcreteMousePositionInputPlayable(MouseStateChangeComplete mst = null, InputMask mask = InputMask.GSYSTEM, EntityType et = Input.EntityType.TOOLS) { this.mst = mst; this.et = et; this.mask = mask; }
public static T SetMask <T>(this T control, InputMask mask) where T : TextBoxControl { control.Mask = mask; return(control); }
/// <summary> /// Initializes a new instance of the <see cref="TurnOffInputMaskCommand"/> class. /// </summary> /// <param name="mask">The mask.</param> public TurnOffInputMaskCommand(InputMask mask) { this.mask = mask; }
public static bool TryGet(InputMask input, out Keys key) { return(InputToKeys.TryGetValue(input, out key) && key != Keys.None); }
override public bool computeOutput(ConnectionPoint connPoint, OutputGenerationParams parms) { if (!verifyInputConnections()) { return(false); } if (!gatherInputAndParameters(parms)) { return(false); } MaskParam mp = ((MaskParam)(connPoint.ParamType)); mp.Value = InputMask.Clone(); mp.Value.mConstraintMask = ConstraintMask; /////////////////////////////////////////////////////////////// int width = parms.Width; int height = parms.Height; int rad = Radius; int[] leadingEdgeX = new int[rad + 1]; // approximately (rad + 0.5)^2 int cutoff = ((rad * 2 + 1) * (rad * 2 + 1) + 2) / 4; for (int v = 0; v <= rad; ++v) { for (int u = 0; u <= rad; ++u) { if (u * u + v * v <= cutoff) { leadingEdgeX[v] = u; } } } const int hLength = 256; int[] ha = new int[hLength]; for (int y = 0; y < parms.Height; y++) { //calculate our histogram.. for (int k = 0; k < hLength; k++) { ha[k] = 0; } int area = 0; int maxArea = GetMaxAreaForRadius(rad); int top = -Math.Min(rad, y); int bottom = Math.Min(rad, height - 1 - y); int left = -Math.Min(rad, 0); int right = Math.Min(rad, width - 1); for (int v = top; v <= bottom; ++v) { for (int u = left; u <= right; ++u) { byte psamp = (byte)(InputMask[u, y + v] * 255); if ((u * u + v * v) <= cutoff) { ++area; ++ha[psamp]; } } } for (int x = 0; x < parms.Width; x++) { mp.Value[x, y] = GetPercentile(Percent, area, ref ha) / 255.0f; left = -Math.Min(rad, x); right = Math.Min(rad + 1, width - 1 - x); // Subtract trailing edge top half int v = -1; while (v >= top) { int u = leadingEdgeX[-v]; if (-u >= left) { break; } --v; } while (v >= top) { int u = leadingEdgeX[-v]; byte p = (byte)(InputMask[x - u, y + v] * 255); --ha[p]; --area; --v; } // add leading edge top half v = -1; while (v >= top) { int u = leadingEdgeX[-v]; if (u + 1 <= right) { break; } --v; } while (v >= top) { int u = leadingEdgeX[-v]; byte p = (byte)(InputMask[x + u + 1, y + v] * 255); ++ha[p]; ++area; --v; } // Subtract trailing edge bottom half v = 0; while (v <= bottom) { int u = leadingEdgeX[v]; if (-u >= left) { break; } ++v; } while (v <= bottom) { int u = leadingEdgeX[v]; byte p = (byte)(InputMask[x - u, y + v] * 255); --ha[p]; --area; ++v; } // add leading edge bottom half v = 0; while (v <= bottom) { int u = leadingEdgeX[v]; if (u + 1 <= right) { break; } ++v; } while (v <= bottom) { int u = leadingEdgeX[v]; byte p = (byte)(InputMask[x + u + 1, y + v] * 255); ++ha[p]; ++area; ++v; } } } return(true); }
internal void TurnOnInputMask(InputMask mask) { this.mask = this.mask | mask; }
override public bool computeOutput(ConnectionPoint connPoint, OutputGenerationParams parms) { if (!verifyInputConnections()) { return(false); } if (!gatherInputAndParameters(parms)) { return(false); } MaskParam mp = ((MaskParam)(connPoint.ParamType)); mp.Value = InputMask.Clone(); mp.Value.mConstraintMask = ConstraintMask; float modStep = 1.0f / NumTerraces; if (Method == (int)eMethod.eSimple) { for (int x = 0; x < parms.Width; x++) { for (int y = 0; y < parms.Height; y++) { float dc = InputMask[x, y] % modStep; mp.Value[x, y] = InputMask[x, y] - dc; } } } else if (Method == (int)eMethod.eSharp) { for (int y = 0; y < parms.Height; y++) { for (int x = 0; x < parms.Width; x++) { //find our low step float val = InputMask[x, y]; float low = val - (val % modStep); float high = low + modStep; float posalpha = (val - low) / (high - low); posalpha *= posalpha; float posVal = ((1.0f - posalpha) * low) + (posalpha * high); float negalpha = (val - low) / (high - low); negalpha = 1.0f - negalpha; { float v = low; low = high; high = v; } negalpha *= negalpha; float negVal = ((1.0f - negalpha) * low) + (negalpha * high); //lerp between neg and pos values mp.Value[x, y] = ((1.0f - TerraceShape) * negVal) + (TerraceShape * posVal); } } } //else if (Method == (int)eMethod.eSmooth) //{ //} return(true); }
internal void TurnOffInputMask(InputMask mask) { this.mask = this.mask & ~mask; this.mask = this.mask | InputMask.GSYSTEM; }
private bool processMask(InputMask m) { if ((m & mask) == m ) { return true; } return false; }
public static bool TryGet(Keys key, out InputMask inputMask) { return(KeysToInput.TryGetValue(key, out inputMask) && inputMask != InputMask.None); }
/// <summary> /// Initializes a new instance of the <see cref="TurnOnInputMaskCommand"/> class. /// </summary> /// <param name="mask">The mask.</param> public TurnOnInputMaskCommand(InputMask mask) { this.mask = mask; }
/// <summary> /// Initializes a new instance of the <see cref="SimpleConcreteGestureInputPlayable"/> class. /// </summary> /// <param name="mst">The MST.</param> /// <param name="mask">The mask.</param> /// <param name="et">The et.</param> public SimpleConcreteGestureInputPlayable(GestureType gestureType, Action<GestureSample> mst = null, InputMask mask = InputMask.GSYSTEM, EntityType et = Input.EntityType.TOOLS) { this.GestureType = gestureType; this.GestureFired += mst; this.EntityType = et; this.mask = mask; }
/// <summary> /// Initializes a new instance of the <see cref="SimpleConcreteKeyboardInputPlayable"/> class. /// For Combo /// </summary> /// <param name="state">The state.</param> /// <param name="key">The key.</param> /// <param name="callback">The callback.</param> /// <param name="mask">The mask.</param> /// <param name="type">The type.</param> public SimpleConcreteKeyboardInputPlayable(StateKey state, Keys[] key, KeyStateChange callback = null, InputMask mask = InputMask.GSYSTEM, EntityType type = Input.EntityType.TOOLS) { this.state = state; this.key = key; if(callback != null) this.KeyStateChange += callback; this.type = type; this.mask = mask; }