Simple Class sketch not working
in
Programming Questions
•
1 year ago
Hi,
I'm very new to classes but can't see why this class doesn't draw a simple line as it should.
Thanks,
Shane
I'm very new to classes but can't see why this class doesn't draw a simple line as it should.
- Field vectors;
- int r, g, b;
- void setup() {
- size(600, 300);
- smooth();
- noStroke();
- // x1, y1, x2, y2
- vectors = new Field(100, 100, 200, 200);
- }
- void draw() {
- frameRate(24);
- background(#DAEBF2);
- vectors.plot();
- }
- class Field {
- float x1, y1, x2, y2;
- //Constructor
- Field(float x1pos, float y1pos, float x2pos, float y2pos) {
- x1 = x1pos;
- y1 = y1pos;
- x2 = x2pos;
- y2 = y2pos;
- }
- void plot() {
- line(x1, y1, x2, y2);//this is just as an example
- }
- }
Thanks,
Shane
1