void decodeBytes(byte[] bytes, ValueMode valueMode, int i, ref Keyframe key) { float valueNormal; if (valueMode == ValueMode.Byte1) { valueNormal = bytes[i] * 1.0f / byte.MaxValue; } else if (valueMode == ValueMode.Byte2) { int value = bytes[i * 2]; value |= bytes[i * 2 + 1] << 8; valueNormal = value * 1.0f / ushort.MaxValue; } else if (valueMode == ValueMode.ValueTan) { valueNormal = bytes[i * 2] * 1.0f / byte.MaxValue; float tanNormal = bytes[i * 2 + 1] * 1.0f / byte.MaxValue; key.inTangent = key.outTangent = Mathf.Lerp(TanMin, TanMax, tanNormal); } else { throw new ArgumentException(); } key.value = Mathf.Lerp(valueMin, valueMax, valueNormal); }
/// <summary> /// Sets a value for the specified field /// </summary> /// <param name="Field">The column or field name</param> /// <param name="Value">The new value to update</param> /// <param name="Mode">Sets how the update value will be applied to the existing field value</param> public void SetField(string Field, object Value, ValueMode Mode) { if (Fields.ContainsKey(Field)) Fields[Field] = new FieldValuePair(Field, Value, Mode); else Fields.Add(Field, new FieldValuePair(Field, Value, Mode)); }
protected override async void OnAppearing() { base.OnAppearing(); if (firstTime) { firstTime = false; this.currentMode = UserPrefs.Mode; await viewModel.ExecuteLoadItemsCommand(this.currentMode); Device.BeginInvokeOnMainThread(async() => { await Task.Delay(50); ItemsCollectionView.ScrollTo(viewModel.Items[15], -1, ScrollToPosition.Start, false); }); } else { if (this.currentMode != UserPrefs.Mode) { this.currentMode = UserPrefs.Mode; await ResetEverything(); } } }
void encodBytes(byte[] bytes, ValueMode valueMode, int i, ref Keyframe key) { var value = key.value; var valueNormal = Mathf.InverseLerp(valueMin, valueMax, value); if (valueMode == ValueMode.Byte1) { bytes[i] = (byte)(valueNormal * byte.MaxValue); } else if (valueMode == ValueMode.Byte2) { ushort bytesValue = (ushort)(valueNormal * ushort.MaxValue); bytes[i * 2] = (byte)(bytesValue & 0XFF); bytes[i * 2 + 1] = (byte)((bytesValue >> 8) & 0XFF); } else if (valueMode == ValueMode.ValueTan) { ushort bytesValue = (ushort)(valueNormal * ushort.MaxValue); bytes[i * 2] = (byte)(valueNormal * byte.MaxValue); bytes[i * 2 + 1] = (byte)(Mathf.InverseLerp(TanMin, TanMax, key.inTangent) * byte.MaxValue); } else { throw new ArgumentException("dataMode:" + valueMode + " error!"); } }
public LatinSquareFC(int size, ValueMode valueMode, VariableMode variableMode, bool firstOnly = false) { _size = size; _valueMode = valueMode; _variableMode = variableMode; _firstOnly = firstOnly; board = new int[_size, _size]; _domain = _size; processed = new List <Position2>(); notProcessed = new List <Position2>(); Solutions = new List <int[, ]>(); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { var pos = new Position2() { X = i, Y = j, Domain = new SortedSet <int>() }; for (int x = 1; x <= _domain; x++) { pos.Domain.Add(x); } pos.Removed = new List <Position2>(); notProcessed.Add(pos); } } }
public CValueProperty() { Mode = ValueMode.Digit; Font = new Font("Tahoma", 7); Color = Color.FromArgb(255, 255, 255, 255); Visible = true; }
public async Task ExecuteLoadItemsCommand(ValueMode mode) { IsBusy = true; try { Items.Clear(); int j = 0; for (int i = 0; i < 10; i++) { Items.Add(new ItemViewModel(page, j++ % 2 == 0)); } foreach (string value in GetValuesBasedOnUserPrefs(mode)) { Items.Add(new ItemViewModel(page, j++ % 2 == 0, value)); } for (int i = 0; i < 10; i++) { Items.Add(new ItemViewModel(page, j++ % 2 == 0)); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
/// <summary> /// 编码成AnimationCurve /// </summary> /// <param name="clip"></param> /// <param name="curve"></param> public void encodeData(CompressedClipData clip, AnimationCurve curve, ValueMode valueMode, bool tan) { float maxTime = clip.length; float time = clip.length; float frameRate = clip.frameRate; List <Keyframe> keys = new List <Keyframe>(curve.keys); deleteOverframe(frameRate, keys); var length = keys.Count; //keysData = new uint[length]; if (valueMode == ValueMode.Byte1) { keysValueByte = new byte[length]; } else { keysValueByte = new byte[length * 2]; } if (tan) { keysTans = new float[length]; } //计算最大值和最小值 valueMin = float.MaxValue; valueMax = float.MinValue; for (int i = 0; i < length; i++) { var key = keys[i]; valueMin = Mathf.Min(valueMin, key.value); valueMax = Mathf.Max(valueMax, key.value); } int timeBytes = Mathf.CeilToInt((time * frameRate + 1) / 8); keysTime = new byte[timeBytes]; float valueSize = valueMax - valueMin; //编码时间和关键帧值 for (int i = 0; i < length; i++) { var key = keys[i]; //时间 int keyIndex = Mathf.RoundToInt(key.time * frameRate); int byteIndex = keyIndex / 8; int byteBit = keyIndex % 8; byte keysTimeByte = keysTime[byteIndex]; keysTime[byteIndex] |= (byte)(1 << byteBit); encodBytes(keysValueByte, valueMode, i, ref key); if (tan) { keysTans[i] = key.inTangent; } } this.valueMode = (byte)valueMode; encodeDebugData(keys); }
private VerifiableMemberContext(object value, VerifiableMemberContract contract, VerifiableObjectContext parentContext) { _parentContext = parentContext; _contract = contract ?? throw new ArgumentNullException(nameof(contract)); _valueMode = ValueMode.DirectValue; _hasGot = true; _valueCached = value; }
public CommandSwitch(string name, ValueMode mode, bool optional) { if (name.Length == 0) throw new Exception("CommandSwitch: empty name not allowed"); this.Name = name; this.Mode = mode; this.Optional = optional; }
public void RestoreObject() { if (m_clone != null) { this.Visible = m_clone.Visible; this.Font = m_clone.Font; this.Color = m_clone.Color; this.Mode = m_clone.Mode; } }
/// <summary> /// Sets a value for the specified field /// </summary> /// <param name="Field">The column or field name</param> /// <param name="Value">The new value to update</param> /// <param name="Mode">Sets how the update value will be applied to the existing field value</param> public void SetField(string Field, object Value, ValueMode Mode) { if (Fields.ContainsKey(Field)) { Fields[Field] = new FieldValuePair(Field, Value, Mode); } else { Fields.Add(Field, new FieldValuePair(Field, Value, Mode)); } }
private List <string> GetValuesBasedOnUserPrefs(ValueMode mode) { switch (mode) { case ValueMode.Ev: return(Values.Instance.Ev.ToList()); case ValueMode.ShutterSpeed: return(Values.Instance.ShutterSpeeds.ToList()); case ValueMode.Aperture: return(Values.Instance.Apertures.ToList()); } return(Values.Instance.Ev.ToList()); }
public NQueensFC(int numberOfQueens, ValueMode valueMode, VariableMode variableMode) { _numberOfQueens = numberOfQueens; _domain = numberOfQueens; board = new int[numberOfQueens]; notProcessed = new List <int>(); for (int i = 0; i < _numberOfQueens; i++) { notProcessed.Add(i); } Solutions = new List <int[]>(); processed = new List <int>(); _valueMode = valueMode; _variableMode = variableMode; }
public NQueens(int numberOfQueens, ValueMode valueMode, VariableMode variableMode) { _numberOfQueens = numberOfQueens; _domain = numberOfQueens; board = new int[numberOfQueens]; processed = new List <int>(); Solutions = new List <int[]>(); valuesHistory = new int[numberOfQueens][]; for (int i = 0; i < valuesHistory.Length; i++) { valuesHistory[i] = new int[numberOfQueens]; } _valueMode = valueMode; _variableMode = variableMode; }
/// <summary> /// Returns the sign for the given value mode /// </summary> /// <param name="mode"></param> /// <returns></returns> protected string GetSign(ValueMode mode) { switch (mode) { default: case ValueMode.Set: return("="); case ValueMode.Add: return("+"); case ValueMode.Divide: return("/"); case ValueMode.Multiply: return("*"); case ValueMode.Subtract: return("-"); } }
long IndexFor(int relativePos, ValueMode mode) { if (mode == ValueMode.Position) { return(program[cursor + relativePos]); } else if (mode == ValueMode.Immediate) { return(cursor + relativePos); } else if (mode == ValueMode.Relative) { return(relativeBase + program[cursor + relativePos]); } throw new ArgumentException($"Why you do this? Mode: {mode}"); }
/// <summary> /// 拷贝编辑器变量 /// </summary> /// <param name="FromInstance">从哪一个拷贝</param> public void CopyInspectorParamsTo(Effect_FadeInOutMaterialFloat FromInstance) { RunMode = FromInstance.RunMode; valueMode = FromInstance.valueMode; curve.keys = FromInstance.curve.keys; curve_DuartionTime = FromInstance.curve_DuartionTime; cure_DelayTime = FromInstance.cure_DelayTime; curveScale = FromInstance.curveScale; PropertyName = FromInstance.PropertyName; Loop = FromInstance.Loop; FadeInDealy = FromInstance.FadeInDealy; FadeInDuartion = FromInstance.FadeInDuartion; FadeInFrom = FromInstance.FadeInFrom; FadeInTo = FromInstance.FadeInTo; FadeOutDelay = FromInstance.FadeOutDelay; FadeOutDuartion = FromInstance.FadeOutDuartion; FadeOutFrom = FromInstance.FadeOutFrom; FadeOutTo = FromInstance.FadeOutTo; }
public void OnInspectorGUI(MultiModeTexts text) { GUIFloat(text.value, m_Value); EditorGUI.indentLevel++; GUIPopup(text.mode, m_Mode, s_Texts.emissionModes); GUIFloat(text.spread, m_Spread); if (!m_Mode.hasMultipleDifferentValues) { ValueMode mode = (ValueMode)m_Mode.intValue; if (mode == ValueMode.Loop || mode == ValueMode.PingPong) { GUIMinMaxCurve(text.speed, m_Speed); } } EditorGUI.indentLevel--; }
/// <summary> /// Sets a value for the specified column /// </summary> /// <param name="column">The column or attribute name</param> /// <param name="value">The new value to update</param> /// <param name="mode">Sets how the update value will be applied to the existing field value</param> internal UpdateQueryBuilder Set(string column, object value, ValueMode mode) { // Check parameter if (String.IsNullOrWhiteSpace(column)) { throw new ArgumentNullException("column"); } // Add column to list if (Columns.ContainsKey(column)) { Columns[column] = new ColumnValuePair(column, value, mode); } else { Columns.Add(column, new ColumnValuePair(column, value, mode)); } // Return this instance for chaining return(this); }
//解码动画曲线 public AnimationCurve decodeData(CompressedClipData clip) { float maxTime = clip.length; ValueMode valueMode = (ValueMode)this.valueMode; AnimationCurve curve = new AnimationCurve(); var length = keysValueByte.Length; if (valueMode == ValueMode.Byte2 || valueMode == ValueMode.ValueTan) { length = length / 2; } // float ValueMax = valueMode == ValueMode.Byte1 ? byte.MaxValue : ushort.MaxValue; var keys = new Keyframe[length]; bool tansData = keysTans != null && keysTans.Length > 0; for (int i = 0; i < length; i++) { Keyframe key = new Keyframe(); decodeBytes(keysValueByte, valueMode, i, ref key); if (tansData) { key.inTangent = keysTans[i]; key.outTangent = keysTans[i]; } keys[i] = key; } decodeTime(clip, keys); decodeDebugData(keys); curve.keys = keys; if (valueMode != ValueMode.ValueTan && !tansData) { for (int i = 0; i < length; i++) { curve.SmoothTangents(i, 0f); } } return(curve); }
public LatinSquare(int size, ValueMode valueMode, VariableMode variableMode, bool firstOnly = false) { _size = size; _valueMode = valueMode; _variableMode = variableMode; _firstOnly = firstOnly; board = new int[_size, _size]; _domain = _size; processed = new List <Position>(); notProcessed = new List <Position>(); Solutions = new List <int[, ]>(); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { notProcessed.Add(new Position() { X = i, Y = j }); } } }
/// <summary> /// Returns the sign for the given value mode /// </summary> /// <param name="Mode"></param> /// <returns></returns> protected string GetSign(ValueMode Mode) { string Sign = ""; switch (Mode) { case ValueMode.Add: Sign = "+"; break; case ValueMode.Divide: Sign = "/"; break; case ValueMode.Multiply: Sign = "*"; break; case ValueMode.Subtract: Sign = "-"; break; } return(Sign); }
public FieldValuePair(string Field, object Value, ValueMode Mode) { this.Field = Field; this.Value = Value; this.Mode = Mode; }
/// <summary> /// Returns the sign for the given value mode /// </summary> /// <param name="Mode"></param> /// <returns></returns> protected string GetSign(ValueMode Mode) { string Sign = ""; switch (Mode) { case ValueMode.Add: Sign = "+"; break; case ValueMode.Divide: Sign = "/"; break; case ValueMode.Multiply: Sign = "*"; break; case ValueMode.Subtract: Sign = "-"; break; } return Sign; }
/// <summary> /// Creates a new CSS background size definition. /// </summary> /// <param name="width">The width to use.</param> /// <param name="height">The height to use.</param> public CssBackgroundSizeValue(ICssValue width, ICssValue height) { _width = width; _height = height; _mode = ValueMode.Explicit; }
// each value range is specified by number of bytes it contains protected ValueRange(int bytes, string values) { System.Diagnostics.Debug.Assert(bytes <= 4 && bytes >= 1); if (values.Trim() == "") { mode = ValueMode.Range; switch (bytes) { case 1: minValue = 0x0; maxValue = 0xff; break; case 2: minValue = 0x0; maxValue = 0xffff; break; case 4: minValue = 0x0; maxValue = 0xffffffff; break; } } else if (values.IndexOf(',') != -1 && values.IndexOf('-') == -1) { mode = ValueMode.Values; string[] tokens = values.Split(','); if (tokens.Length == 0) { throw new InvalidValueSpecificationException(values); } vlist = new uint[tokens.Length]; try { for (int i = 0; i < tokens.Length; ++i) { vlist[i] = Convert.ToUInt32(tokens[i]); } } catch (FormatException fe) { throw new InvalidValueSpecificationException(fe.Message); } } else if (values.IndexOf(',') == -1 && values.IndexOf('-') != -1) { mode = ValueMode.Range; string[] tokens = values.Split('-'); if (tokens.Length != 2) { throw new InvalidValueSpecificationException(values); } try { minValue = Convert.ToUInt32(tokens[0]); maxValue = Convert.ToUInt32(tokens[1]); } catch (FormatException fe) { throw new InvalidValueSpecificationException(fe.Message); } if (maxValue < minValue) { throw new InvalidValueSpecificationException(values); } vlist = null; } else if (values.IndexOf(',') == -1 && values.IndexOf('-') == -1) // single value { mode = ValueMode.Values; vlist = new uint[1]; try { vlist[0] = Convert.ToUInt32(values); } catch (FormatException fe) { throw new InvalidValueSpecificationException(fe.Message); } } else if (values.IndexOf(',') != -1 && values.IndexOf('-') != -1) { throw new InvalidValueSpecificationException("Cannot specify both value and range: " + values); } }
public override void OnInspectorGUI() { m_Instance.RunMode = (EffectRunMode)EditorGUILayout.EnumPopup("运行模式:", m_Instance.RunMode); m_Instance.targetType = (LineRenderTargetType)EditorGUILayout.EnumPopup("目标类型:", m_Instance.targetType); if (m_Instance.RunMode == EffectRunMode.Self) { src = EditorGUILayout.ObjectField("源物体:", src, typeof(Transform), true) as Transform; dst = EditorGUILayout.ObjectField("目标物体:", dst, typeof(Transform), true) as Transform; m_Instance.LocalSrcObj = src; m_Instance.LocalDstObj = dst; } m_Instance.UseThickNess = EditorGUILayout.Toggle("使用贴图密度:", m_Instance.UseThickNess); if (m_Instance.UseThickNess) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(ThickNessTexture, true); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } m_Instance.RefDistance = EditorGUILayout.FloatField("贴图密度距离:", m_Instance.RefDistance); } GUI.enabled = !EditorApplication.isPlaying; ValueMode valueMode = (ValueMode)EditorGUILayout.EnumPopup("运算方式:", m_Instance.valueMode); if (valueMode != m_Instance.valueMode) { m_Instance.valueMode = valueMode; } GUI.enabled = true; if (m_Instance.valueMode == ValueMode.Constant) { int vertexCount = EditorGUILayout.IntSlider("顶点数:", m_Instance.VertexCount, 2, 150); if (vertexCount != m_Instance.VertexCount) { m_Instance.VertexCount = vertexCount; m_Instance.useMultiColor = (vertexCount > 2); } if (m_Instance.useMultiColor) { EditorGUILayout.TextField("使用多个顶点时"); EditorGUILayout.TextField("每增加一个顶点"); EditorGUILayout.TextField("渲染量会多一倍"); EditorGUILayout.TextField("仅在需要流动纹理并且两端模糊时使用"); m_Instance.vecStartPoint = EditorGUILayout.Vector3Field("StartPoint:", m_Instance.vecStartPoint); m_Instance.vecEndPoint = EditorGUILayout.Vector3Field("EndPoint:", m_Instance.vecEndPoint); m_Instance.lineWidth = EditorGUILayout.Vector2Field("LineWidth", m_Instance.lineWidth); if (m_Instance.subVectorColor == null || m_Instance.subVectorColor.Length != m_Instance.VertexCount) { m_Instance.subVectorColor = null; m_Instance.subVectorColor = new Effect_LineRender.ColorVertex[m_Instance.VertexCount]; for (int i = 0; i < m_Instance.subVectorColor.Length; i++) { m_Instance.subVectorColor[i].pert = (float)i / (float)(m_Instance.subVectorColor.Length - 1); m_Instance.subVectorColor[i].color = Color.white; } } for (int i = 0; i < m_Instance.subVectorColor.Length; i++) { m_Instance.subVectorColor[i].pert = EditorGUILayout.FloatField("顶点比例(0-1,头0尾1)" + i, m_Instance.subVectorColor[i].pert); m_Instance.subVectorColor[i].color = EditorGUILayout.ColorField("顶点色" + i, m_Instance.subVectorColor[i].color); } if (m_Instance.subVectorColor.Length > 2) { m_Instance.subVectorColor[0].pert = 0.0f; m_Instance.subVectorColor[m_Instance.subVectorColor.Length - 1].pert = 1.0f; } } } if (m_Instance.valueMode == ValueMode.Curve) { m_Instance.VertexCount = EditorGUILayout.IntSlider("顶点数:", m_Instance.VertexCount, 2, 150); EditorGUILayout.BeginVertical("box"); m_Instance.VertexCurve = EditorGUILayout.CurveField("顶点曲线:", m_Instance.VertexCurve); m_Instance.CurveScale = EditorGUILayout.FloatField("曲线缩放:", m_Instance.CurveScale); m_Instance.VertexCurve_X = EditorGUILayout.Toggle("X:", m_Instance.VertexCurve_X); m_Instance.VertexCurve_Y = EditorGUILayout.Toggle("Y:", m_Instance.VertexCurve_Y); m_Instance.VertexCurve_Z = EditorGUILayout.Toggle("Z:", m_Instance.VertexCurve_Z); EditorGUILayout.EndVertical(); } m_Instance.UVScroll = EditorGUILayout.ObjectField("UV流动控制器:", m_Instance.UVScroll, typeof(Effect_UVScroll), true) as Effect_UVScroll; m_Instance.UVTextureAnimator = EditorGUILayout.ObjectField("UV动画控制器:", m_Instance.UVTextureAnimator, typeof(Effect_UVTextureAnimator), true) as Effect_UVTextureAnimator; m_Instance.FadeInOutMaterialFloat = EditorGUILayout.ObjectField("浮点数控制器:", m_Instance.FadeInOutMaterialFloat, typeof(Effect_FadeInOutMaterialFloat), true) as Effect_FadeInOutMaterialFloat; m_Instance.FadeInOutMaterialColor = EditorGUILayout.ObjectField("颜色控制器:", m_Instance.FadeInOutMaterialColor, typeof(Effect_FadeInOutMaterialColor), true) as Effect_FadeInOutMaterialColor; //if (GUILayout.Button("Play")) //{ // m_Instance.Play(); //} //if (GUILayout.Button("Stop")) //{ // m_Instance.Stop(); //} //if (GUILayout.Button("Init")) //{ // m_Instance.Init(); //} if (GUI.changed) { EditorUtility.SetDirty(m_Instance); } }
public FieldValuePair(string Field, object Value, ValueMode Mode) { this.Field = Field; this.Value = Value; this.Mode = Mode; }
public VerifiableMemberContext(VerifiableObjectContext parentContext, VerifiableMemberContract contract, bool directMode) { _parentContext = parentContext; _contract = contract ?? throw new ArgumentNullException(nameof(contract)); _valueMode = directMode ? ValueMode.DirectType : ValueMode.Dictionary; }
public void SetParameter(object instance, ValueMode vmode, ParamMode mode = ParamMode.Value) { GpuParameter.Add(new GpuParamSet(instance, vmode, mode)); }
protected void SetParameter(object instance, ValueMode vmode, ParamMode mode = FunctionBase.ParamMode.Value) { GpuParameter[sellectionIndex].Add(new GpuParamSet(instance, vmode, mode)); }
public GpuParamSet(object instance, ValueMode vmode, ParamMode mode = FunctionBase.ParamMode.Value) { ParamMode = mode; Instance = instance; ValueMode = vmode; }
long ValueFor(int relativePos, ValueMode mode) { return(Read(IndexFor(relativePos, mode))); }