mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Since we've got a vector class, and it has a getter for the magnitude, why not also a getter for the angle.
23 lines
810 B
Dart
23 lines
810 B
Dart
// Copyright 2018 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'dart:ui';
|
|
import 'dart:math' show pi;
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
test('Offset.direction', () {
|
|
expect(const Offset(0.0, 0.0).direction, 0.0);
|
|
expect(const Offset(0.0, 1.0).direction, pi / 2.0);
|
|
expect(const Offset(0.0, -1.0).direction, -pi / 2.0);
|
|
expect(const Offset(1.0, 0.0).direction, 0.0);
|
|
expect(const Offset(1.0, 1.0).direction, pi / 4.0);
|
|
expect(const Offset(1.0, -1.0).direction, -pi / 4.0);
|
|
expect(const Offset(-1.0, 0.0).direction, pi);
|
|
expect(const Offset(-1.0, 1.0).direction, pi * 3.0 / 4.0);
|
|
expect(const Offset(-1.0, -1.0).direction, -pi * 3.0 / 4.0);
|
|
});
|
|
}
|