header

 

More links

Adobe Connect | Adobe Conect Custom Pods | AutoHotkey | Android | Arduino | Blog | COMM140Fractals | Grammar Checkers | Knots | a Million Dots |  Processing | RedBubble | Tutorials | Weather | World Time Meeting Planner |

Home > Tutorials > Processing > Processing Examples > Laser Radiation I

Laser Radiation

 

Laser Radiation

 



processing code

// Warning Laser Radiation
// by Rupert Russell
// http://www.rupert.id.au/tutorials/processing/examples.php'
// see: 


color bgColor = color(255,255,0);
PFont font;

int screenWidth = 749;
int screenHeight = 999;

float xMargin = screenWidth / 10;
float yMargin = screenHeight / 9;
float triangleMargin = screenHeight / 3.74 ;
int sm = 95;


void setup() {
size(screenWidth,screenHeight);
smooth();
noLoop();

}

void draw() {
background(255,255,0);
fill(255,255,0);

beginShape(); // Triangle
strokeWeight(37);
strokeCap(ROUND);
strokeJoin(ROUND);
vertex(0 + xMargin, screenHeight - yMargin - triangleMargin);
vertex(screenWidth - xMargin, screenHeight - yMargin - triangleMargin);
vertex(screenWidth / 2, yMargin);
endShape(CLOSE);


translate(width / 2, height / 2 - 55);

fill(0);
ellipse(0,0, 70,70);
strokeCap(SQUARE);

// Large
strokeWeight(10);
stroke(0);
for (float i = 0; i < 240; i = i+30) {
pushMatrix();
rotate(radians(i));
line(0, 140, 0, -140);
popMatrix();
}

// the laserbeam 
stroke(0,0,0);
pushMatrix();
rotate(radians(90));
line(0, 0, 0, -200);
popMatrix();

// Small
stroke(0,0,0);

for (float i = 0; i < 240; i = i+30) {
pushMatrix();
rotate(radians(i+15));
line(0, sm, 0, -sm);
popMatrix();

}



save("Laser_v2.png");
}
code formatter

http://www.onformative.com/codeformatter/

 


Version 5 for Posters

processing code

paste your code// Warning Laser Radiation
// by Rupert Russell
// http://www.rupert.id.au/tutorials/processing/examples.php
// Warning this code is rough and ready


color bgColor = color(255,255,0);
  PFont font;
 
  int screenWidth = 2996;
  int screenHeight = 3996;
   
  float xMargin = screenWidth / 10;
  float yMargin = screenHeight / 9;
  float triangleMargin = screenHeight / 3.74  ;
  int sm = 295;  // length of shorter radiation lines
  int la = 500; // length of longer radiation lines
 
void setup() {
  size(screenWidth,screenHeight);
  smooth();
  noLoop();
 
}
 
void draw() {
  background(255,255,0);
  fill(255,255,0);
  
  beginShape();  // Triangle
    strokeWeight(100);
    strokeCap(ROUND);
    strokeJoin(ROUND);
    vertex(0 + xMargin, screenHeight - yMargin - triangleMargin);
    vertex(screenWidth - xMargin, screenHeight - yMargin - triangleMargin);
    vertex(screenWidth / 2, yMargin);
  endShape(CLOSE);
   
 
  translate(width / 2, height / 2 - 250);  // Move the position of the laser in the triangle
   
  fill(0);
  ellipse(0,0, 70,70);
  strokeCap(SQUARE);
  
  
  // Draw the Laser
  
  // Draw the longer laser lines
  strokeWeight(40);
  stroke(0);
  for (float i = 0; i < 240; i = i+30) {
  pushMatrix();
  rotate(radians(i));
  line(0, la, 0, -la);
  popMatrix();
  }
   

   
  // Draw the shorter lines
  stroke(0,0,0);
 
  for (float i = 0; i < 240; i = i+30) {
  pushMatrix();
  rotate(radians(i+15));
  line(0, sm, 0, -sm);
  popMatrix();
   
  }

  // Draw the laser beeam
  stroke(0,0,0);
  pushMatrix();
  rotate(radians(90));
  line(0, 0, 0, -800);
  popMatrix(); 
  
   
   
save("Warning_Laser_v4a.png");
}
code formatter
APA citation:
Russell, R. (2016, July 05, 07:26 am). Laser radiation.
     Retrieved December 15, 2017, from http://www.rupert.id.au/tutorials/processing/examples/laser/index.php

Last refreshed: December 15 2017. 03:47.56 am

rupert dot russell at acu dot edu dot au Support Wikipedia

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.


1442 visits since April 13, 2013