相关文章推荐
干练的麻辣香锅  ·  EGL14.EglCreateWindowS ...·  6 月前    · 
不敢表白的勺子  ·  会议通知 | ...·  1 年前    · 
重情义的羽毛球  ·  python ...·  2 年前    · 
性感的小蝌蚪  ·  jquery的html,text,val ...·  2 年前    · 

Name

push()

Description

The push() function saves the current drawing style settings and transformations, while pop() restores these settings. Note that these functions are always used together. They allow you to change the style and transformation settings and later return to what you had. When a new state is started with push(), it builds on the current style and transform information.
push() stores information related to the current transformation state and style settings controlled by the following functions: rotate() , translate() , scale() , fill() , stroke() , tint() , strokeWeight() , strokeCap() , strokeJoin() , imageMode() , rectMode() , ellipseMode() , colorMode() , textAlign() , textFont() , textMode() , textSize() , textLeading() .
The push() and pop() functions were added with Processing 3.5. They can be used in place of pushMatrix() , popMatrix() , pushStyles() , and popStyles() . The difference is that push() and pop() control both the transformations (rotate, scale, translate) and the drawing styles at the same time.

Examples

  • fill(255);
    rect(0, 0, 200, 200);  // White rectangle
    push();
    translate(80, 70);
    fill(0);  
    rect(0, 0, 200, 200);  // Black rectangle
    pop();  // Restore original settings
    fill(100);  
    rect(40, 40, 200, 200);  // Gray rectangle
  • ellipse(0, 200, 133, 133);  // Left circle
    push();