private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { bDragging = true; downX = e.X; downY = e.Y; currentPic = new PicObject(getRandomColor()); currentPic.filled = random.Next(5) <= 2; currentPic.addPoint(downX, downY); }
public void drawPicInMirrors(Graphics g, int x0, int y0) { int step = picInMirrorSerial.Count; for (int i = step - 1; i >= 0; i--) { //including original object, i--, more later, more draw first ArrayList se = (ArrayList)picInMirrorSerial[i]; for (int j = 0; j < se.Count; j++) { PicObject pic = (PicObject)se[j]; pic.draw(g, x0, y0); } } }
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { bDragging = false; kaleido.addPicObject(currentPic); currentPic = null; using (Graphics g = this.CreateGraphics()) { g.Clear(this.BackColor); kaleido.getPicInMirrors(3); kaleido.drawPicInMirrors(g, 0, 0); kaleido.drawMirrors(g, Color.Black, 0, 0); } }
public PicObject picObjectMirrorSymmetry(PicObject pic) { if (pic.mirror == this) { return(null); // a Pic In this mirror can not through the mirror itself } Color color = colorMirrorRef(pic.color, refl); PicObject pic2 = new PicObject(pic.type, color, pic.filled); int n = pic.countPoint(); for (int i = 0; i < n; i++) { PointCoord p = pic.getPoint(i); pic2.addPoint(pointMirrorSymmetry(p)); } pic2.mirror = this; pic2.originalPicObject = pic.originalPicObject; pic2.srcPicObject = pic; return(pic2); }
public ArrayList getPicInMirrors(int step) { if (step <= 0) { return(null); } //int n=picInMirrorSerial.Count; //if( step<=n ) return (ArrayList)picInMirrorSerial[ step]; //???? picInMirrorSerial.Clear(); if (picObjects == null) { return(null); } picInMirrorSerial.Add(picObjects); //picObjects as the first serial ArrayList lastStep = picObjects; for (int i = 1; i <= step; i++) { ArrayList thisStep = new ArrayList(); for (int j = 0; j < lastStep.Count; j++) { PicObject pic = (PicObject)lastStep[j]; for (int k = 0; k < mirrors.Count; k++) { Mirror mir = (Mirror)(mirrors[k]); if (pic.mirror != mir) { thisStep.Add(mir.picObjectMirrorSymmetry(pic)); } } } picInMirrorSerial.Add(thisStep); lastStep = thisStep; } return(lastStep); }
public void addPicObject(PicObject po) { picObjects.Add(po); }