Giter Site home page Giter Site logo

simple-radar-project's Introduction

Rules

Functions shouldn't change global origin

Example

draw_a_square_in_center should only draw a square in center. But it also change the global state of origin. Now poor circle is at right-bottom of scren.

void setup() {
  size(800, 600);
  background(236, 226, 225);
}

void draw() {
  draw_a_rectagle_in_center();
  circle(width/2, height/2, 50);
  
}

void draw_a_square_in_center() {
  translate(width/2, height/2);
  rect(0, 0, 100,100);
}
  • Functions don't depend on another

Solution

Use pushMatrix everywhre.

void setup() {
  size(800, 600);
  background(236, 226, 225);
}

void draw() {
  draw_a_rectagle_in_center();
  circle(width/2, height/2, 50);
  
}

void draw_a_square_in_center() {
  pushMatrix();
    translate(width/2, height/2);
    rect(0, 0, 100,100);
  popMatrix();
}

Functions shouldn't depend on another functions state

f(x) = y means y is only depend on x, and global variable in our case :(. A function can operate with global variables, but it shouldn't need caller function's state. Beacuse it's hard for extracting specific part later from that chapter.

Example

Wait what? Why bar didn't centered the circle. When I call from foo it did.

void setup() {
  size(800, 600);
  background(236, 226, 225);
}

void draw() {
  foo();
  bar();
}

void foo() {
  translate(width/2, height/2);
  circle(0, 0, 100);
  bar();
}

void bar(){
  circle(0, 0, 50);
}

Solution

TODO

Style

Function Template

void foo(){
    pushMatrix();

    // Matrix must made sandwich

    popMatrix();
}

Format

Use auto-format from processing's ide. It's bound to C-t (Control-t)

Assign values for visuals in setup()

Info

Processing doesn't follow Cartesian coordinate system.

It uses translate(x,y) to temporarirly changing orign. Each changing lives untill

  • Another translate(x,y)
  • Popped Matrix

simple-radar-project's People

Contributors

brsikinci avatar eugercek avatar kaangezgin avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.