Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:math
dart:math
description

dart:math library

Mathematical constants and functions, plus a random number generator.

To use this library in your code:

import 'dart:math';

Random

Random is a generator ofbool,int ordouble values.

var intValue = Random().nextInt(10); // Value is >= 0 and < 10.var doubleValue = Random().nextDouble(); // Value is >= 0.0 and < 1.0.var boolValue = Random().nextBool(); // true or false, with equal chance.

Point

Point is a utility class for representing two-dimensional positions.

var leftTop = const Point(0, 0);var rightBottom = const Point(200, 400);

Rectangle

Rectangle is a class for representing two-dimensional axis-alignedrectangles whose properties are immutable.

Create a rectangle spanned by the points.

var leftTop = const Point(20, 50);var rightBottom = const Point(300, 600);var rectangle = Rectangle.fromPoints(leftTop, rightBottom);print(rectangle.left); // 20print(rectangle.top); // 50print(rectangle.right); // 300print(rectangle.bottom); // 600

Create a rectangle spanned by(left, top) and(left+width, top+height).

var rectangle = const Rectangle(20, 50, 300, 600);print(rectangle.left); // 20print(rectangle.top); // 50print(rectangle.right); // 320print(rectangle.bottom); // 650

MutableRectangle

MutableRectangle is a class for representing two-dimensional axis-alignedrectangles with mutable properties.

Create a mutable rectangle spanned by(left, top) and(left+width, top+height).

var rectangle = MutableRectangle(20, 50, 300, 600);print(rectangle); // Rectangle (20, 50) 300 x 600print(rectangle.left); // 20print(rectangle.top); // 50print(rectangle.right); // 320print(rectangle.bottom); // 650// Change rectangle width and height.rectangle.width = 200;rectangle.height = 100;print(rectangle); // Rectangle (20, 50) 200 x 100print(rectangle.left); // 20print(rectangle.top); // 50print(rectangle.right); // 220print(rectangle.bottom); // 150

Classes

MutableRectangle<T extendsnum>
A class for representing two-dimensional axis-aligned rectangles withmutable properties.
Point<T extendsnum>
A utility class for representing two-dimensional positions.
Random
A generator of random bool, int, or double values.
Rectangle<T extendsnum>
A class for representing two-dimensional rectangles whose properties areimmutable.

Constants

e→ constdouble
Base of the natural logarithms.
ln10→ constdouble
Natural logarithm of 10.
ln2→ constdouble
Natural logarithm of 2.
log10e→ constdouble
Base-10 logarithm ofe.
log2e→ constdouble
Base-2 logarithm ofe.
pi→ constdouble
The PI constant.
sqrt1_2→ constdouble
Square root of 1/2.
sqrt2→ constdouble
Square root of 2.

Functions

acos(numx)double
Convertsx to adouble and returns its arc cosine in radians.
asin(numx)double
Convertsx to adouble and returns its arc sine in radians.
atan(numx)double
Convertsx to adouble and returns its arc tangent in radians.
atan2(numa,numb)double
A variant ofatan.
cos(numradians)double
Convertsradians to adouble and returns the cosine of the value.
exp(numx)double
Convertsx to adouble and returns the natural exponent,e,to the powerx.
log(numx)double
Convertsx to adouble and returns the natural logarithm of the value.
max<T extendsnum>(Ta,Tb)→ T
Returns the larger of two numbers.
min<T extendsnum>(Ta,Tb)→ T
Returns the lesser of two numbers.
pow(numx,numexponent)num
Returnsx to the power ofexponent.
sin(numradians)double
Convertsradians to adouble and returns the sine of the value.
sqrt(numx)double
Convertsx to adouble and returns the positive square root of thevalue.
tan(numradians)double
Convertsradians to adouble and returns the tangent of the value.
  1. Dart
  2. dart:math
DartSDK
  1. Libraries
  2. Core
  3. dart:async
  4. dart:collection
  5. dart:convert
  6. dart:core
  7. dart:developer
  8. dart:math
  9. dart:typed_data
  10. VM
  11. dart:ffi
  12. dart:io
  13. dart:isolate
  14. dart:mirrors
  15. Web
  16. package:webopen_in_new
  17. dart:js_interop
  18. dart:js_interop_unsafe
  19. Web (Legacy)
  20. dart:html
  21. dart:indexed_db
  22. dart:js
  23. dart:js_util
  24. dart:svg
  25. dart:web_audio
  26. dart:web_gl
dart:math library

[8]ページ先頭

©2009-2025 Movatter.jp