// Compiled by ClojureScript 1.10.520 {}
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__4523__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__34996(s__34997){
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__34997__$1 = s__34997;
while(true){
var temp__5720__auto__ = cljs.core.seq.call(null,s__34997__$1);
if(temp__5720__auto__){
var s__34997__$2 = temp__5720__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__34997__$2)){
var c__4521__auto__ = cljs.core.chunk_first.call(null,s__34997__$2);
var size__4522__auto__ = cljs.core.count.call(null,c__4521__auto__);
var b__34999 = cljs.core.chunk_buffer.call(null,size__4522__auto__);
if((function (){var i__34998 = (0);
while(true){
if((i__34998 < size__4522__auto__)){
var n = cljs.core._nth.call(null,c__4521__auto__,i__34998);
cljs.core.chunk_append.call(null,b__34999,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__35004 = (i__34998 + (1));
i__34998 = G__35004;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__34999),weathergen$wind$barb_$_iter__34996.call(null,cljs.core.chunk_rest.call(null,s__34997__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__34999),null);
}
} else {
var n = cljs.core.first.call(null,s__34997__$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__34996.call(null,cljs.core.rest.call(null,s__34997__$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__4523__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__4523__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__35000(s__35001){
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__35001__$1 = s__35001;
while(true){
var temp__5720__auto__ = cljs.core.seq.call(null,s__35001__$1);
if(temp__5720__auto__){
var s__35001__$2 = temp__5720__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__35001__$2)){
var c__4521__auto__ = cljs.core.chunk_first.call(null,s__35001__$2);
var size__4522__auto__ = cljs.core.count.call(null,c__4521__auto__);
var b__35003 = cljs.core.chunk_buffer.call(null,size__4522__auto__);
if((function (){var i__35002 = (0);
while(true){
if((i__35002 < size__4522__auto__)){
var n = cljs.core._nth.call(null,c__4521__auto__,i__35002);
cljs.core.chunk_append.call(null,b__35003,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__35005 = (i__35002 + (1));
i__35002 = G__35005;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__35003),weathergen$wind$barb_$_iter__35000.call(null,cljs.core.chunk_rest.call(null,s__35001__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__35003),null);
}
} else {
var n = cljs.core.first.call(null,s__35001__$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__35000.call(null,cljs.core.rest.call(null,s__35001__$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__4523__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));
});
