Package GShape.Core.Objects.Primitives

Examples of GShape.Core.Objects.Primitives.rect


public class Ex004_Skyscraper extends PApplet {

  public void setup () {
   
    GShape.begin(this, "Top0", new rect (0, 0, 20, 20, 0) ); // Must be called, otherwise it will not work
       
   
    // Building
    int i = 0;
    while (true) {
View Full Code Here


public class Ex008_EmbeddParent extends PApplet{
 
  public void setup () {
       
    // Initialize
    rect iniGeometry = new rect (10, 10, 60, 80, 0);
    GShape.begin(this, "Rect", iniGeometry); // Must be called, otherwise it will not work
    GShape.showCoordinates();
   
   
    // Embedd externel object
View Full Code Here

public class Ex005_SimpleSimulation extends PApplet{
 
  public void setup () {
   
    GShape.begin(this, "Ground", new rect (10, 10, 100, 200, 0)); // Must be called, otherwise it will not work
    GShape.showCoordinates();
   
   
    // Attributes
    GShape.setAttribute ("height", 100);
View Full Code Here

public class Ex002_AlignVolumes  extends PApplet{
 
  public void setup () {

      GShape.begin(this, "Ground", new rect (10, 10, 100, 200, 0)); // Must be called, otherwise it will not work
       
     
      // Envirement
      GShape.SplitY ("Ground", "~40m:Sectors");
      GShape.SplitY ("Sectors", "~10m ; ~30m:Lots");
View Full Code Here

public class Ex008_EmbeddChild extends PApplet{
 
  public void setup () {
   
    // Initialize
    GShape.begin(this, "Ground", new rect (10, 10, 34, 50, 0) ); // Must be called, otherwise it will not work
    GShape.showCoordinates();

   
    // Attributes
    Random rand = new Random();
View Full Code Here

public class Ex003_SimpleVolumeDraw extends PApplet{
 
  public void setup () {

    GShape.begin(this, "Ground", new rect (10, 10, 100, 200, 0)); // Must be called, otherwise it will not work
    GShape.showCoordinates();

  }
View Full Code Here

    for (iGObject src : source) {
     
      // Get base geometrie
      Object base = src.GetPrimitive(rect.class);
      if (base != null) {
        rect oRect = (rect) base;


        // Looping new Objects:
        for (GExpressionItem item : exp.Items) { // Bsp: "5m ; Xm:Perimeter ; 5m"
         
          if (directionX) { // Split X
           
            float length = oRect.width;
            // absolut, x or percentage
            if (item.isNumber && (item.isAbsolut || item.isX || item.isPercentage)) // Bsp: 5m
              new PRect (core, item.getString(), new rect (oRect.p1.x + item.getOffset(length, exp),  oRect.p1.y, oRect.p1.x + item.getOffset(length, exp) + item.getNumber(length, 0), oRect.p2.y, oRect.z), src);
            // Tilde
            if (item.isTilde) {
              for (int ii=0;ii<item.getCount(length);ii++) {
                             
                float num = item.getNumber(length, 0);
                new PRect (core, item.getString()new rect (oRect.p1.x,  oRect.p1.y + item.getOffset(length, exp) + ii * num, oRect.p2.x, oRect.p1.y + item.getOffset(length, exp) + (ii + 1) * num, oRect.z), src);

              }
            }
           
          } else { // Split Y
           
            float length = oRect.depth;
            if (item.isNumber && item.isAbsolut) // Bsp: 5m
              new PRect (core, item.getString(), new rect (oRect.p1.x,  oRect.p1.y + item.getOffset(length, exp), oRect.p2.x, oRect.p1.y + item.getOffset(length, exp) + item.getNumber(0, 0), oRect.z), src);         
            // X
            if (item.isNumber && item.isX) // Bsp: Xm
              new PRect (core, item.getString()new rect (oRect.p1.x,  oRect.p1.y + item.getOffset(length, exp), oRect.p2.x, oRect.p1.y + item.getOffset(length, exp) + item.getNumber(length, 0), oRect.z), src);
            // Tilde
            if (item.isTilde) {
              for (int ii=0;ii<item.getCount(length);ii++) {
                             
                float num = item.getNumber(length, 0);
                new PRect (core, item.getString()new rect (oRect.p1.x,  oRect.p1.y + item.getOffset(length, exp) + ii * num, oRect.p2.x, oRect.p1.y + item.getOffset(length, exp) + (ii + 1) * num, oRect.z), src);

              }
            }
         
          }
View Full Code Here

  public void PerformRule(GCore core, iGObject src, GExpression exp, int tmpWhichDirection) throws Exception {

      // Get base geometrie
      Object base = src.GetPrimitive(rect.class);
      if (base != null) {
        rect oRect = (rect) base;

       
        // Only one Item!!
        if (exp.Items.size() == 1 && exp.Items.get(0).isNumber) {
         
          // Item
          GExpressionItem item = exp.Items.get(0); // Bsp: "100m:70m:Lots:30%"
         
         
          // Random value 0 or 1 (width or depth)
          java.util.Random rnd = new java.util.Random ();
          int whichDirection = rnd.nextInt(2); // 0 to 1
          if (tmpWhichDirection != -1)
            whichDirection = tmpWhichDirection;
          int mirror = rnd.nextInt(2); // 0 to 1

         
          // Which direction?
          float factorX = 1;
          float factorY = 1;
          if (whichDirection == 0) // width
            factorX = Math.abs(mirror - (item.Parts.get(3).Number / 100)); // bsp 30% direction X
          else  // depth
            factorY = Math.abs(mirror - (item.Parts.get(3).Number / 100)); // bsp 30% direction Y
         

          // Create 2 new rects (only geometry first)
          float x = (oRect.p2.x - oRect.p1.x) * factorX + oRect.p1.x;
          float y = (oRect.p2.y - oRect.p1.y) * factorY + oRect.p1.y;
          float x2 = (oRect.p2.x - oRect.p1.x) * factorX + oRect.p1.x;
          float y2 = (oRect.p2.y - oRect.p1.y) * factorY + oRect.p1.y;
          if (whichDirection == 1) x2 = oRect.p1.x; else y2 = oRect.p1.y;
          rect rec1 = new rect (oRect.p1.x, oRect.p1.y, x, y, oRect.z);
          rect rec2 = new rect (x2, y2, oRect.p2.x, oRect.p2.y, oRect.z);
         
         
          // Create object and call this class recursive
          //  - if min with and min height not to small
          //  - no recursive function in else case if tmpWhichDirection != -1
View Full Code Here

    for (iGObject src : source) {

      // Get base geometrie
      Object base = src.GetPrimitive(rect.class);
      if (base != null) {
        rect oRect = (rect) base;


        // Looping new Objects:
        for (int i=0;i<exp.Items.size();i++) { // Bsp: "10:Lot"
         
          GExpressionItem item = exp.Items.get(i);
           
          if (item.isNumber) { // Bsp: 10 (multiply geometry 10 times)
           
            for (int ii=0;ii<item.getNumber(0, 0) + 1;ii++) {
                                           
              float offset, width;
              rect newRect = null;
              if (directionX) {
                offset = oRect.width * ii;
                width = offset + oRect.width;
                newRect = new rect (offset, oRect.p1.y, width, oRect.p2.y, oRect.z);
              }
              if (!directionX) {
                offset = oRect.depth * ii;
                width = offset + oRect.depth;
                newRect = new rect (oRect.p1.y, offset, oRect.p2.x, width, oRect.z);
              }
              new PRect (core, item.getString(), newRect, src);

            }
           
View Full Code Here

    size(800, 600, OPENGL, null);
    frameRate(60);

   
    // Initialize
    GShape.begin(this, "Area", new rect (10, 10, 200, 200, 0)); // Must be called, otherwise it will not work

   
    // Envirement
    GShape.DivideArea ("Area", "25m:20m:Areas:40%");
    GShape.Shrink("Areas", "5m:Green ; Lots");
View Full Code Here

TOP

Related Classes of GShape.Core.Objects.Primitives.rect

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.