dotgnu-libs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-libs-commits] CVS: xsharp/samples Cube.cs,NONE,1.1 Makefile.am,1


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-libs-commits] CVS: xsharp/samples Cube.cs,NONE,1.1 Makefile.am,1.3,1.4 samples.build,1.3,1.4
Date: Tue, 01 Oct 2002 03:15:37 -0400

Update of /cvsroot/dotgnu-libs/xsharp/samples
In directory subversions:/tmp/cvs-serv5233/samples

Modified Files:
        Makefile.am samples.build 
Added Files:
        Cube.cs 
Log Message:


add an isometric cube application to the "samples" directory.


--- NEW FILE ---
/*
 * Cube.cs - Sample Cube for Xsharp
 *
 * This file is part of the X# library.
 * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/* Contributed by Gopal V <address@hidden> */

/* Move the mouse cursor within the window to rotate the cube */

using System;
using XWindows;

public class Cube3d
{
        // Internal state.
        private static int lastX,lastY;
        private static int degree=0;
        private const int H=200;
        private const int V=50;
        private const int VERTICES=4; // Vertices in Prism
        private const int THETA=4; // How to divide the angles
        
        // Main entry point.
        public static void Main(String[] args)
        {
                Application app = new Application("Cube::Isometric", args);
                TopLevelWindow topLevel = new TopLevelWindow("Cube::Isometric", 
600, 480);
                topLevel.PointerMotion += new PointerMotionEventHandler(Motion);
                topLevel.Foreground = new Color(0x00, 0x00, 0x00);
                topLevel.Background = new Color(0xFF, 0xFF, 0xFF);
                Canvas canvas=new Canvas(topLevel);
                canvas.Clear(0,0,topLevel.Width,topLevel.Height);
                canvas.Dispose();
                DrawCube(topLevel,30);
                topLevel.Map();
                app.Run();
                app.Close();
        }

        // Handle mouse pointer motion.
        public static void Motion(Widget widget, int x, int y,
                                                          ModifierMask 
modifiers)
        {
                Canvas canvas=new Canvas(widget);
                canvas.Clear(0,0,widget.Width,widget.Height);
                canvas.Dispose();
                degree+=(x-lastX);
                DrawCube(widget,degree);
                lastX = x;
                lastY = y;
        }

        public static void DrawCube(Widget widget,int degree)
        {
                double rad=(degree*3.14)/180;
                int x=widget.Width/3;
                int y=widget.Height/3;
                int []a=new int[2*VERTICES+2];
                for(int i=0;i<VERTICES;i++)
                        {
                                
a[2*i]=(int)(x-H*Math.Sin(rad+3.14*(2*i)/THETA));
                                
a[2*i+1]=(int)(y-V*Math.Cos(rad+3.14*(2*i)/THETA));
                        }
                a[2*VERTICES]=a[0];
                a[2*VERTICES+1]=a[1];
                DrawPolygon(widget,VERTICES,a);
                Canvas canvas=new Canvas(widget);
                for(int i=0;i<VERTICES;i++)
                {
                        int x2=a[2*i+1]+H;
                        canvas.DrawLine(a[2*i],a[2*i+1],a[2*i],x2);
                        a[2*i+1]+=H;
                }
                canvas.Dispose();
                a[2*VERTICES]=a[0];
                a[2*VERTICES+1]=a[1];
                DrawPolygon(widget,VERTICES,a);
        }
        public static void DrawPolygon(Widget widget,int n,int []a)
        {
                Canvas canvas = new Canvas(widget);
                for(int i=0;i<n;i++)
                {
                        canvas.DrawLine(a[2*i],a[2*i+1],a[2*i+2],a[2*i+3]);
                }
                canvas.Dispose();
        }

} // class Cube3d

Index: Makefile.am
===================================================================
RCS file: /cvsroot/dotgnu-libs/xsharp/samples/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Makefile.am 30 Sep 2002 22:01:56 -0000      1.3
--- Makefile.am 1 Oct 2002 07:15:34 -0000       1.4
***************
*** 5,7 ****
                        -f "$(srcdir)/samples.build" all
  
! CLEANFILES = XHello.exe Scribble.exe Effects.exe
--- 5,7 ----
                        -f "$(srcdir)/samples.build" all
  
! CLEANFILES = XHello.exe Scribble.exe Effects.exe Cube.exe

Index: samples.build
===================================================================
RCS file: /cvsroot/dotgnu-libs/xsharp/samples/samples.build,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** samples.build       30 Sep 2002 22:01:56 -0000      1.3
--- samples.build       1 Oct 2002 07:15:34 -0000       1.4
***************
*** 54,57 ****
--- 54,74 ----
                </compile>
  
+               <!-- Build the Cube.exe program -->
+               <compile output="Cube.exe"
+                                target="exe"
+                                optimize="true"
+                                debug="true"
+                                sanewarnings="true">
+ 
+                       <sources>
+                               <file name="Cube.cs"/>
+                       </sources>
+ 
+                       <references>
+                               <file name="../Xsharp/Xsharp.dll"/>
+                       </references>
+ 
+               </compile>
+ 
        </target>
  </project>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]