// Compiled by ClojureScript 1.9.562 {}
goog.provide('weathergen.wind');
goog.require('cljs.core');
goog.require('goog.string');
goog.require('goog.string.format');
goog.require('hoplon.svg');
goog.require('weathergen.math');
weathergen.wind.barb = (function weathergen$wind$barb(speed){
var pennants = cljs.core.long$.call(null,(speed / (50)));
var speed_SINGLEQUOTE_ = (speed - ((50) * pennants));
var ticks = weathergen.math.clamp.call(null,(((pennants === (0)))?(1):(0)),(100),((speed_SINGLEQUOTE_ / (5)) | (0)));
var full_tails = ((ticks / (2)) | (0));
var half_tail_QMARK_ = cljs.core.odd_QMARK_.call(null,ticks);
var single_half_tail_QMARK_ = (half_tail_QMARK_) && ((full_tails === (0))) && ((pennants === (0)));
var starts_with_tail_QMARK_ = ((pennants === (0))) && ((full_tails > (0)));
var scale = (1);
var offset = 0.1;
var tail_step = 0.16;
var tail_slant = 0.15;
var tail_width = (0.25 * 1.5);
var pennant_base = 0.2;
var pennant_step = 0.25;
var pennant_offset = (pennant_step * pennants);
return hoplon.svg.g.call(null,((starts_with_tail_QMARK_)?hoplon.svg.path.call(null,new cljs.core.Keyword(null,"attr","attr",-604132353),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"class","class",-2030961996),"wind-vector",new cljs.core.Keyword(null,"fill","fill",883462889),"none"], null),new cljs.core.Keyword(null,"d","d",1972142424),goog.string.format("M%f,%f L%f,%f L%f,%f",tail_width,-0.5,(0),(-0.5 + tail_slant),(0),(0.5 - tail_slant))):hoplon.svg.line.call(null,new cljs.core.Keyword(null,"attr","attr",-604132353),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"class","class",-2030961996),"wind-vector"], null),new cljs.core.Keyword(null,"x1","x1",-1863922247),(0),new cljs.core.Keyword(null,"x2","x2",-1362513475),(0),new cljs.core.Keyword(null,"y1","y1",589123466),(0.5 - tail_slant),new cljs.core.Keyword(null,"y2","y2",-718691301),(-0.5 + tail_slant))),hoplon.svg.g.call(null,new cljs.core.Keyword(null,"attr","attr",-604132353),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"class","class",-2030961996),"wind-vector pennant"], null),(function (){var iter__24200__auto__ = ((function (pennants,speed_SINGLEQUOTE_,ticks,full_tails,half_tail_QMARK_,single_half_tail_QMARK_,starts_with_tail_QMARK_,scale,offset,tail_step,tail_slant,tail_width,pennant_base,pennant_step,pennant_offset){
return (function weathergen$wind$barb_$_iter__38449(s__38450){
return (new cljs.core.LazySeq(null,((function (pennants,speed_SINGLEQUOTE_,ticks,full_tails,half_tail_QMARK_,single_half_tail_QMARK_,starts_with_tail_QMARK_,scale,offset,tail_step,tail_slant,tail_width,pennant_base,pennant_step,pennant_offset){
return (function (){
var s__38450__$1 = s__38450;
while(true){
var temp__5278__auto__ = cljs.core.seq.call(null,s__38450__$1);
if(temp__5278__auto__){
var s__38450__$2 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__38450__$2)){
var c__24198__auto__ = cljs.core.chunk_first.call(null,s__38450__$2);
var size__24199__auto__ = cljs.core.count.call(null,c__24198__auto__);
var b__38452 = cljs.core.chunk_buffer.call(null,size__24199__auto__);
if((function (){var i__38451 = (0);
while(true){
if((i__38451 < size__24199__auto__)){
var n = cljs.core._nth.call(null,c__24198__auto__,i__38451);
cljs.core.chunk_append.call(null,b__38452,hoplon.svg.path.call(null,new cljs.core.Keyword(null,"attr","attr",-604132353),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"fill","fill",883462889),"black"], null),new cljs.core.Keyword(null,"d","d",1972142424),goog.string.format("M%f,%f L%f,%f L%f,%f Z",(0),(-0.5 + (pennant_step * n)),tail_width,(-0.5 + (pennant_step * n)),(0),((-0.5 + (pennant_step * n)) + pennant_base))));

var G__38457 = (i__38451 + (1));
i__38451 = G__38457;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__38452),weathergen$wind$barb_$_iter__38449.call(null,cljs.core.chunk_rest.call(null,s__38450__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__38452),null);
}
} else {
var n = cljs.core.first.call(null,s__38450__$2);
return cljs.core.cons.call(null,hoplon.svg.path.call(null,new cljs.core.Keyword(null,"attr","attr",-604132353),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"fill","fill",883462889),"black"], null),new cljs.core.Keyword(null,"d","d",1972142424),goog.string.format("M%f,%f L%f,%f L%f,%f Z",(0),(-0.5 + (pennant_step * n)),tail_width,(-0.5 + (pennant_step * n)),(0),((-0.5 + (pennant_step * n)) + pennant_base))),weathergen$wind$barb_$_iter__38449.call(null,cljs.core.rest.call(null,s__38450__$2)));
}
} else {
return null;
}
break;
}
});})(pennants,speed_SINGLEQUOTE_,ticks,full_tails,half_tail_QMARK_,single_half_tail_QMARK_,starts_with_tail_QMARK_,scale,offset,tail_step,tail_slant,tail_width,pennant_base,pennant_step,pennant_offset))
,null,null));
});})(pennants,speed_SINGLEQUOTE_,ticks,full_tails,half_tail_QMARK_,single_half_tail_QMARK_,starts_with_tail_QMARK_,scale,offset,tail_step,tail_slant,tail_width,pennant_base,pennant_step,pennant_offset))
;
return iter__24200__auto__.call(null,cljs.core.range.call(null,pennants));
})()),hoplon.svg.g.call(null,new cljs.core.Keyword(null,"attr","attr",-604132353),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"class","class",-2030961996),"wind-vector full-tail"], null),(function (){var iter__24200__auto__ = ((function (pennants,speed_SINGLEQUOTE_,ticks,full_tails,half_tail_QMARK_,single_half_tail_QMARK_,starts_with_tail_QMARK_,scale,offset,tail_step,tail_slant,tail_width,pennant_base,pennant_step,pennant_offset){
return (function weathergen$wind$barb_$_iter__38453(s__38454){
return (new cljs.core.LazySeq(null,((function (pennants,speed_SINGLEQUOTE_,ticks,full_tails,half_tail_QMARK_,single_half_tail_QMARK_,starts_with_tail_QMARK_,scale,offset,tail_step,tail_slant,tail_width,pennant_base,pennant_step,pennant_offset){
return (function (){
var s__38454__$1 = s__38454;
while(true){
var temp__5278__auto__ = cljs.core.seq.call(null,s__38454__$1);
if(temp__5278__auto__){
var s__38454__$2 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__38454__$2)){
var c__24198__auto__ = cljs.core.chunk_first.call(null,s__38454__$2);
var size__24199__auto__ = cljs.core.count.call(null,c__24198__auto__);
var b__38456 = cljs.core.chunk_buffer.call(null,size__24199__auto__);
if((function (){var i__38455 = (0);
while(true){
if((i__38455 < size__24199__auto__)){
var n = cljs.core._nth.call(null,c__24198__auto__,i__38455);
cljs.core.chunk_append.call(null,b__38456,hoplon.svg.line.call(null,new cljs.core.Keyword(null,"x1","x1",-1863922247),(0),new cljs.core.Keyword(null,"y1","y1",589123466),(((-0.5 + tail_slant) + pennant_offset) + (tail_step * n)),new cljs.core.Keyword(null,"x2","x2",-1362513475),tail_width,new cljs.core.Keyword(null,"y2","y2",-718691301),((-0.5 + pennant_offset) + (tail_step * n))));

var G__38458 = (i__38455 + (1));
i__38455 = G__38458;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__38456),weathergen$wind$barb_$_iter__38453.call(null,cljs.core.chunk_rest.call(null,s__38454__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__38456),null);
}
} else {
var n = cljs.core.first.call(null,s__38454__$2);
return cljs.core.cons.call(null,hoplon.svg.line.call(null,new cljs.core.Keyword(null,"x1","x1",-1863922247),(0),new cljs.core.Keyword(null,"y1","y1",589123466),(((-0.5 + tail_slant) + pennant_offset) + (tail_step * n)),new cljs.core.Keyword(null,"x2","x2",-1362513475),tail_width,new cljs.core.Keyword(null,"y2","y2",-718691301),((-0.5 + pennant_offset) + (tail_step * n))),weathergen$wind$barb_$_iter__38453.call(null,cljs.core.rest.call(null,s__38454__$2)));
}
} else {
return null;
}
break;
}
});})(pennants,speed_SINGLEQUOTE_,ticks,full_tails,half_tail_QMARK_,single_half_tail_QMARK_,starts_with_tail_QMARK_,scale,offset,tail_step,tail_slant,tail_width,pennant_base,pennant_step,pennant_offset))
,null,null));
});})(pennants,speed_SINGLEQUOTE_,ticks,full_tails,half_tail_QMARK_,single_half_tail_QMARK_,starts_with_tail_QMARK_,scale,offset,tail_step,tail_slant,tail_width,pennant_base,pennant_step,pennant_offset))
;
return iter__24200__auto__.call(null,cljs.core.range.call(null,((starts_with_tail_QMARK_)?(1):(0)),full_tails));
})()),((half_tail_QMARK_)?(function (){var length = 0.6;
return hoplon.svg.line.call(null,new cljs.core.Keyword(null,"attr","attr",-604132353),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"class","class",-2030961996),"wind-vector half-tail"], null),new cljs.core.Keyword(null,"x1","x1",-1863922247),(0),new cljs.core.Keyword(null,"y1","y1",589123466),(((-0.5 + tail_slant) + pennant_offset) + (tail_step * (full_tails + ((single_half_tail_QMARK_)?1.5:(0))))),new cljs.core.Keyword(null,"x2","x2",-1362513475),(tail_width * length),new cljs.core.Keyword(null,"y2","y2",-718691301),(((-0.5 + (tail_slant * ((1) - length))) + pennant_offset) + (tail_step * (full_tails + ((single_half_tail_QMARK_)?1.5:(0))))));
})():null));
});
