TextureAtom.fromJson constructor
TextureAtom.fromJson(
- Map<String, dynamic> json
)
Implementation
factory TextureAtom.fromJson(Map<String, dynamic> json) {
final ix1 = int.parse(json['ix1']);
final iy1 = int.parse(json['iy1']);
final ix2 = int.parse(json['ix2']);
final iy2 = int.parse(json['iy2']);
final textureName = json['texname'] as String;
final ln = Engine.instance.texture.getTextureByName(textureName)?.len ?? 1;
final hg = Engine.instance.texture.getTextureByName(textureName)?.hgt ?? 1;
final tx1 = ix1 / ln;
final ty1 = iy1 / hg;
final tx2 = ix2 / ln;
final ty2 = iy2 / hg;
final len = (ix1 - ix2).abs();
final hgt = (iy1 - iy2).abs();
final tl = ln;
final th = hg;
return TextureAtom(tx1, ty1, tx2, ty2, textureName, tl, th,
ix1: ix1, iy1: iy1, ix2: ix2, iy2: iy2, len: len, hgt: hgt);
}