GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Processing
  • Download
  • Reference
  • Environment
  • Libraries
  • Tools
  • Wiki
  • Tutorials
  • Examples
  • Books
  • Forum
  • Overview
  • People
  • Privacy

This view

  • Original page
  • New address

GeezerVison is showing processing.org — Object / Reference

Reference+
Documentation→Reference→Data→Composite

Class Name

Object

Description

Objects are instances of classes. A class is a grouping of related methods (functions) and fields (variables and constants).

Examples

  • // Declare and construct two objects (h1, h2) from the class HLine 
    HLine h1 = new HLine(20, 2.0); 
    HLine h2 = new HLine(50, 2.5); 
     
    void setup() 
    {
      size(200, 200);
      frameRate(30);
    }
    
    void draw() { 
      background(204);
      h1.update(); 
      h2.update();  
    } 
     
    class HLine { 
      float ypos, speed; 
      HLine (float y, float s) {  
        ypos = y; 
        speed = s; 
      } 
      void update() { 
        ypos += speed; 
        if (ypos > height) { 
          ypos = 0; 
        } 
        line(0, ypos, width, ypos); 
      } 
    } 
    

Parameters

  • ClassNamethe class from which to create the new object
  • instanceNamethe name for the new object

Related

  • class
Creative Commons License

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

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.