RGB Color Codes Chart 🎨 (rapidtables.com

 

RGB Color Codes Chart 🎨

RGB Color Codes Chart RGB color picker | RGB color codes chart | RGB color space | RGB color format and calculation | RGB color table RGB color picker RGB color codes chart Hover with cursor on color to get the hex and decimal color codes below: RGB color

www.rapidtables.com

포토샵이나 그림툴, 사진 편집툴 등에 익숙한 사람들은 잘 알겠지만

 

 

Decimal Code R,G,B 각각의 값을 조절하면 조절할 때마다, 다른 추출색을 볼 수 있다.

빨강의 0~255 경우, 그린의 정도 0~255 경우, 파랑의 정도 0~255 경우를 다르게 설정할 수 있으므로

총 255 * 255 * 255 가지의 색을 볼 수 있는 것이다.

 

R,G,B 모두 char 형(8비트 정수형 데이터타입)을 사용한다.

2^8의 크기를 가진 데이터형으로 -128~127까지의 숫자를 나타낼 수 있는데,

다만, char, signed char, unsigned char로 총 3가지의 Variation이 있다.

signed 와 unsigned는 음수부터 2^8승 크기의 숫자를 나타내냐, 아니면 0부터 2^8승 크기의 숫자를

나타내냐의 차이로,

signed = -128 ~ 127 (음수표시 가능)

unsigned = 0 ~ 255 (양수만 표시 가능)이므로 R,G,B 는 모두 unsigned char이라는 것을 알 수 있다.

 

그렇다면 Vec{0.0f, 0.0f, 1.0f, 1.0f}과 같이 라는 0~1로 따지는 숫자 체계로

순서대로 R,G,B, Alpha(투명도)일 때, salmon을 보고 싶다면?

salmon #FA8072 (250,128,114)

R,G,B 각각이 0~1인 것을 255로 나눈 값으로 변환해주어야 한다.

Vec{0.0f, 0.0f, 1.0f, 1.0f}였던 것을

Vec4{250.0f / 255.0f, 128.0f / 255.0f, 114.0f / 255.0f, 1.0f}로 바꾸면

R,G,B 각각 0~1 사이의 값으로 각각 읽히게 되면서 정상적으로  salmon의 색감을 볼 수 있게 된다.

)

정의 피킹(Peeking) | Microsoft Learn

 

정의 피킹(Peeking)

정의 피킹을 사용하여 코드를 인라인으로 보고 편집하는 방법을 알아봅니다. 자세한 내용은 다음을 참조하십시오. https://msdn.microsoft.com/en-us/library/vstudio/dn160178%28v=vs.120%29.aspx 사용 가능한 비디오

learn.microsoft.com

 

How to: View and Edit Code by Using Peek Definition (Alt+F12) | Microsoft Learn

 

How to: View and Edit Code by Using Peek Definition (Alt+F12)

Table of contents How to: View and Edit Code by Using Peek Definition (Alt+F12) Article 04/28/2015 3 minutes to read In this article --> You can use the Peek Definition command to view and edit code without switching away from the code that you're writing.

learn.microsoft.com

 

'debugging' 카테고리의 다른 글

VScode에서 Debugging  (0) 2022.06.06

https://pronist.dev/143

 

JWT(JSON Web Token)의 개념부터 구현까지 알아보기

JWT(JSON Web Token) JWT 는 유저를 인증하고 식별하기 위한 토큰(Token)기반 인증이다. RFC 7519 에 자세한 명세가 나와있다. 토큰은 세션과는 달리 서버가 아닌 클라이언트에 저장되기 때문에 메모리나

pronist.dev

 

현재 경로와 파일이름 읽기

const path = require("path");

console.log(__dirname);
console.log(__filename);

내 노트북

윈도우라서 위와 같이 떴고,

유닉스 계열(맥, 리눅스)이었다면

회사 맥미니

위와 같이 표기된다.

'NodeJS' 카테고리의 다른 글

