Formulas 式

There are many situations where formulas can be used in Rainmeter to arrive at a numerical result. These might be things like:数値結果を得るためにRainmeterで式を使用できる状況はたくさんあります。これらは次のようなものかもしれません:

  • In a Calc measure: Formula=(2.5 + 100) * 2Calcメジャーでは: Formula=(2.5 + 100) * 2
  • In an IFCondition option value: IfCondition=MeasureName > (2.5 + 100) * 2IFConditionオプション値では、次のようになります。 IfCondition=MeasureName > (2.5 + 100) * 2
  • In a numeric meter or measure option value: W=((2.5 + 100) * 2)数値メーターまたは数値データオプションの値の場合: W=((2.5 + 100) * 2)
  • As a numeric part of an option value: FontColor=(255 * 0.5),255,255,255オプション値の数値部分として: FontColor=(255 * 0.5),255,255,255
  • In a Bang: LeftMouseUpAction=[!SetOption SomeMeter W "((2.5 + 100) * 2)"]強打で: LeftMouseUpAction=[!SetOption SomeMeter W "((2.5 + 100) * 2)"]

There are a few place where formulas are not allowed. These are primarily places where the option value is assumed to be a string and only a string. In those cases, the characters used in a formula are treated as any other string character. A few examples are:数式が許可されていない場所がいくつかあります。これらは主に、オプション値が文字列であり、文字列のみであると見なされる場所です。そのような場合、式で使用されている文字は他の文字列文字として扱われます。いくつか例を挙げます。

  • The Text option of a String meter.Textストリングメーターのオプション。
  • The String option of a String measure.String文字列メジャーのオプション。
  • The RegExp option of a WebParser measure.RegExpWebParserメジャーのオプション。
  • IfMatch options.IfMatch オプション
  • TootipText or TooltipTitle options.TootipTextまたはTooltipTitleオプション。

While formulas can be used in the [Variables] section of a skin, be aware that the [Variables] section itself does not resolve the formula. If you have a variable MyVar=(5 * 2), then the value of #MyVar# is not "10", but literally "(5 * 2)". However, if you then use the variable in an option that does allow formulas, that option itself will do the math, as in X=#MyVar# in a meter.式はスキンの[Variables]セクションで使用できますが、[Variables]セクション自体は式を解決しないことに注意してください。変数がある場合MyVar=(5 * 2)、#MyVar#の値は "10"ではなく、文字通り "(5 * 2)"です。ただし、数式を許可するオプションで変数を使用するX=#MyVar#と、メーターの場合と同様に、そのオプション自体が計算されます。

Mathematical formulas must be entirely enclosed in (parentheses) to alert Rainmeter that it is a formula, unless they are being used in the Formula option of a Calc measure or in a IfCondition option, where the function is always assumed to be a formula, and the enclosing parentheses are optional.それらがCalcメジャーのFormulaオプションまたはIfConditionオプションで使用されていない限り、数式がその式であることをRainmeterに警告するために、数式は完全に(括弧)で囲む必要があります。囲む括弧はオプションです。

Note: While [Measures], [SectionVariables:] and #Variables# can be used in a formula, all the components of a formula must be numeric, using only numbers, operators, functions and constants. Using .5 or .25 in a formula will cause an error. It must be 0.5 or 0.25.注: [Measures]、[SectionVariables:]、および#Variables#は数式で使用できますが、数式のすべての構成要素は、数値、演算子、関数、および定数のみを使用して数値である必要があります。式に.5または.25を使用するとエラーが発生します。0.5または0.25でなければなりません。

Formula Syntax式の構文

Operatorsオペレータ

  • +: Addition+:加算
  • -: Subtraction-:減算
  • *: Multiplication*:掛け算
  • /: Division/部署
  • **: Power**: 力
  • %: Remainder or modulus%:余りまたは係数
  • &: Bitwise and&:ビットワイズと
  • |: Bitwise or|:ビット単位または
  • ^: Bitwise xor^:ビットごとのxor
  • ~: Bitwise not~:ビットごとではない

Logical Operators論理演算子

  • <>: Not equal<>:等しくない
  • =: Equal to=: に等しい
  • >: Greater than>より大
  • <: Less than<: 未満
  • <=: Less than or equal to<=:以下
  • >=: Greater than or equal to>=: 以上
  • &&: Logical and&&:論理的な
  • ||: Logical or||:論理的または

Note: Conditional statements using logical operators evaluate to 1 or 0 (true / false).注:論理演算子を使用した条件付きステートメントは、1または0に評価されます(true / false)。

Functions関数

  • Cos(x): The cosine of an angle of x radians.Cos(x)xラジアンの角度の余弦。
  • Sin(x): The sine of an angle of x radians.Sin(x)xラジアンの角度のサイン。
  • Tan(x): The tangent of an angle of x radians.Tan(x)xラジアンの角度の正接。
  • Acos(x): The principal arc cosine of x, in the interval [0,PI] radians. The value of x is between -1 and 1.Acos(x):[0、PI]ラジアンの範囲のxの主アークコサイン。xの値は-1から1の間です。
  • Asin(x): The principal arc sine of x, in the interval [-PI/2,+PI/2] radians. The value of x is between -1 and 1.Asin(x)xの主アークサイン(区間[-PI / 2、+ PI / 2]ラジアン)。xの値は-1から1の間です。
  • Atan(x): The principal arc tangent of x, in the interval [-PI/2,+PI/2] radians.Atan(x):[-PI / 2、+ PI / 2]ラジアンの範囲のxの主アークタンジェント。
  • Atan2(y, x): The principal arc tangent in the interval [-PI,+PI] radians between points y and x in the Cartesian plane. The sign of the elements determines the quadrant.Atan2(y, x):デカルト平面の点yxの間の[-PI、+ PI]ラジアンの間隔の主弧の接線。要素の符号が象限を決定します。
  • Rad(x): Converts x degrees to radians.Rad(x)x度をラジアンに変換します。
  • Deg(x): Converts x radians to degrees.Deg(x)xラジアンを度に変換します。
  • Abs(x): Absolute value of x.Abs(x):の絶対値のx
  • Neg(x): Negative value of x.Neg(x):負の値のx
  • Exp(x): Returns ex.Exp(x)e xを返します。
  • Log(x): Base 10 logarithm of x.Log(x)xの 10を底とする対数。
  • Ln(x): Natural logarithm of x.Ln(x):自然対数のx
  • Sqrt(x): Square root of x.Sqrt(x):の平方根のx
  • Sgn(x): Return 1 if x is positive, -1 if x is negative, or 0 if x is zero.Sgn(x):xが正の場合は1、xが負の場合は-1、xがゼロの場合は0を返します。
  • Frac(x): Fractional, or decimal, part of x. (e.g. frac(1.234) = 0.234)Frac(x)xの小数部、または小数部。(例:frac(1.234)= 0.234)
  • Trunc(x): Integer part of x. (e.g. trunc(1.234) = 1)Trunc(x):の整数部分のx。(例:trunc(1.234)= 1)
  • Floor(x): Floor of x.Floor(x):の床のx
  • Ceil(x): Ceiling of x.Ceil(x):の天井のx
  • Min(x, y): Minimum of x and y.Min(x, y):最小のxyの
  • Max(x, y): Maximum of x and y.Max(x, y):最大xy
  • Clamp(x, low, high): Restricts value x to low and high limits.Clamp(x, low, high):値制限X低い及び高い限界を。
  • Round(x, precision): Rounds x to an integer, or to a specified number of decimal places. precision is optional.Round(x, precision)xを整数または指定された小数桁数に丸めます。精度はオプションです。

Constants定数

  • PI: Mathematical constant Pi (~3.14159265...).PI:数学定数Pi(〜3.14159265 ...)
  • E: Mathematical constant e (~2.71828182...).E:数学定数e(〜2.71828182 ...)

Conditional Operations条件付き操作

<condition> ? <expr. if true.> : <expr. if false.>

This will evaluate condition as being either true or false. If it is true, the expression to the left of the colon (:) is evaluated. If it is false, the expression to the right is evaluated. This is equivalent to the following if-then-else statement:これは、条件を真または偽として評価します。それが真であれば、コロン(:)の左側の式が評価されます。それが偽であれば、右側の式が評価されます。これは、次のif-then-else文と同じです。

if (condition)
then
expr. if true
else
expr. if false
end if
[Measure]
Measure=Calc
Formula=5

[Meter]
Meter=String
X=([Measure] < 6 ? 0 : 10)
DynamicVariables=1

The meter would be positioned at X=0 since the condition [Measure] < 6 evaluates to true.X=0条件[Measure] < 6が真と評価されるので、メーターはに位置付けられます。

Conditional operators can be nested. It should be noted that there is a maximum of 30 nested operators.条件演算子はネストできます。最大30のネストした演算子があることに注意してください。

[Measure]
Measure=Calc
Formula=2

[Meter]
Meter=String
X=([Measure] < 1 ? 99 : ([Measure] < 2 ? 98 : ([Measure] < 3 ? 97 : 96)))
DynamicVariables=1

The meter would be positioned at X=97. Since the first statement of [Measure] < 1 is false, the formula begins testing the nested formulas in order until the condition becomes true . If none of the conditions are met, the final false value of 96 would be set.メーターはに配置されX=97ます。の最初のステートメント[Measure] < 1は偽なので、式は条件が真になるまでネストした式のテストを順番に開始します。いずれの条件も満たされていない場合は、96の最終偽値が設定されます。

関連記事

スポンサーリンク

擬似要素を含む要素に後続する要素の内容物が左右にはみ出る

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る