/* * 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 */ 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