<defs>
<def id="brickscs"><![CDATA[
using System;
using System.Drawing;
using System.Collections.Generic;
class Bricks{
QcQ

  List<String> ll;
  Graphics g;
  Bricks(){ll = new List<String>();}
  public static void Main(String [] args){
  try{
    Bitmap b = new Bitmap(400,400);
    Graphics g = Graphics.FromImage(b);
    Bricks bw = new Bricks();
    bw.letsGoToWork();
    bw.render(g);
    b.Save("brick.png");
  }
  catch (Exception e){
    Console.WriteLine(e.ToString());
  }
  }

  void addN(String s,int n){for(int i=0;i<n;i++)ll.Add(s);}
  public void b(){ll.Add("b");}
  public void h(){ll.Add("h");}
  public void r(){ll.Add("r");}
  public void s(){ll.Add("s");}
  public void l(){ll.Add("l");}
  public void q(){ll.Add("q");}
  public void w(){ll.Add("w");}
  public void m(){ll.Add("m");}
  void b(int n){addN("b",n);}
  void h(int n){addN("h",n);}
  void r(int n){addN("r",n);}
  void s(int n){addN("s",n);}
  void l(int n){addN("l",n);}
  void q(int n){addN("q",n);}
  void w(int n){addN("w",n);}
  void m(int n){addN("m",n);}
  double x0 = 0.0;
  double y0 = 0.0;
  double xs = 100.0;
  double ys = -100.0;

  double gap = 0.1;
  double x = 0.0;
  double y = 0.0;
  double z = 0.0;
  double vp=50;
  Point flat(double x, double y, double z)
  { double s=0.5;double c=0.866;
    return (new Point(
      (int)((x0+xs*(c*x-c*z))*vp/(vp-x-y-z)),
      (int)((y0+ys*(-s*x+y-s*z))*vp/(vp-x-y-z))));
  }
  Pen currPen;
  Brush currBrush;
  void drawLine(Point p1,Point p2){
    g.DrawLine(currPen,p1,p2);
  }
  void face(Color c,Point p0,Point p1,Point p2,Point p3)
  {
    Point[] f = {p0,p1,p2,p3};
    g.FillPolygon(new SolidBrush(c),f);
    g.DrawPolygon(new Pen(c), f);
  }
  void block(double dx,double dy,double dz)
  {
    Point [,,] p = new Point [3,3,3];
    //[2][2];// = {{},{},{}};
    for (int i=0;i<2;i++){
      for (int j=0;j<2;j++){
        for (int k=0;k<2;k++)
          p[i,j,k]=flat(x+i*(dx-gap),y+j*(dy-gap),z+k*(dz-gap));
        }
      }
    face(Color.FromArgb(192,192,255),p[0,1,0],p[1,1,0],p[1,1,1],p[0,1,1]);
    face(Color.FromArgb(128,128,255),p[1,0,0],p[1,1,0],p[1,1,1],p[1,0,1]);
    face(Color.FromArgb(96,96,255)  ,p[0,0,1],p[0,1,1],p[1,1,1],p[1,0,1]);
    x += dx;
  }

  private void l(int x2,int y2,int z2,
                 int xd,int yd,int zd){
    for(int i=0;i<xd;i++)
      drawLine(flat(i,0,0),flat(i ,y2,z2));
    for(int i=0;i<yd;i++)
      drawLine(flat(0,i,0),flat(x2,i ,z2));
    for(int i=0;i<zd;i++)
      drawLine(flat(0,0,i),flat(x2,y2,i ));
  }
  public void render(Graphics gp){
    g = gp;
    currBrush = new SolidBrush(Color.FromArgb(64,64,64));
    g.FillRectangle(currBrush,0,0,400,400);
    g.TranslateTransform(140,150);
    g.ScaleTransform(0.2f,0.2f);
    currPen = new Pen(Color.FromArgb(235,200,80));
    l( 0,6,0, 11,0,0);
    l(10,0,0,  0,7,0);
    l( 0,0,6,  0,7,0);
    l( 0,6,0,  0,0,7);
    l(10,0,0,  0,0,7);
    l( 0,0,6, 11,0,0);
    foreach (String s in ll){
      Console.Write(s);
      if (s == "b")  block(2.0,1.0,1.0);
      if (s == "h")  block(1.0,1.0,1.0);
      if (s == "r")  {x=0.0;z+=1.0;}
      if (s == "s")  {x=0.0;y+=1.0;z=0.0;}
      if (s == "m")  {x+=1.0;}
      if (s == "l")  {x=0.0;y+=1;}
      if (s == "w")  {x=0.0;y=0.0;z+=1.0;}
      if (s == "q")  block(0.5,1.0,1.0);
    }
  }
}
]]></def>

