Blame mono/Assistance/ModifierSnowflake.cs

72b17c
using System;
72b17c
using System.Drawing;
72b17c
using System.Drawing.Imaging;
72b17c
using System.Collections.Generic;
72b17c
72b17c
namespace Assistance {
72b17c
	public class ModifierSnowflake: Modifier {
72b17c
		public static readonly int rays = 6;
72b17c
	
72b17c
		public ActivePoint center;
72b17c
726e8a
		public ModifierSnowflake(Document document, Point center): base(document) {
72b17c
			this.center = new ActivePoint(this, ActivePoint.Type.CircleCross, center);
72b17c
		}
72b17c
72b17c
		public override void draw(System.Drawing.Graphics g) {
72b17c
			for(int i = 0; i < rays/2; ++i) {
72b17c
				Point pp0 = center.position;
72b17c
				Point pp1 = center.position + new Point(100.0, 0.0).rotate( i*2.0*Math.PI/(double)rays );
72b17c
				Geometry.truncateInfiniteLine(new Rectangle(g.VisibleClipBounds), ref pp0, ref pp1);
72b17c
				g.DrawLine(pen, pp0.toFloat(), pp1.toFloat());
72b17c
			}
72b17c
		}
72b17c
72b17c
		public override void getTransformFuncs(List<geometry.transformfunc> transformFuncs) {</geometry.transformfunc>
72b17c
			Point p0 = center.position;
72b17c
			for(int i = 0; i < rays; ++i) {
72b17c
				double angle = i*2.0*Math.PI/(double)rays;
72b17c
				double s = Math.Sin(angle);
72b17c
				double c = Math.Cos(angle);
72b17c
				
72b17c
				transformFuncs.Add(delegate(Point p) {
72b17c
					double x = p.x - p0.x;
72b17c
					double y = p.y - p0.y;
72b17c
					return p0 + new Point(c*x - s*y, s*x + c*y);
72b17c
				});
72b17c
72b17c
				transformFuncs.Add(delegate(Point p) {
72b17c
					double x = p.x - p0.x;
72b17c
					double y = p.y - p0.y;
72b17c
					return p0 + new Point(c*x + s*y, s*x - c*y);
72b17c
				});
72b17c
			}
72b17c
		}
72b17c
	}
72b17c
}
72b17c