[NodeJS] Timer  (0) 2022.06.12
[Node.js] Events `EventEmitter`  (0) 2022.06.05

기본 package.json 구성

 

터미널 : npm init --yes 

package.json

{
  "name": "nodejs",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "type": "module", //자바스크립트 자체적으로 쓰는 모듈을 쓸 것이다.
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon app"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.18.1"
  },
  "devDependencies": {
    "nodemon": "^2.0.16"
  }
}

 

1초 기본 타이머

let num = 1;
setInterval(() => {
  console.log(num++);
}, 1000);

setInterval은 따로 중지하지 않는 이상, 계속 실행된다.

 

 

/**
 * The `timer` module exposes a global API for scheduling functions to
 * be called at some future period of time. Because the timer functions are
 * globals, there is no need to call `require('timers')` to use the API.
 *
 * The timer functions within Node.js implement a similar API as the timers API
 * provided by Web Browsers but use a different internal implementation that is
 * built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout).
 * @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/timers.js)
 */
declare module 'timers' {
    import { Abortable } from 'node:events';
    import { setTimeout as setTimeoutPromise, setImmediate as setImmediatePromise, setInterval as setIntervalPromise } from 'node:timers/promises';
    interface TimerOptions extends Abortable {
        /**
         * Set to `false` to indicate that the scheduled `Timeout`
         * should not require the Node.js event loop to remain active.
         * @default true
         */
        ref?: boolean | undefined;
    }
    let setTimeout: typeof global.setTimeout;
    let clearTimeout: typeof global.clearTimeout;
    let setInterval: typeof global.setInterval;
    let clearInterval: typeof global.clearInterval;
    let setImmediate: typeof global.setImmediate;
    let clearImmediate: typeof global.clearImmediate;
    global {
        namespace NodeJS {
            // compatibility with older typings
            interface Timer extends RefCounted {
                hasRef(): boolean;
                refresh(): this;
                [Symbol.toPrimitive](): number;
            }
            interface Immediate extends RefCounted {
                /**
                 * If true, the `Immediate` object will keep the Node.js event loop active.
                 * @since v11.0.0
                 */
                hasRef(): boolean;
                _onImmediate: Function; // to distinguish it from the Timeout class
            }
            interface Timeout extends Timer {
                /**
                 * If true, the `Timeout` object will keep the Node.js event loop active.
                 * @since v11.0.0
                 */
                hasRef(): boolean;
                /**
                 * Sets the timer's start time to the current time, and reschedules the timer to
                 * call its callback at the previously specified duration adjusted to the current
                 * time. This is useful for refreshing a timer without allocating a new
                 * JavaScript object.
                 *
                 * Using this on a timer that has already called its callback will reactivate the
                 * timer.
                 * @since v10.2.0
                 * @return a reference to `timeout`
                 */
                refresh(): this;
                [Symbol.toPrimitive](): number;
            }
        }
        function setTimeout<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timeout;
        // util.promisify no rest args compability
        // tslint:disable-next-line void-return
        function setTimeout(callback: (args: void) => void, ms?: number): NodeJS.Timeout;
        namespace setTimeout {
            const __promisify__: typeof setTimeoutPromise;
        }
        function clearTimeout(timeoutId: NodeJS.Timeout | undefined): void;
        function setInterval<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timer;
        // util.promisify no rest args compability
        // tslint:disable-next-line void-return
        function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timer;
        namespace setInterval {
            const __promisify__: typeof setIntervalPromise;
        }
        function clearInterval(intervalId: NodeJS.Timeout | undefined): void;
        function setImmediate<TArgs extends any[]>(callback: (...args: TArgs) => void, ...args: TArgs): NodeJS.Immediate;
        // util.promisify no rest args compability
        // tslint:disable-next-line void-return
        function setImmediate(callback: (args: void) => void): NodeJS.Immediate;
        namespace setImmediate {
            const __promisify__: typeof setImmediatePromise;
        }
        function clearImmediate(immediateId: NodeJS.Immediate | undefined): void;
        function queueMicrotask(callback: () => void): void;
    }
}
declare module 'node:timers' {
    export * from 'timers';
}

