Combine overlay graphics in draw

I suggested that you:

I am using original code you provided below.
I added a template to create the starfield that I showed in the picture.

//Global Variables

int c,r; //rows/coloms
int space=10; //space
 int w=1920; //width of
  int h=1080;//height of
  
  float[][] tgrid;
  float cloud=0;

PGraphics pg;

void setup(){
  size(1920,1080,P3D);
  c=w/space;
  r=h/space; 
   tgrid=new float [c][r];
  
  pg = createGraphics(width, height, P2D);
  starfield();
 }

void draw(){
  
 cloud-=0.04; //cloud speed
  
  float moveY=cloud;
 for(int y=0; y<r;y++){
   float moveX=2;
    for(int x=0; x<c;x++){
      tgrid[x][y]=map(noise(moveX,moveY),0,1,-150,150); 
      moveX +=0.05;
    }
    moveY +=0.05;
 }
  
  background(0);
   stroke(#4C6FEA);
   noFill();
   
  
  image(pg, 0, 0); 
   
   translate(width/2,height/2);
   rotateX(PI/2.6);
   translate(-w/2,-h/2);
  for (int y=0; y<r-1;y++){
    beginShape(TRIANGLES);
    for(int x=0; x<c;x++){ 
      vertex(x*space,y*space,tgrid[x][y]);
      vertex(x*space,(y+1)*space,tgrid[x][y+1]);
    }
    endShape();
           
    }
    
 // starField(10,10,250,0,0);    
 myLine(140, 200, 1, 100, 1000, 1920, 100);
 myLine(#FFE079, 10, 20, -100, 0, 0, 30);
 

}

void myLine(int colour, int transparency, int weight, int size, int midpointX, int midpointY, int separation){

 for(int y = 0; y < 2000; y = y + separation) 
  {
 for (int x = 0; x < 2000; x = x + separation) 
  {
    stroke(colour, transparency);
    strokeWeight(weight);
    line(midpointX, midpointY, x + size , y + size);
      }
    }
}

void starfield()
  {
  pg.beginDraw();
  pg.background(0);

 // Code to generate a PGraphic with 1000 random stars removed
  
  pg.circle(width/2, height/2, 50);
  pg.endDraw();
  }

//I'm trying to put this function in as well but I have no idea how. I just want points to appear and disappear, or simply point that appear on my screen over the rest.

//void starField(float xstar, float ystar, int rstar, int gstar, int bstar, int fRate1, int fRate2) {

// frameRate(fRate1);
//  fill(0,30);
//  rect(0,0,width,height);
// rameRate(fRate2);
//fill(rstar,gstar,bstar);
//  noStroke();
//  ellipse(random(width),random(height),xstar,ystar);
//}

I will leave the remainder of this project with you.

You can complete the code in the template as an exercise if you wish.

I also provide other suggestions; decision is yours as this is your project.

I changed the subject.

:slight_smile:

1 Like