<def id="bricks"><![CDATA[
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.io.File;
import javax.imageio.ImageIO;
class Bricks{  

QcQ
   
  Bricks(){l = new ArrayList<String>();}
  public static void main(String args[])throws Exception {
    BufferedImage image =
      new BufferedImage(400,400, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = image.createGraphics();
    final Bricks bw = new Bricks();
    bw.letsGoToWork();
    bw.render(g);
    g.dispose();
    File out = new File("brick.png");
    ImageIO.write(image, "png", out);
  }

  ArrayList<String> l;
  Graphics2D g;
  void addN(String s,int n){for(int i=0;i<n;i++)l.add(s);}
  public void b(){l.add("b");}
  public void h(){l.add("h");}
  public void r(){l.add("r");}
  public void s(){l.add("s");}
  public void l(){l.add("l");}
  public void q(){l.add("q");}
  public void w(){l.add("w");}
  public void m(){l.add("m");}
  void b(int n){addN("b",n);}
  void h(int n){addN("h",n);}
  void r(int n){addN("r",n);}
  void s(int n){addN("s",n);}
  void l(int n){addN("l",n);}
  void q(int n){addN("q",n);}
  void w(int n){addN("w",n);}
  void m(int n){addN("m",n);}
  int xm = 300;
  int ym = 300;
  double x0 = 0.0;
  double y0 = 0.0;
  double xs = 100.0;
  double ys = -100.0;

  double gap = 0.1;
  double x = 0.0;
  double y = 0.0;
  double z = 0.0;
  double vp=50;
  Point flat(double x, double y, double z)
  { double s=0.5;double c=0.866;
    return (new Point(
      (int)((x0+xs*(c*x-c*z))*vp/(vp-x-y-z)),
      (int)((y0+ys*(-s*x+y-s*z))*vp/(vp-x-y-z))));
  }
  void drawLine(Point p1,Point p2){
    g.drawLine(p1.x,p1.y,p2.x,p2.y);
  }
  void face(Color c,Point p0,Point p1,Point p2,Point p3)
  {
    Polygon f = new Polygon();
    f.addPoint(p0.x,p0.y);
    f.addPoint(p1.x,p1.y);
    f.addPoint(p2.x,p2.y);
    f.addPoint(p3.x,p3.y);
    g.setColor(c);
    g.fillPolygon(f);
    g.setColor(Color.black);
    g.drawPolygon(f);
  }
  void block(double dx,double dy,double dz)
  {
    Point p[][][] = new Point[2][2][2];
    for (int i=0;i<2;i++)
      for (int j=0;j<2;j++)
        for (int k=0;k<2;k++)
          p[i][j][k]=flat(x+i*(dx-gap),y+j*(dy-gap),z+k*(dz-gap));
    face(new Color(192,192,255),p[0][1][0],p[1][1][0],p[1][1][1],p[0][1][1]);
    face(new Color(128,128,255),p[1][0][0],p[1][1][0],p[1][1][1],p[1][0][1]);
    face(new Color(96,96,255)  ,p[0][0][1],p[0][1][1],p[1][1][1],p[1][0][1]);
    x += dx;
  }
  private void l(int x2,int y2,int z2,
                 int xd,int yd,int zd){
    for(int i=0;i<xd;i++)
      drawLine(flat(i,0,0),flat(i ,y2,z2));
    for(int i=0;i<yd;i++)
      drawLine(flat(0,i,0),flat(x2,i ,z2));
    for(int i=0;i<zd;i++)
      drawLine(flat(0,0,i),flat(x2,y2,i ));
  }
  public void render(Graphics2D gp){
    g = gp;
    g.setRenderingHint(
      RenderingHints.KEY_ANTIALIASING,
      RenderingHints.VALUE_ANTIALIAS_ON);
    g.setStroke(new BasicStroke(1,
          BasicStroke.CAP_ROUND,
          BasicStroke.JOIN_ROUND));
    g.setColor(new Color(64,64,64));
    g.fillRect(0,0,400,400);
    g.translate(140,150);
    g.scale(0.2,0.2);
    g.setColor(new Color(235,200,80));
    g.setStroke(new BasicStroke(1));
    l( 0,6,0, 11,0,0);
    l(10,0,0,  0,7,0);
    l( 0,0,6,  0,7,0);
    l( 0,6,0,  0,0,7);
    l(10,0,0,  0,0,7);
    l( 0,0,6, 11,0,0);
    for(String s : l){
      System.out.print(s);
      if (s.equals("b"))  block(2.0,1.0,1.0);
      if (s.equals("h"))  block(1.0,1.0,1.0);
      if (s.equals("r"))  {x=0.0;z+=1.0;}
      if (s.equals("s"))  {x=0.0;y+=1.0;z=0.0;}
      if (s.equals("m"))  {x+=1.0;}
      if (s.equals("l"))  {x=0.0;y+=1;}
      if (s.equals("q"))  block(0.5,1.0,1.0);
      if (s.equals("w"))  {x=0.0;y=0.0;z+=1.0;}
    }
  }
}]]></def>
</defs>
