fix sprite rect width
This commit is contained in:
parent
b83a670e4d
commit
8b8ae416be
|
@ -19,7 +19,7 @@ let make ~texture ~pdf ~x ~y ~w ~h ~ox ~oy =
|
||||||
and ox0 = Float.of_int (x - ox)
|
and ox0 = Float.of_int (x - ox)
|
||||||
and oy0 = Float.of_int (y - oy)
|
and oy0 = Float.of_int (y - oy)
|
||||||
and ox1 = Float.of_int (x - ox + w)
|
and ox1 = Float.of_int (x - ox + w)
|
||||||
and oy1 = Float.of_int (y - oy + w)
|
and oy1 = Float.of_int (y - oy + h)
|
||||||
in {
|
in {
|
||||||
texture;
|
texture;
|
||||||
clip = aabb x0 y0 x1 y1;
|
clip = aabb x0 y0 x1 y1;
|
||||||
|
@ -61,10 +61,13 @@ let parse_sprite ~map ~texture ~pdf = function
|
||||||
| sexp ->
|
| sexp ->
|
||||||
Sexp_conv.of_sexp_error "invalid sprite" sexp
|
Sexp_conv.of_sexp_error "invalid sprite" sexp
|
||||||
|
|
||||||
let of_sexp ~texture ?(dpi = 96) = function
|
let of_sexp ~texture ?dpi = function
|
||||||
| Sexp.List (Atom "map" :: sprite_args) ->
|
| Sexp.List (Atom "map" :: sprite_args) ->
|
||||||
let map = Hashtbl.create (List.length sprite_args * 2) in
|
let map = Hashtbl.create (List.length sprite_args * 2) in
|
||||||
let pdf = Float.of_int dpi /. 96.0 in
|
let pdf = match dpi with
|
||||||
|
| Some dpi -> Float.of_int dpi /. 96.0
|
||||||
|
| None -> 1.0
|
||||||
|
in
|
||||||
List.iter (parse_sprite ~map ~texture ~pdf) sprite_args;
|
List.iter (parse_sprite ~map ~texture ~pdf) sprite_args;
|
||||||
map
|
map
|
||||||
| sexp ->
|
| sexp ->
|
||||||
|
|
Loading…
Reference in New Issue