Well I have 3 methods that are overloads, but in it's scope has the same scope except one method call.
public static Texture2D DrawAnnulus(this Texture2D texture, Func<int, int, Color?> predicate, AnnulusConfig annulusConfig)
{
InitTexture(ref texture, annulusConfig.offset.x + annulusConfig.radius * 2, annulusConfig.offset.y + annulusConfig.radius * 2);
Polar(texture, annulusConfig.offset.x, annulusConfig.offset.y, annulusConfig.radius, predicate);
if (annulusConfig.apply)
texture.Apply();
return texture;
}
public static Texture2D DrawAnnulus(this Texture2D texture, SectorList list, AnnulusConfig annulusConfig)
{
InitTexture(ref texture, annulusConfig.offset.x + annulusConfig.radius * 2, annulusConfig.offset.y + annulusConfig.radius * 2);
Polar(texture, annulusConfig.offset.x, annulusConfig.offset.y, annulusConfig.radius, (xx, yy) => Annulus(annulusConfig.offset.x, annulusConfig.offset.y, xx, yy, annulusConfig.radius2, list));
if (annulusConfig.apply)
texture.Apply();
return texture;
}
public static Texture2D DrawAnnulus(this Texture2D texture, Color? color, AnnulusConfig annulusConfig)
{
InitTexture(ref texture, annulusConfig.offset.x + annulusConfig.radius * 2, annulusConfig.offset.y + annulusConfig.radius * 2);
Polar(texture, annulusConfig.offset.x, annulusConfig.offset.y, annulusConfig.radius, (xx, yy) => Annulus(annulusConfig.offset.x, annulusConfig.offset.y, xx, yy, annulusConfig.radius2, color));
if (annulusConfig.apply)
texture.Apply();
return texture;
}
As you can see the only changing part is the Polar
method call. The other part is only checks.
How could I simplify this?