\startcomponent 5-loops-broad-graph

\project proj_fingerlooping
\product prd_manuscript

\setupMPinstance
 [metafun]
 [textstyle=sans]


\startMPinclusions

patternsize:= 20mm;

def lhl(expr ca,cb,sx,sy) =
    picture lefthandloop;
    lefthandloop := image (
        path p, q, r ;
        p := fullcircle scaled 4mm ;
        q := p shifted (0mm,10mm) ;
        r := center p .. (5mm,5mm) .. center q ;
        r := r cutbefore (p intersectionpoint r) cutafter (q
intersectionpoint r) ;

        draw r withpen pencircle scaled 0.2mm withcolor black ; % the connecting curve
        fill p withcolor ca;
        draw p withpen pencircle scaled 0.2mm withcolor black ; % upper shank
        fill q withcolor cb;
        draw q withpen pencircle scaled 0.2mm withcolor black ; % lower shank
        );
    draw lefthandloop shifted (sx*patternsize,sy*patternsize);
enddef;

path s, t, u ;

s := fullcircle scaled 4mm shifted (4mm,0mm);
t := s shifted (0mm,10mm) ;
u := center s .. (0mm,8mm) .. center t ;

u := u cutbefore (s intersectionpoint u) cutafter (t intersectionpoint u) ;



def lbl(expr sx,sy) =
    picture leftblank;
    leftblank := image (
        draw r withpen pencircle scaled 0.2mm withcolor .6white ; % the connecting curve
        fill p withcolor .8white;
        draw p withpen pencircle scaled 0.2mm withcolor .6white ; % upper shank
        fill q withcolor .8white;
        draw q withpen pencircle scaled 0.2mm withcolor .6white ; % lower shank
        );
    draw leftblank shifted (sx*patternsize,sy*patternsize);
enddef;

def rhl(expr ca,cb,sx,sy) =
    picture righthandloop;
    	righthandloop := image (
		draw u withpen pencircle scaled 0.2mm withcolor black ;
		fill s withcolor ca ;
		draw s withpen pencircle scaled 0.2mm withcolor black ;
		fill t withcolor cb ;
		draw t withpen pencircle scaled 0.2mm withcolor black ;
		);
    draw righthandloop shifted (sx*patternsize,sy*patternsize);
enddef;


def rbl(expr sx,sy) =
    picture rightblank;
    rightblank := image (

	path s, t, u ;

	s := fullcircle scaled 4mm shifted (4mm,0mm);
	t := s shifted (0mm,10mm) ;
	u := center s .. (0mm,8mm) .. center t ;

   	u := u cutbefore (s intersectionpoint u) cutafter (t intersectionpoint u) ;


    	draw u withpen pencircle scaled 0.2mm withcolor .6white ; % the connecting curve
    	fill s withcolor .8white;
    	draw s withpen pencircle scaled 0.2mm withcolor .6white ; % upper shank
    	fill t withcolor .8white;
    	draw t withpen pencircle scaled 0.2mm withcolor .6white ; % lower shank
        );
    draw rightblank shifted (sx*patternsize,sy*patternsize);
enddef;

% picture labels ;
% labels :=
% 	image (
% 	draw textext("La") shifted (-.8cm,6.5cm) ;
% 	draw textext("Lb") shifted (-.8cm,4.5cm) ;
% 	draw textext("Lc") shifted (-.8cm,2.5cm) ;
% 	draw textext("Ld") shifted (-.8cm,0.5cm) ;
% 
% 	draw textext("Ra") shifted (3.2cm,6.5cm) ;
% 	draw textext("Rb") shifted (3.2cm,4.5cm) ;
% 	draw textext("Rc") shifted (3.2cm,2.5cm) ;
% 	draw textext("Rd") shifted (3.2cm,0.5cm) ;
% 
% 	draw textext("left") shifted (0cm,-.8cm) ;
% 	draw textext("right") shifted (2.5cm,-.8cm) ;
% 	) ;

picture grid ;
grid :=
	image (
		width := 9cm ;
		height := 7cm ;
		unit := cm ;
		draw vlingrid (0, width/unit, 1/10, width, height) withcolor .6white ; 
		draw hlingrid (0, height/unit, 1/10, height, width) withcolor .6white ;
		draw vlingrid (0, width/unit, 1/2, width, height) withcolor .4blue ; 
		draw hlingrid (0, height/unit, 1/2, height, width) withcolor .4blue ;
		draw vlingrid (0, width/unit, 1, width, height) withcolor .6red ;
		draw hlingrid (0, height/unit, 1, height, width ) withcolor .6red ;
	) ;

% first pickup arrow
picture pfirst ;
pfirst :=
	image (
	drawarrow (1.8cm,6.5cm) .. (1.8cm,6.0cm) .. (2.4cm,5.5cm) .. (2.8cm,5cm) .. (1.8cm,4.2cm) .. (0.8cm,2.0cm) .. (0.3cm,2.0cm)
			withpen pencircle scaled .6mm withcolor blue;
	) ;


