Skip to content

Instantly share code, notes, and snippets.

@bjorng
Created July 25, 2009 18:50
Show Gist options
  • Save bjorng/154857 to your computer and use it in GitHub Desktop.
Save bjorng/154857 to your computer and use it in GitHub Desktop.
colorBlur(#we{es=Etab}=We) ->
L0 = array:sparse_foldl(
fun(E, #edge{vs=Va,ve=Vb}, A) ->
Left0 = wings_va:edge_attrs(E, left, We),
Right0 = wings_va:edge_attrs(E, right, We),
Left = def_color(wings_va:attr(color, Left0)),
Right = def_color(wings_va:attr(color, Right0)),
[{Va,Left},{Va,Right},{Vb,Left},{Vb,Right}|A]
end, [], Etab),
[{V,Color}|L] = lists:sort(L0),
colorBlur_1(L, V, [Color], We).
colorBlur_1([{V,Col}|T], V, ColAcc, We) ->
colorBlur_1(T, V, [Col|ColAcc], We);
colorBlur_1([{V,Col}|T], PrevV, ColAcc, We0) ->
Color = wings_color:average(ColAcc),
We = wings_va:set_vertex_color(gb_sets:singleton(PrevV), Color, We0),
colorBlur_1(T, V, [Col], We);
colorBlur_1([], PrevV, ColAcc, We) ->
Color = wings_color:average(ColAcc),
wings_va:set_vertex_color(gb_sets:singleton(PrevV), Color, We).
def_color(none) -> {1.0,1.0,1.0};
def_color(Color) -> Color.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment