SlideShare a Scribd company logo
Processing…
피노키오 13 교육부 김송현
Processing:
▪https://processing.org/
▪미디어 아트/교육용으로 사용되는 오픈소스 프로그래밍 언어
▪ Java 기반이지만, 객체지향 개념을 몰라도 쉽게 쓸 수 있다
▪ Python/CoffieScript/JavaScript 등으로도 작성 가능
▪시리얼 통신 가능!!!
▪ 아두이노와 연동할 수 있다
Before Beginning:
▪Java와 C의 다른 점
▪ 주소 개념을 사용하지 않는다 == 포인터가 없다
▪ 배열을 선언할 때
▪ int arr1[3];(x) int[] arr1 = new int[3];(o)
▪ int arr2[3][3];(x) int[][] arr2 = new int[3][3];(o)
▪ 자기보다 큰 자료형의 값을 대입할 땐 명시적 형 변환 필수!
▪ long num1; int num2 = num1; (x)
▪ long num1; int num2 = (int)num1; (o)
▪ bool(x) boolean(o)
▪ 논리 연산에는 무조건 boolean만 사용해야 한다
▪ 정수형과 호환 안 됨(시무룩)
▪ const 대신 final
Before Beginning:
▪좌표 읽는 법
x
y
O
← y좌표의 방향에 주의!
(a, b)
a
b
0th Program:
▪아무것도 안 한다
1st Program:
▪원하는 크기/배경색의 창을 띄워보자
void setup()
{
size(600, 400);
background(20, 20, 20);
}
1st Program:
1st Program:
▪void setup()
▪ 아두이노의 setup()과 비슷한 기능
▪ 프로그램이 시작될 때 단 한 번 실행됨
▪ 초기화할 때 사용함
▪void size(width, height)
▪ 화면의 사이즈를 지정해줄 수 있다(단위: pixel)
▪void background(R, G, B)
▪ 화면의 배경색을 설정할 수 있다(0<=R,G,B<=255, 정수)
2nd Program:
▪ 화면 정중앙에 사각형을 그려보자
void setup()
{
size(600, 400);
rectMode(CENTER);
}
void draw()
{
rect(width/2, height/2, 100, 100);
// draw()를 사용하긴 했지만, 여기서는 setup()에 작성해도 상관없다
}
2nd Program:
2nd Program:
▪width, height
▪ 화면 사이즈에 따라 알아서 값이 바뀌는 시스템 변수
▪void draw()
▪ 아두이노의 loop()와 비슷
▪void rect(x, y, w, h)
▪ 직사각형 그리는 함수
▪ x, y: 원점 좌표
▪ w, h: 너비, 높이
▪ 사실 옵션이 더 있는데, 패스합니다…
2nd Program:
▪void rectMode(mode)
▪ mode에 따라 rect()의 표현방식이 달라진다
↑ 똑같은 프로그램을 mode만 바꿔서 그려보았다
CENTER CORNER
(기본값)
CORNERS
RADIUS
h
w w
h
w
h
원점(x, y)
다른 점(w, h)
2nd Program: Going Further
▪도형의 윤곽선을 없애고 싶어요!
▪ rect()를 사용하기 전에 noStroke();를 추가해 보세요
▪윤곽선 말고 안쪽 색을 없애고 싶어요!
▪ rect()를 사용하기 전에 noFill();을 추가해 보세요
▪ noStroke();와 같이 쓰지 않도록 주의!
▪도형의 색깔을 바꾸고 싶어요!
▪ rect()를 사용하기 전에 fill(R, G, B, opacity);를 추가해 보세요
▪ 0<=opacity<=255 (값이 작을수록 투명해짐, 실수)
▪선 색깔은 바꿀 수 없나요?
▪ rect()를 사용하기 전에 stroke(R, G, B, opacity);를 추가해 보세요
2nd Program: Going Further
▪사각형 말고 다른 건 못 그리나요?
▪ 그릴 수 있습니다. 레퍼런스를 참조하세요
▪ 특히 quad()나 ellipse(), arc() 정도는 알아두는 것이 좋습니다
▪ quad(): 그냥 사각형(직사각형 말고)
▪ ellipse(): 원/타원
▪ arc(): 부채꼴/활꼴
▪사각형 그릴 때는 몰랐는데, 원을 그리니까 선이 깨져요ㅠ
▪ smooth() 함수를 이용해 보세요. 반대는 noSmooth()입니다
Assignment:
▪이 정도는 껌인 여러분을 위한 과제:
이거 해 보셈ㅋ
(단, 너비/높이가 달라져도 똑같이 동작할 것!)
Assignment:
▪아직까진 할만한 여러분을 위한 과제:
이건 좀 어려울걸
(hint : 세 부분으로 나누어 생각해 보자)

More Related Content

What's hot

[C++ korea] effective modern c++ study item 7 distinguish between () and {} w...
[C++ korea] effective modern c++ study item 7 distinguish between () and {} w...[C++ korea] effective modern c++ study item 7 distinguish between () and {} w...
[C++ korea] effective modern c++ study item 7 distinguish between () and {} w...
Seok-joon Yun
 
자바스크립트.
자바스크립트.자바스크립트.
자바스크립트.
Deoc Jin
 
[C++ korea] effective modern c++ study item8~10 정은식
[C++ korea] effective modern c++ study item8~10 정은식[C++ korea] effective modern c++ study item8~10 정은식
[C++ korea] effective modern c++ study item8~10 정은식
은식 정
 
Modern Effective C++ Item2 Understanding Auto type deducing
Modern Effective C++ Item2 Understanding Auto type deducingModern Effective C++ Item2 Understanding Auto type deducing
Modern Effective C++ Item2 Understanding Auto type deducing
건 손
 
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...Seok-joon Yun
 
Project#2말의여행 Hwp
Project#2말의여행 HwpProject#2말의여행 Hwp
Project#2말의여행 HwpKimjeongmoo
 
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
Seok-joon Yun
 
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
Seok-joon Yun
 
말의여행
말의여행말의여행
말의여행mil23
 
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
Seok-joon Yun
 
C언어 세미나 - 함수
C언어 세미나 - 함수C언어 세미나 - 함수
C언어 세미나 - 함수
SeungHyun Lee
 
Visual studio 2010
Visual studio 2010Visual studio 2010
Visual studio 2010
MinGeun Park
 
C++ 타입 추론
C++ 타입 추론C++ 타입 추론
C++ 타입 추론
Huey Park
 
[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3
Chris Ohk
 
[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26
Seok-joon Yun
 
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
Seok-joon Yun
 
이산치6보고서
이산치6보고서이산치6보고서
이산치6보고서KimChangHoen
 
Finding Functional Programming
Finding Functional Programming Finding Functional Programming
Finding Functional Programming
NAVER Engineering
 

What's hot (20)

[C++ korea] effective modern c++ study item 7 distinguish between () and {} w...
[C++ korea] effective modern c++ study item 7 distinguish between () and {} w...[C++ korea] effective modern c++ study item 7 distinguish between () and {} w...
[C++ korea] effective modern c++ study item 7 distinguish between () and {} w...
 
자바스크립트.
자바스크립트.자바스크립트.
자바스크립트.
 
[C++ korea] effective modern c++ study item8~10 정은식
[C++ korea] effective modern c++ study item8~10 정은식[C++ korea] effective modern c++ study item8~10 정은식
[C++ korea] effective modern c++ study item8~10 정은식
 
Modern Effective C++ Item2 Understanding Auto type deducing
Modern Effective C++ Item2 Understanding Auto type deducingModern Effective C++ Item2 Understanding Auto type deducing
Modern Effective C++ Item2 Understanding Auto type deducing
 
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
 
자료구조02
자료구조02자료구조02
자료구조02
 
Project#2말의여행 Hwp
Project#2말의여행 HwpProject#2말의여행 Hwp
Project#2말의여행 Hwp
 
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
 
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
 
말의여행
말의여행말의여행
말의여행
 
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
[C++ korea] Effective Modern C++ study item 19 use shared ptr for shared owne...
 
튜터링 #9 20120409
튜터링 #9 20120409튜터링 #9 20120409
튜터링 #9 20120409
 
C언어 세미나 - 함수
C언어 세미나 - 함수C언어 세미나 - 함수
C언어 세미나 - 함수
 
Visual studio 2010
Visual studio 2010Visual studio 2010
Visual studio 2010
 
C++ 타입 추론
C++ 타입 추론C++ 타입 추론
C++ 타입 추론
 
[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3
 
[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26
 
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
 
이산치6보고서
이산치6보고서이산치6보고서
이산치6보고서
 
Finding Functional Programming
Finding Functional Programming Finding Functional Programming
Finding Functional Programming
 

Similar to UNIST Pinocchio - Processing Lecture 1

[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary
Chris Ohk
 
학교에서 배우지 않는 C
학교에서 배우지 않는 C학교에서 배우지 않는 C
학교에서 배우지 않는 C
Heesuk Kang
 
문과생 대상 파이썬을 활용한 데이터 분석 강의
문과생 대상 파이썬을 활용한 데이터 분석 강의문과생 대상 파이썬을 활용한 데이터 분석 강의
문과생 대상 파이썬을 활용한 데이터 분석 강의
Kwangyoun Jung
 
GopherCon Korea 2015 - Python 개발자를 위한 Go (이경찬)
GopherCon Korea 2015 - Python 개발자를 위한 Go (이경찬)GopherCon Korea 2015 - Python 개발자를 위한 Go (이경찬)
GopherCon Korea 2015 - Python 개발자를 위한 Go (이경찬)
Kyoungchan Lee
 
Let's Go (golang)
Let's Go (golang)Let's Go (golang)
Let's Go (golang)
상욱 송
 
Open Jig Ware
Open Jig WareOpen Jig Ware
Open Jig Ware
Jinwook On
 
HI-ARC PS 101
HI-ARC PS 101HI-ARC PS 101
HI-ARC PS 101
Jae-yeol Lee
 
C++과 Lua script연동
C++과 Lua script연동C++과 Lua script연동
C++과 Lua script연동
선협 이
 

Similar to UNIST Pinocchio - Processing Lecture 1 (8)

[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary
 
학교에서 배우지 않는 C
학교에서 배우지 않는 C학교에서 배우지 않는 C
학교에서 배우지 않는 C
 
문과생 대상 파이썬을 활용한 데이터 분석 강의
문과생 대상 파이썬을 활용한 데이터 분석 강의문과생 대상 파이썬을 활용한 데이터 분석 강의
문과생 대상 파이썬을 활용한 데이터 분석 강의
 
GopherCon Korea 2015 - Python 개발자를 위한 Go (이경찬)
GopherCon Korea 2015 - Python 개발자를 위한 Go (이경찬)GopherCon Korea 2015 - Python 개발자를 위한 Go (이경찬)
GopherCon Korea 2015 - Python 개발자를 위한 Go (이경찬)
 
Let's Go (golang)
Let's Go (golang)Let's Go (golang)
Let's Go (golang)
 
Open Jig Ware
Open Jig WareOpen Jig Ware
Open Jig Ware
 
HI-ARC PS 101
HI-ARC PS 101HI-ARC PS 101
HI-ARC PS 101
 
C++과 Lua script연동
C++과 Lua script연동C++과 Lua script연동
C++과 Lua script연동
 

UNIST Pinocchio - Processing Lecture 1

  • 2. Processing: ▪https://processing.org/ ▪미디어 아트/교육용으로 사용되는 오픈소스 프로그래밍 언어 ▪ Java 기반이지만, 객체지향 개념을 몰라도 쉽게 쓸 수 있다 ▪ Python/CoffieScript/JavaScript 등으로도 작성 가능 ▪시리얼 통신 가능!!! ▪ 아두이노와 연동할 수 있다
  • 3. Before Beginning: ▪Java와 C의 다른 점 ▪ 주소 개념을 사용하지 않는다 == 포인터가 없다 ▪ 배열을 선언할 때 ▪ int arr1[3];(x) int[] arr1 = new int[3];(o) ▪ int arr2[3][3];(x) int[][] arr2 = new int[3][3];(o) ▪ 자기보다 큰 자료형의 값을 대입할 땐 명시적 형 변환 필수! ▪ long num1; int num2 = num1; (x) ▪ long num1; int num2 = (int)num1; (o) ▪ bool(x) boolean(o) ▪ 논리 연산에는 무조건 boolean만 사용해야 한다 ▪ 정수형과 호환 안 됨(시무룩) ▪ const 대신 final
  • 4. Before Beginning: ▪좌표 읽는 법 x y O ← y좌표의 방향에 주의! (a, b) a b
  • 6. 1st Program: ▪원하는 크기/배경색의 창을 띄워보자 void setup() { size(600, 400); background(20, 20, 20); }
  • 8. 1st Program: ▪void setup() ▪ 아두이노의 setup()과 비슷한 기능 ▪ 프로그램이 시작될 때 단 한 번 실행됨 ▪ 초기화할 때 사용함 ▪void size(width, height) ▪ 화면의 사이즈를 지정해줄 수 있다(단위: pixel) ▪void background(R, G, B) ▪ 화면의 배경색을 설정할 수 있다(0<=R,G,B<=255, 정수)
  • 9. 2nd Program: ▪ 화면 정중앙에 사각형을 그려보자 void setup() { size(600, 400); rectMode(CENTER); } void draw() { rect(width/2, height/2, 100, 100); // draw()를 사용하긴 했지만, 여기서는 setup()에 작성해도 상관없다 }
  • 11. 2nd Program: ▪width, height ▪ 화면 사이즈에 따라 알아서 값이 바뀌는 시스템 변수 ▪void draw() ▪ 아두이노의 loop()와 비슷 ▪void rect(x, y, w, h) ▪ 직사각형 그리는 함수 ▪ x, y: 원점 좌표 ▪ w, h: 너비, 높이 ▪ 사실 옵션이 더 있는데, 패스합니다…
  • 12. 2nd Program: ▪void rectMode(mode) ▪ mode에 따라 rect()의 표현방식이 달라진다 ↑ 똑같은 프로그램을 mode만 바꿔서 그려보았다 CENTER CORNER (기본값) CORNERS RADIUS h w w h w h 원점(x, y) 다른 점(w, h)
  • 13. 2nd Program: Going Further ▪도형의 윤곽선을 없애고 싶어요! ▪ rect()를 사용하기 전에 noStroke();를 추가해 보세요 ▪윤곽선 말고 안쪽 색을 없애고 싶어요! ▪ rect()를 사용하기 전에 noFill();을 추가해 보세요 ▪ noStroke();와 같이 쓰지 않도록 주의! ▪도형의 색깔을 바꾸고 싶어요! ▪ rect()를 사용하기 전에 fill(R, G, B, opacity);를 추가해 보세요 ▪ 0<=opacity<=255 (값이 작을수록 투명해짐, 실수) ▪선 색깔은 바꿀 수 없나요? ▪ rect()를 사용하기 전에 stroke(R, G, B, opacity);를 추가해 보세요
  • 14. 2nd Program: Going Further ▪사각형 말고 다른 건 못 그리나요? ▪ 그릴 수 있습니다. 레퍼런스를 참조하세요 ▪ 특히 quad()나 ellipse(), arc() 정도는 알아두는 것이 좋습니다 ▪ quad(): 그냥 사각형(직사각형 말고) ▪ ellipse(): 원/타원 ▪ arc(): 부채꼴/활꼴 ▪사각형 그릴 때는 몰랐는데, 원을 그리니까 선이 깨져요ㅠ ▪ smooth() 함수를 이용해 보세요. 반대는 noSmooth()입니다
  • 15. Assignment: ▪이 정도는 껌인 여러분을 위한 과제: 이거 해 보셈ㅋ (단, 너비/높이가 달라져도 똑같이 동작할 것!)
  • 16. Assignment: ▪아직까진 할만한 여러분을 위한 과제: 이건 좀 어려울걸 (hint : 세 부분으로 나누어 생각해 보자)