% second pickup arrow
picture psecond ;
	psecond :=
		image (
		drawarrow (0.6cm,6.5cm) .. (1.0cm,5.6cm) .. (0.6cm,4.7cm)
				withpen pencircle scaled .6mm withcolor blue;
		drawarrow (0.6cm,4.3cm) .. (1.0cm,3.4cm) .. (0.6cm,2.5cm)
						withpen pencircle scaled .6mm withcolor blue;
		) ;


% arrow to go before action and result
picture btwarrow ;
	btwarrow :=
		image(
		drawarrow (3.5cm,3.5cm) ... (5cm,3.5cm) withpen pencircle scaled .6mm withcolor black;
%		label.top (btex you get etex,(3.5cm,3.5cm)) ;
		) ;


\stopMPinclusions


\setupframed[offset=.5cm]

\starttext



% Loops: syntax for coloured 'color top, color bottom, loc x, loc y'; for blank only 'loc x, loc y'

\startbuffer[setup 5-loop basic]



\startMPcode

%draw grid ; %grid for debugging arrows

%SETUP


		lhl	(yellow,red,0,3);
		lhl	(yellow,red,0,2);
		lhl	(yellow,red,0,1);
		lbl	(0,0);
		rbl	(1,3);
		rhl	(red,yellow,1,2);
		rhl	(red,yellow,1,1);
		rbl(1,0);
		

draw textext("La") shifted (-.8cm,6.5cm) ;
draw textext("Lb") shifted (-.8cm,4.5cm) ;
draw textext("Lc") shifted (-.8cm,2.5cm) ;
draw textext("Ld") shifted (-.8cm,0.5cm) ;

draw textext("Ra") shifted (3.2cm,6.5cm) ;
draw textext("Rb") shifted (3.2cm,4.5cm) ;
draw textext("Rc") shifted (3.2cm,2.5cm) ;
draw textext("Rd") shifted (3.2cm,0.5cm) ;

draw textext("left") shifted (0cm,-.8cm) ;
draw textext("right") shifted (2.5cm,-.8cm) ;
		
\stopMPcode
\stopbuffer

\startbuffer[1st step 5-loop broad]
% FIRST PICKUP (Ra picks up Lcl)

\startMPcode

%draw grid ; %grid for debugging arrows

% pattern
		lhl	(yellow,red,0,3);
		lhl	(yellow,red,0,2);
		lhl	(yellow,red,0,1);
		lbl	(0,0);
		rbl	(1,3);
		rhl	(red,yellow,1,2);
		rhl	(red,yellow,1,1);
		rbl(1,0);


		draw textext("La") shifted (-.8cm,6.5cm) ;
		draw textext("Lb") shifted (-.8cm,4.5cm) ;
		draw textext("Lc") shifted (-.8cm,2.5cm) ;
		draw textext("Ld") shifted (-.8cm,0.5cm) ;

		draw textext("Ra") shifted (3.2cm,6.5cm) ;
		draw textext("Rb") shifted (3.2cm,4.5cm) ;
		draw textext("Rc") shifted (3.2cm,2.5cm) ;
		draw textext("Rd") shifted (3.2cm,0.5cm) ;


% pickup arrow
draw pfirst;

% AFTER first pickup

% Arrow to go between the figs
%drawarrow (3.5cm,3.5cm) ... (5cm,3.5cm) withpen pencircle scaled .6mm withcolor black;
draw btwarrow;

% pattern
		lhl	(yellow,red,3,3);
		lhl	(yellow,red,3,2);
		lbl	(3,1);
		lbl	(3,0);
		rhl	(red,yellow,4,3);
		rhl	(red,yellow,4,2);
		rhl	(red,yellow,4,1);
		rbl(4,0);
		
		

\stopMPcode
\stopbuffer

\startbuffer[2nd step 5-loop broad]
\startMPcode

%draw grid ; %grid for debugging arrows


% pattern
		lhl	(yellow,red,0,3);
		lhl	(yellow,red,0,2);
		lbl	(0,1);
		lbl	(0,0);
		rhl	(red,yellow,1,3);
		rhl	(red,yellow,1,2);
		rhl	(red,yellow,1,1);
		rbl(1,0);
		
		
		
		draw textext("La") shifted (-.8cm,6.5cm) ;
		draw textext("Lb") shifted (-.8cm,4.5cm) ;
		draw textext("Lc") shifted (-.8cm,2.5cm) ;
		draw textext("Ld") shifted (-.8cm,0.5cm) ;

		draw textext("Ra") shifted (3.2cm,6.5cm) ;
		draw textext("Rb") shifted (3.2cm,4.5cm) ;
		draw textext("Rc") shifted (3.2cm,2.5cm) ;
		draw textext("Rd") shifted (3.2cm,0.5cm) ;



% arrows for shift down
draw psecond ;


