(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



(* ::Input::Initialization:: *)
BeginPackage["DrorBarNatan`"];
$DBNExtensions={As, BetterBlackBoard, MakeImage,RotateToMinimal, $Image, $NewInputAliases};
(*Print["DBN Extensions: ",$DBNExtensions];*)
Begin["`Private`"];


(* ::Input::Initialization:: *)
$Path=Join[$Path, {
"C:\\drorbn\\AcademicPensieve\\Projects\\KnotTheory"
}]


(* ::Input::Initialization:: *)
BetterBlackBoard[shot_] := Module[{diag, s1,s2},
diag=Norm[ImageDimensions[shot]];
s1=ColorConvert[shot, "Grayscale"];
s2=ImageAdjust[ ImageApply[Max[#1-#2,0]&, {s1, Blur[s1, 0.01diag]}] ] // ColorNegate;
ImageAdjust[s2, 0.3]
];


(* ::Input::Initialization:: *)
SetAttributes[As,HoldAll];
As /: (op:Do|Product|Sum|Table)[As[iter___], \[ScriptCapitalE]__] := op[\[ScriptCapitalE], {iter}]


(* ::Input::Initialization:: *)
Options[MakeImage] = {ImageSize -> {2400}, ThumbnailSize -> {512}};
MakeImage[g_, opts___Rule] := Module[
{isize = ImageSize /. {opts} /. Options[MakeImage]},
ImageResize[
ImageCrop[Rasterize[g, RasterSize -> isize, ImageSize -> isize]],
isize]
];
MakeImage[name_String, g_, opts___Rule] := Module[{s,
isize = ImageSize /. {opts} /. Options[MakeImage],
tsize = ThumbnailSize /. {opts} /. Options[MakeImage]
},
Export[name<>".png",
s=ImageResize[
ImageCrop[Rasterize[$Image[name]=g, RasterSize -> isize, ImageSize -> isize]],
isize]
];
ImageResize[s, tsize]
];


(* ::Input::Initialization:: *)
RotateToMinimal[l_]:=Module[
{bestl=l,rotatedl=RotateLeft[l]},
While[rotatedl=!=l,
bestl=First[Sort[{bestl,rotatedl}]];
rotatedl=RotateLeft[rotatedl]
];
bestl
];
RotateToMinimal[s_String] := StringJoin[RotateToMinimal[Characters[s]]];


(* ::Input::Initialization:: *)
$NewInputAliases={"Zhe"->"\:0416", "zhe"->"\:0436","<<"->"\[Precedes]", "<<="->"\[PrecedesEqual]", ">>"->"\[Succeeds]", ">>="->"\[SucceedsEqual]"};


(* ::Input::Initialization:: *)
If[$FrontEnd =!= Null,
SetOptions[$FrontEnd,
InputAliases->$NewInputAliases
]
]


(* ::Input::Initialization:: *)
End[]; EndPackage[];