타이머 취소하기

let num = 1;
const interval = setInterval(() => {
  console.log(num++);
}, 1000);

setTimeout(() => {
  console.log("TimeOut!");
  clearInterval(interval);
}, 6000);

 

다만 타이머 계열 api들 보다 

process.nextTick(()=>{}) 이 콜스택에 들어가는 최우선 순위를 가장 먼저 가져간다.

 

 

코드 실행시간 측정

 

* setTimeout과 setImmediate는 거의 동일하게 작용

console.time()~console.timeEnd()로 실행~완료 시간을 측정할 수 있다.

console.time("");
setTimeout(() => {
  console.timeEnd("");
}, 0);  // 1.959ms 등 다양한 숫자가 나오면서 완벽히 0초를 보장하지는 않는다.

 

console.time("");
setImmediate(() => {
  console.timeEnd("");
}, 0); //역시나 2.391ms 등 다양한 숫자가 나오면서 완벽히 0초를 보장하지는 않는다.

완벽한 0초를 보장할 수 없는 이유 : 콜스택이 텅텅 비었다고 보장 받을 때까지 기다리는 시간이 있기 때문이다.

'NodeJS' 카테고리의 다른 글

[NodeJS] path  (0) 2022.06.12
[Node.js] Events `EventEmitter`  (0) 2022.06.05

<a> 링크 </a> : 이동의 맥락이므로 어디로..? 가 빠질 수 없다.

<a href="어디로"> 링크 </a>

<href 주소값 표기 방법>

 

 (1) 웹 URL

<a href="www.naver.com"> 링크 </a>

 (2) 프로젝트 내 위치에 대한 상대 경로

<a href="./SpecialPage.html"> 스페셜 페이지 </a>

SpecialPage.html

<h1>스페셜 페이지</h1>

(3) 페이지 내 이동

이동하고자 하는 태그 id 어트리뷰트를 적어준다.

<a href="#hello"> 다음 섹션으로 이동 </a>

(4) 메일 쓰기

<a href="mailto:아무아이디@gmail.com">아무에게 메일쓰기</a>

(5) 통화연결 : 모바일 페이지에서 사용가능

<a href="tel:01012345678>전화걸기</a>

<target="_blank">

기존의 브라우저 창이 아니라 새탭을 열어서 이동할 수 있도록 설정할 수 있는 어트리뷰트

<a href="www.naver.com" target="_blank"> 네이버 </a>

'MarkUp > HTML' 카테고리의 다른 글

[HTML/ Canvas] MDN 캔버스 기본 사용법(1)  (0) 2022.06.05

 

함수 선언 : 바디{ }가 없음

int sum(void); //매개변수가 없음

int sum(); //매개변수가 있는데, 아직 뭔지 모름

 

 

함수 정의 : 바디{ }가 있음

int sum(void) // 매개변수가 없음

{

}

 

int sum() // 매개변수가 없음

{

}

 

c에서는 매개변수 비어있으면 반드시 void를 써넣어주는 것이 좋다.

'unmanaged language C' 카테고리의 다른 글

[C] #include<파일명>의 동작 방법  (0) 2022.06.11

학습 조건 : clang 설치

: https://rinovation.tistory.com/170 해당 링크와

https://www.vompressor.com/clang-windws/ 해당 링크 참고하면서 clang 설치

개념은 https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=yong030389&logNo=221698524595 참고

 

왜냐하면 쉘이나 cmd 에서 

clang -std=c89 -W -Wall -pedantic-errors main.c

컴파일 flag로 컴파일할 예정이기 때문

(비쥬얼스튜디오 같은 IDE, 통합 개발 환경을 안 쓰기 때문)

clang -std=c89 -W -Wall -pedantic-errors main.c
//컴파일러, c89표준으로 컴파일하라, Warning 다 켜라, 문제들이 있으면 에러 많이 내뱉어라, 마지막에 main.c 빌드해라
//clang 실제 문서에서 각 컴파일 flag들이 무슨 역할 하는지 적혀있음
//컴파일할 때 어떤 옵션으로 할 것인지 써주는 것들
//main.c 대신에 *.c 하면 모든 C파일 컴파일해서 실행파일 만들어달라고 할 수 있다
//실행파일은 특별히 지정 안 하는 이상 다 a로 나온다.
//윈도우에서는 a.exe, 리눅스에서는 a.out
./a.out

echo $?

 

 

요약: c에서 컴파일 화는 과정, 어떤 라이브러리를 가져오겠다고 #include하는 과정은 <> 안에 있는 해당 텍스트 파일을 열어서 코드를 전부 복붙해오는 과정이라고 생각하면 된다.

 

헤더 파일을 include할 때 실제로 일어나는 일

 

전처리기는 컴파일을 시작하기 전에 include를 찾는다.

 

C의 Hello World (.c) (.h)

#include<stdio.h> //헤더 파일 발견
//C의 #include는 헤더 파일(*.h)을 열어서 그 내용을 복사해서
//아예 이 위치에 붙여버린다.

int main()
{
	printf("Hello World!");
	return 0;
}

즉, 위와 같은 상태로 컴파일을 돌리면

 include로 가져온 파일 속에 있는 모든 코드들도 먼저 같이 포함된 상태로

컴파일이 되는 것이다.

 

C#의 Hello World (.cs)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Hello_World
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            //Console.WriteLine()같은 함수는
            //C#언어를 사용하면 가져다 쓰라고 만든 함수, 변수들을 모아놓은 것들 중 하나
        }
    }
}

 

#include

: #이 붙는 것들은 전처리기(Preprocessor) 지시문

전처리기:

Preprocessor : Pre + processor, 프로세서 전

실제 처리하기 전(컴파일을 하기 전)에 텍스트를 복붙해주는 일을 함

C# C
using System; #include<stdio.h>

C#에서 using 지시문과 비슷한 일을 함

다른 파일에 구현된 함수나 변수를 사용할 수 있게 해줌

다만 C#처럼 똑똑하게 알아서 함수나 변수를 찾아주지는 않음

 

#include< >

: 괄호 안 파일 찾아서 포함해라!

<> 안의 단어(stdio.h)는 실제 디스크 상에 존재하는 파일 이름

 

실제로

C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt

경로로 파고들어가면

<stdio.h>

 

C 표준 라이브러리 중 일부(C Standard Library)

C 표준 라이브러리란 다음에 필요한 매크로, 자료형(data type), 함수 등을 모아 놓은 것이다.

- 문자열 처러

- 수학 계산

- 입출력 처리

- 메모리 관리

 

#include<stdio.h>

libc에서 표준 입출력(Standard Input and Output)을 담당

스트림 입출력에 관련된 함수들을 포함(콘솔 키보드 스트림이냐 파일 스트림이냐 다를 수는 있음)

c#의 System namespace와 비슷한 역할을 가진 라이브러리

stdio 라이브러리에 있는 함수 몇가지 예

- printf()

- scanf()

- fopen()

- fclose()

 

main(void) 함수

int main(void)
{
	return 0;
}

- 프로그램의 진입점 (entry point) : 언제나 하나 작성해놔야만 한다.

- c 코드를 빌드해서 나온 실행파일(.exe 또는 .out)을 실행하면 main(void) 함수가 자동적으로 실행됨

- 반드시 int 를 반환해야 함

- 최종 0 빈환: 프로그램을 실행하고 종료까지 하는데 아무 문제가 없었다는 뜻

- C는 모든 것이 절차적이기 때문에 main 함수에 c#과 달리 static이 안달려있다

 

        static void Main(string[] args)
        {
        }
        //C#에서 static은 OOP 언어인 것을 절차적으로 프로그래밍하기 위해서 우겨넣었다고 생각하면 쉽다

 

 

+ Recent posts