draw btwarrow ; 

		% AFTER the shift, i.e. second movement

		% pattern
				lbl	(3,3);
				lhl	(yellow,red,3,2);
				lhl	(yellow,red,3,1);
				lbl	(3,0);
				rhl	(red,yellow,4,3);
				rhl	(red,yellow,4,2);
				rhl	(red,yellow,4,1);
				rbl(4,0);




\stopMPcode
\stopbuffer

\startbuffer[3rd step 5-loop broad]
\startMPcode

%draw grid ; %grid for debugging arrows


% pattern
	lbl	(0,3);
	lhl	(yellow,red,0,2);
	lhl	(yellow,red,0,1);
	lbl	(0,0);
	rhl	(red,yellow,1,3);
	rhl	(red,yellow,1,2);
	rhl	(red,yellow,1,1);
	rbl(1,0);
		

	draw textext("La") shifted (-.8cm,6.5cm) ;
	draw textext("Lb") shifted (-.8cm,4.5cm) ;
	draw textext("Lc") shifted (-.8cm,2.5cm) ;
	draw textext("Ld") shifted (-.8cm,0.5cm) ;

	draw textext("Ra") shifted (3.2cm,6.5cm) ;
	draw textext("Rb") shifted (3.2cm,4.5cm) ;
	draw textext("Rc") shifted (3.2cm,2.5cm) ;
	draw textext("Rd") shifted (3.2cm,0.5cm) ;



% arrow for pickup
draw pfirst reflectedabout ((0,0cm),(0,7cm)) shifted (2.4cm,0cm);


draw btwarrow ; 

		% AFTER right-hand pickup

		% pattern
			lhl	(yellow,red,3,3);
			lhl	(yellow,red,3,2);
			lhl	(yellow,red,3,1);
			lbl	(3,0);
			rhl	(red,yellow,4,3);
			rhl	(red,yellow,4,2);
			rbl	(4,1);
			rbl(4,0);




\stopMPcode
\stopbuffer


\startbuffer[4th step 5-loop broad]
\startMPcode

%draw grid ; %grid for debugging arrows


% pattern
lhl	(yellow,red,0,3);
lhl	(yellow,red,0,2);
lhl	(yellow,red,0,1);
lbl	(0,0);
rhl	(red,yellow,1,3);
rhl	(red,yellow,1,2);
rbl	(1,1);
rbl(1,0);
		

draw textext("La") shifted (-.8cm,6.5cm) ;
draw textext("Lb") shifted (-.8cm,4.5cm) ;
draw textext("Lc") shifted (-.8cm,2.5cm) ;
draw textext("Ld") shifted (-.8cm,0.5cm) ;

draw textext("Ra") shifted (3.2cm,6.5cm) ;
draw textext("Rb") shifted (3.2cm,4.5cm) ;
draw textext("Rc") shifted (3.2cm,2.5cm) ;
draw textext("Rd") shifted (3.2cm,0.5cm) ;




% arrow for pickup
draw psecond reflectedabout ((0,0cm),(0,7cm)) shifted (2.4cm,0cm);


draw btwarrow ; 

		% AFTER the shift (fourth movement)

		% pattern
			lhl	(yellow,red,3,3);
			lhl	(yellow,red,3,2);
			lhl	(yellow,red,3,1);
			lbl	(3,0);
			rbl	(4,3);
			rhl	(red,yellow,4,2);
			rhl	(red,yellow,4,1);
			rbl(4,0);




\stopMPcode
\stopbuffer

%% EXAMPLE
%\placefigure
% [here] % placement
% [fig:combinations] % reference
% {An example of combination} % caption for whole group
% {
% \startcombination[3*2] % 3 columns, 2 rows
% {\externalfigure[lb00220]} {a} {\externalfigure[lb00221]} {b} % picture and caption for two figures in first row
% {\externalfigure[lb00222]} {c} {\externalfigure[lb00223]} {d}
% {\externalfigure[lb00225]} {e} {\externalfigure[lb00226]} {f}
% \stopcombination


\placefigure[here]
	[fig: 5 loop departed setup]
	{The start position for a 5-loop braid with departed (=two-colour) loops}
	{\framed{\getbuffer[setup 5-loop basic]}}


\placefigure[here]
[fig: 5 loops broad departed]
{The movements of creating a 5-loop broad lace (= an unorthodox 5-loop fingerloop braid)}
{
\startcombination[2*2]
	{\framed{\getbuffer[1st step 5-loop broad]}}{Put \Ra\ through Rb and pick up lower shank of Lc, pull through.}
	{\framed{\getbuffer[2nd step 5-loop broad]}}{Shift Lb to Lc and La to Lb.}
	{\framed{\getbuffer[3rd step 5-loop broad]}}{Put La through Lb and pick up lower shank of Rc, pull through.}
	{\framed{\getbuffer[4th step 5-loop broad]}}{Shift Rb to Rc and Ra to Rb.}
\stopcombination
}

\stoptext
