public bool RaaktLijnCirkel(Point begin, Point einde, Point cirkel, int radius) { double bovenkant = Math.Abs((begin.X - einde.X) * (einde.Y - cirkel.Y) - (einde.X - cirkel.X) * (begin.Y - einde.Y)); double onderkant = Math.Sqrt(Math.Pow((begin.X - einde.X), 2) + Math.Pow(begin.Y - einde.Y, 2)); double afstand = bovenkant / onderkant; return(afstand <= radius && VolRechthoekObject.RaaktCirkel(cirkel, radius, begin, einde)); }
public bool RaaktCirkel(Point locatiegum, int radius) { // Maak een oppervlakte die ongeveer de grootte van de tekst voorsteld Size oppervlakte = TextRenderer.MeasureText(tekst, new Font("Tahoma", 10 * grootte)); // Check of er binnen die oppervlakte 'gegumd' wordt. return(VolRechthoekObject.RaaktCirkel(locatiegum, radius, locatie , new Point(locatie.X + oppervlakte.Width, locatie.Y + oppervlakte.Height))); }
public SchetsHistorie(string geserialiseerdeHistorie) { historie = new Stack <ISchetsObject>(); toekomst = new Stack <ISchetsObject>(); StringReader reader = new StringReader(geserialiseerdeHistorie); string line; while (!String.IsNullOrEmpty(line = reader.ReadLine())) { string[] typeAndValue = line.Split('='); ISchetsObject so = null; switch (typeAndValue[0]) { case "PenObject": so = PenObject.VanSerialisatie(typeAndValue[1]); break; case "PlaatjeObject": so = PlaatjeObject.VanSerialisatie(typeAndValue[1]); break; case "LijnObject": so = PenObject.VanSerialisatie(typeAndValue[1]); break; case "RechthoekObject": so = PenObject.VanSerialisatie(typeAndValue[1]); break; case "GumObject": so = GumObject.VanSerialisatie(typeAndValue[1]); break; case "VolOvaalObject": so = VolOvaalObject.VanSerialisatie(typeAndValue[1]); break; case "VolRechthoekObject": so = VolRechthoekObject.VanSerialisatie(typeAndValue[1]); break; case "TekstObject": so = TekstObject.VanSerialisatie(typeAndValue[1]); break; case "OvaalObject": so = OvaalObject.VanSerialisatie(typeAndValue[1]); break; } this.Push(so); } }