A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

Untitled - Stikked
From Sweet Matamata, 11 Years ago, written in Java.
Embed
  1. import javalib.colors.*;
  2. import javalib.worldimages.*;
  3.  
  4. import java.awt.*;
  5.  
  6. /**
  7.  * <p>Copyright 2014 Benjamin Lerner</p>
  8.  * <p>This program is distributed under the terms of the
  9.  * GNU Lesser General Public License (LGPL)</p>
  10.  */
  11.  
  12.  /**
  13.  * <p>The class to represent filled regular polygon images drawn by the
  14.  * world when drawing on its <code>Canvas</code>.</p>
  15.  * <p>The pinhole for the polygon is in the center of the polygon.</p>
  16.  *
  17.  * @author Benjamin Lerner
  18.  * @since November 14 2014
  19.  */
  20.  
  21. class RegularPolyImage extends WorldImage {
  22.     public Posn center;
  23.     public int sides;
  24.     public double sideLen;
  25.     public double angle;
  26.     private Polygon poly;
  27.  
  28.     /**
  29.      * The full constructor for an equilateral regular polygon, whose rightmost
  30.      * point is rotated from the horizontal
  31.      * @param center -- the central point of the regular polygon
  32.      * @param sideLen -- the length of one of the sides
  33.      * @param numSides -- the number of sides of the polygon
  34.      * @param angle -- the angle of rotation in radians
  35.      * @param color -- the color for this regular polygon
  36.      */
  37.     public RegularPolyImage(Posn center, double sideLen, int numSides, double angle, Color color){
  38.       super(center, color);
  39.       this.sideLen = sideLen;
  40.       this.sides = numSides;
  41.       this.angle = angle;
  42.       this.center = center;
  43.       this.setPoly(center);
  44.      
  45.       // set the pinhole in the center of the triangle
  46.       this.pinhole = center;
  47.     }
  48.     private void setPoly(Posn center) {
  49.         int[] xCoord = new int[this.sides];
  50.         int[] yCoord = new int[this.sides];
  51.         double internalAngle = (2.0 * Math.PI) / this.sides;
  52.         for (int i = 0; i < this.sides; i = i + 1) {
  53.             xCoord[i] = (int)(center.x + Math.cos(angle + i * internalAngle) * sideLen);
  54.             yCoord[i] = (int)(center.y + Math.sin(angle + i * internalAngle) * sideLen);
  55.         }
  56.         this.poly = new Polygon(xCoord, yCoord, this.sides);
  57.     }
  58.  
  59.     /**
  60.      * A convenience constructor to supply the color in the form of
  61.      * <code>{@link IColor IColor}</code>.
  62.      *
  63.      * @param center -- the central point of the regular polygon
  64.      * @param sideLen -- the length of one of the sides
  65.      * @param numSides -- the number of sides of the polygon
  66.      * @param angle -- the angle of rotation in radians
  67.      * @param color the color for this image
  68.      */
  69.     public RegularPolyImage(Posn center, double sideLen, int numSides, double angle, IColor color){
  70.       this(center, sideLen, numSides, angle, color.thisColor());
  71.     }
  72.    
  73.     /**
  74.      * Draw this image in the provided <code>Graphics2D</code> context.
  75.      *
  76.      * @param g the provided <code>Graphics2D</code> context
  77.      */
  78.     public void draw(Graphics2D g){
  79.       if (color == null)
  80.         color = new Color(0, 0, 0);
  81.      
  82.       // save the current paint
  83.       Paint oldPaint = g.getPaint();
  84.       // set the paint to the given color
  85.       g.setPaint(color);  
  86.       // draw the triangle
  87.       g.fill(poly);
  88.       // reset the original paint
  89.       g.setPaint(oldPaint);  
  90.     }
  91.    
  92.     /**
  93.      * Produce the regular polygon with the pinhole moved by the given (dx, dy)
  94.      *
  95.      * @param dx the horizontal offset
  96.      * @param dy the vertical offset
  97.      */
  98.     public WorldImage getMovedImage(int dx, int dy){
  99.       return new RegularPolyImage(this.movePosn(this.center, dx, dy),
  100.                               this.sideLen,
  101.                               this.sides,
  102.                               this.angle,
  103.                               this.color);
  104.     }
  105.  
  106.     /**
  107.      * Produce the regular polygon with the pinhole moved to the given location
  108.      *
  109.      * @param p the given location
  110.      */
  111.     public WorldImage getMovedTo(Posn p){
  112.       int dx = p.x - this.pinhole.x;
  113.       int dy = p.y - this.pinhole.y;
  114.       return this.getMovedImage(dx,  dy);
  115.     }
  116.    
  117.     /**
  118.      * EFFECT:
  119.      * Move the pinhole for this image by the given offset.
  120.      *
  121.      * @param dx the horizontal offset
  122.      * @param dy the vertical offset
  123.      */
  124.     public void movePinhole(int dx, int dy){
  125.       this.pinhole.x = this.pinhole.x + dx;
  126.       this.pinhole.y = this.pinhole.y + dy;
  127.       this.center = this.pinhole;
  128.       this.setPoly(this.pinhole);
  129.     }
  130.  
  131.     /**
  132.      * EFFECT:
  133.      * Move the pinhole for this image to the given location.
  134.      *
  135.      * @param p the given location
  136.      */
  137.     public void moveTo(Posn p){
  138.       int dx = p.x - this.pinhole.x;
  139.       int dy = p.y - this.pinhole.y;
  140.       this.movePinhole(dx,  dy);
  141.     }
  142.  
  143.     /**
  144.      * Produce the width of this triangle image
  145.      *
  146.      * @return the width of this image
  147.      */
  148.     public int getWidth(){
  149.       int minX = this.poly.xpoints[0];
  150.       int maxX = this.poly.xpoints[0];
  151.       for (int i = 0; i < this.sides; i = i + 1) {
  152.           minX = Math.min(minX, this.poly.xpoints[i]);
  153.           maxX = Math.max(maxX, this.poly.xpoints[i]);
  154.       }
  155.       return maxX - minX;
  156.     }
  157.  
  158.     /**
  159.      * Produce the height of this triangle image
  160.      *
  161.      * @return the height of this image
  162.      */
  163.     public int getHeight(){
  164.         int minY = this.poly.ypoints[0];
  165.         int maxY = this.poly.ypoints[0];
  166.         for (int i = 0; i < this.sides; i = i + 1) {
  167.             minY = Math.min(minY, this.poly.ypoints[i]);
  168.             maxY = Math.max(maxY, this.poly.ypoints[i]);
  169.         }
  170.         return maxY - minY;
  171.     }
  172.    
  173.     /**
  174.      * Produce a <code>String</code> representation of this triangle image
  175.      */
  176.     public String toString(){
  177.       return "new RegularPolyImage(" +
  178.           "this.pinhole = (" + this.pinhole.x + ", " + this.pinhole.y + "),n" +
  179.           "this.sideLen = " + Double.toString(this.sideLen) + ",n" +
  180.           "this.sides = " + Integer.toString(this.sides) + ",n" +
  181.           "this.color = " + this.color.toString() +
  182.           "))n";
  183.     }
  184.    
  185.     /**
  186.      * Produce a <code>String</code> that represents this image,
  187.      * indented by the given <code>indent</code>
  188.      *
  189.      * @param indent the given prefix representing the desired indentation
  190.      * @return the <code>String</code> representation of this image
  191.      */
  192.     public String toIndentedString(String indent){
  193.       indent = indent + " ";
  194.       return classNameString(indent, "RegularPolyImage") +
  195.           pinholeString(indent, this.pinhole) +
  196.           indent + "this.sideLen = " + Double.toString(this.sideLen) + ",n" +
  197.           indent + "this.sides = " + Integer.toString(this.sides) + ",n" +
  198.           colorString(indent, this.color) +
  199.           "))n";
  200.     }
  201.    
  202.     /**
  203.      * Is this <code>RegularPolyImage</code> same as the given object?
  204.      */
  205.     public boolean equals(Object o){
  206.       if (o instanceof RegularPolyImage){
  207.         RegularPolyImage that = (RegularPolyImage)o;
  208.         return this.pinhole.x == that.pinhole.x
  209.           && this.pinhole.y == that.pinhole.y
  210.           && this.sideLen == that.sideLen
  211.           && this.sides == that.sides
  212.           && this.color.equals(that.color);
  213.       }
  214.       else
  215.         return false;
  216.     }
  217.    
  218.     /**
  219.      * The hashCode to match the equals method
  220.      */
  221.     public int hashCode(){
  222.       return this.pinhole.x + this.pinhole.y + this.color.hashCode() +
  223.           (int)this.sideLen + this.sides;
  224.     }    
  225. }
  226.  
  227. /**
  228.  * Represents a filled Hexagon, a special case of a filled regular polygon
  229.  *
  230.  */
  231. class HexagonImage extends RegularPolyImage {
  232.   /**
  233.    * The full constructor for an equilateral hexagon, whose top and bottom
  234.    * are rotated from the horizontal
  235.    * @param center -- the central point of the hexagon
  236.    * @param sideLen -- the length of one of the sides
  237.    * @param angle -- the angle of rotation in radians
  238.    * @param color -- the color for this hexagon
  239.    */
  240.   public HexagonImage(Posn center, double sideLen, double angle, Color color){
  241.     super(center, sideLen, 6, angle, color);
  242.   }
  243.   /**
  244.    * A convenience constructor to supply the color in the form of
  245.    * <code>{@link IColor IColor}</code>.
  246.    *
  247.    * @param center -- the central point of the hexagon
  248.    * @param sideLen -- the length of one of the sides
  249.    * @param angle -- the angle of rotation in radians
  250.    * @param color the color for this image
  251.    */
  252.   public HexagonImage(Posn center, double sideLen, double angle, IColor color){
  253.     this(center, sideLen, angle, color.thisColor());
  254.   }
  255. }