aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2016-05-11 22:21:23 +0200
committerBjörn-Egil Dahlberg <[email protected]>2016-05-11 22:21:23 +0200
commitc57ea89a4f53f78dd42b0fdfba73454ab5792302 (patch)
tree59aeb0ff49d1015c30f6f09e243181b3a1c3c884
parent715876f5e6d40bc75ad8f3e6c4c70249aea0fc66 (diff)
downloadotp-c57ea89a4f53f78dd42b0fdfba73454ab5792302.tar.gz
otp-c57ea89a4f53f78dd42b0fdfba73454ab5792302.tar.bz2
otp-c57ea89a4f53f78dd42b0fdfba73454ab5792302.zip
egd: Improve span calculation
-rw-r--r--lib/percept/src/egd_primitives.erl16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/percept/src/egd_primitives.erl b/lib/percept/src/egd_primitives.erl
index 7b6e15efe7..14c8c3506d 100644
--- a/lib/percept/src/egd_primitives.erl
+++ b/lib/percept/src/egd_primitives.erl
@@ -411,15 +411,17 @@ point_side(_) -> on_line.
%% AUX
-span(Points) ->
- Xs = [TX||{TX, _} <- Points],
- Ys = [TY||{_, TY} <- Points],
- Xmin = lists:min(Xs),
- Xmax = lists:max(Xs),
- Ymin = lists:min(Ys),
- Ymax = lists:max(Ys),
+span([{X0,Y0}|Points]) ->
+ span(Points,X0,Y0,X0,Y0).
+span([{X0,Y0}|Points],Xmin,Ymin,Xmax,Ymax) ->
+ span(Points,erlang:min(Xmin,X0),
+ erlang:min(Ymin,Y0),
+ erlang:max(Xmax,X0),
+ erlang:max(Ymax,Y0));
+span([],Xmin,Ymin,Xmax,Ymax) ->
{Xmin,Ymin,Xmax,Ymax}.
+
rgb_float2byte({R,G,B}) -> rgb_float2byte({R,G,B,1.0});
rgb_float2byte({R,G,B,A}) ->
{trunc(R*255), trunc(G*255), trunc(B*255), trunc(A*255)}.