42 lines
1.1 KiB
Dart

import 'dart:ffi';
import 'package:ffi/ffi.dart';
import 'package:segmentation_douglas_peucker_flutter/dotnet_exception.dart';
import 'package:segmentation_douglas_peucker_flutter/gen/generated_bindings.dart';
import 'package:segmentation_douglas_peucker_flutter/lib.dart';
class DaliPoint {
final int x;
final int y;
const DaliPoint(this.x, this.y);
factory DaliPoint.fromPointer(Pointer<Void> pointer) {
final NativeLibrary nativeLibrary = NativeLibrary(Lib.shared);
final Pointer<System_Exception_t> exception = calloc();
final x = nativeLibrary.System_Drawing_Point_X_Get(pointer, exception);
exception.handle();
final y = nativeLibrary.System_Drawing_Point_Y_Get(pointer, exception);
exception.handle();
return DaliPoint(x, y);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is DaliPoint &&
runtimeType == other.runtimeType &&
x == other.x &&
y == other.y;
@override
int get hashCode => x.hashCode ^ y.hashCode;
@override
String toString() {
return 'DaliPoint{x: $x, y: $y}';
}
}