[WED] 2021-12-22 TIL

MINBOKยท2021๋…„ 12์›” 22์ผ
0

๋ฉ‹์Ÿ์ด์‚ฌ์ž์ฒ˜๋Ÿผ

๋ชฉ๋ก ๋ณด๊ธฐ
15/19
post-custom-banner

chartjs

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>chartjs</title>

    <!-- chartjs cdn -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

    <!-- bootstrap css -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <div class="container">
        <div class="row">
            <div class="col-md-6">
                <canvas id="myChartOne"></canvas>
            </div>
            <div class="col-md-6">
                <canvas id="myChartTwo"></canvas>
            </div>
            <div class="col-md-6">
                <canvas id="myChartThree"></canvas>
            </div>
            <div class="col-md-6">
                <canvas id="myChartFour"></canvas>
            </div>
        </div>
    </div>
    <script>
        const labels = [
            '1์›”',
            '2์›”',
            '3์›”',
            '4์›”',
            '5์›”',
            '6์›”',
            '7์›”',
        ];
        const data = {
        labels: labels,
        datasets: [{
            label: '๋งค์ถœ์•ก ํ˜„ํ™ฉ(์–ต)',
            backgroundColor: 'rgb(255, 99, 132)',
            borderColor: 'rgb(255, 99, 132)',
            data: [1, 2, 5, 2, 2, 3, 4],
        }]
        };
        const data2 = {
        labels: labels,
        datasets: [{
            label: '๋งค์ถœ์•ก ํ˜„ํ™ฉ(์–ต)',
            backgroundColor: ['#ff0000', 'green', 'blue'], // rgba(255, 0, 0, 0.5), #ff0000
            borderColor: 'black',
            borderWidth: 5,
            hoverBorderWidth: 7,
            data: [1, 2, 5, 2, 2, 3, 4],
        }]
        };
        const data3 = {
        labels: labels,
        datasets: [{
            label: '๋งค์ถœ์•ก ํ˜„ํ™ฉ(์–ต)',
            backgroundColor: ['#ff0000', 'green', 'blue'], // rgba(255, 0, 0, 0.5), #ff0000
            borderColor: 'black',
            borderWidth: 5,
            hoverBorderWidth: 7,
            data: [1, 2, 5, 2, 2, 3, 4],
        }]
        };
        const data4 = {
        labels: labels,
        datasets: [{
            label: '๋งค์ถœ์•ก ํ˜„ํ™ฉ(์–ต)',
            backgroundColor: ['red', 'green', 'blue', 'pink', 'dodgerblue', 'gray', 'hotpink'], // rgba(255, 0, 0, 0.5), #ff0000
            // ๋ณดํ†ต ์ปฌ๋Ÿฌ๋ฅผ ํ•˜๋‚˜ํ•˜๋‚˜ ์ž…๋ ฅํ•˜์ง€์•Š๊ณ  function์„ ์‚ฌ์šฉํ•จ
            borderColor: 'black',
            borderWidth: 5,
            hoverBorderWidth: 7,
            data: [1, 2, 5, 2, 2, 3, 4],
        }]
        };
        const config = {
            type: 'line', // pie, bar, line, doughnut, polarArea
            data: data,
            options: {}
        };
        const config2 = {
            type: 'bar', // pie, bar, line, doughnut, polarArea
            data: data2,
            options: {}
        };
        const config3 = {
            type: 'bar', // pie, bar, line, doughnut, polarArea
            data: data3,
            options: {
                plugins:{
                    title:{
                        display: true,
                        text: '๋งค์ถœ์•ก!!!!',
                        color: 'red',
                        position: 'bottom',
                        padding: {
                            top: 10,
                            bottom: 10
                        }
                    },
                    legend: {
                        display: true,
                        position:'right',
                        labels:{
                            color:'blue'
                        }
                    }
                }
            }
        };
        const config4 = {
            type: 'pie', // pie, bar, line, doughnut, polarArea
            data: data4,
            options: {}
        };
    </script>
    <script>
        const myChartOne = new Chart(
            document.getElementById('myChartOne'),
            config
        );
        const myChartTwo = new Chart(
            document.getElementById('myChartTwo'),
            config2
        );
        const myChartThree = new Chart(
            document.getElementById('myChartThree'),
            config3
        );
        const myChartFour = new Chart(
            document.getElementById('myChartFour'),
            config4
        );
    </script>
</body>
</html>

Canvas

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Canvas tutorial</title>
</head>
<body>
    <canvas id="canvas"></canvas>
    <script>
        // ํƒœ๊ทธ ์„ ํƒ
        const canvas = document.getElementById('canvas');
        //  ์บ”๋ฒ„์Šค์—์„œ ์–ด๋–ป๊ฒŒ ๊ทธ๋ฆด์ง€(๋ Œ๋”๋ง) ์ปจํ…์ŠคํŠธ๋ฅผ ๋ฐ›์•„์˜ด
        const ctx = canvas.getContext('2d');

        // ๊ทธ๋ฆผ ๊ทธ๋ฆฌ๊ธฐ
        function drawRect(ctx) {
            // x, y : ์ขŒ์ธก ์ƒ๋‹จ ๊ธฐ์ค€ x, y ์ขŒํ‘œ
            // w๋Š” ๋„ˆ๋น„, h๋Š” ๋†’์ด
            let x = 30,
            y = 50,
            w = 150,
            h = 100;
            ctx.fillStyle = 'pink';
            ctx.fillRect(x, y, w, h);
        }
        // drawRect(ctx);

        function ์‚ผ๊ฐํ˜•(ctx){
            // ์ ์„ ํ•˜๋‚˜์”ฉ ์ฐ๋Š” ๋ฐฉ์‹
            // moveTo, lineTo๋ฅผ ๋ฐ”๊พธ๋ฉด ์‚ผ๊ฐํ˜• ๋ชจ์–‘์ด ๋ฐ”๋€œ
            ctx.beginPath()
            ctx.moveTo(25, 50);
            ctx.lineTo(100, 75);
            ctx.lineTo(100, 25);
            ctx.fillStyle = 'red';
            ctx.fill();
        }

        ์‚ผ๊ฐํ˜•(ctx);
    </script>
</body>
</html>

D3

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>D3</title>
    <script src="https://d3js.org/d3.v7.min.js"></script>
</head>
<body>
    <div class="canvas"></div>
    <script>
        const canvas = d3.select('.canvas');

        const svg = canvas.append('svg') //์ถ”๊ฐ€
            .attr('height', 1000) // ์†์„ฑ ์ง€์ •
            .attr('width', 1000);

        svg.append('text') // ์ถ”๊ฐ€, text ํ˜•ํƒœ๋กœ ์ถ”๊ฐ€
            .attr('x', 200)
            .attr('y', 200) // ์ขŒ์ธก ์ƒ๋‹จ ๊ธฐ์ค€ ์ขŒํ‘œ
            .attr('fill', 'black')
            .text('hello world')
            .style('font-weight', 'bold')
            .style('font-size', '34px');
        // .style('font-style', 'Nanum Pen Script'); 
        // google font style์€ ๋ฐ”๋กœ ์ ์šฉ ์•ˆ๋จ (import๋ฅผ ์‚ฌ์šฉํ•ด์„œ root์— ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ํ•ด๊ฒฐ ๊ฐ€๋Šฅ)

        svg.append('rect') // ์ถ”๊ฐ€, ์‚ฌ๊ฐํ˜• ํ˜•ํƒœ๋กœ ์ถ”๊ฐ€
            // .attr('x', 10)
            // .attr('y', 10)
            .attr('width', 200)
            .attr('height', 200)
            .attr('fill', 'pink')

        svg.append('circle') // ์ถ”๊ฐ€, ์› ํ˜•ํƒœ๋กœ ์ถ”๊ฐ€
            // .attr('x', 10)
            // .attr('y', 10)
            .attr('r', 50)
            .attr('cx', 200) // x ์ถ•
            .attr('cy', 200) // y ์ถ•
            .attr('fill', 'hotpink')

        svg.append('line')
            .attr('x1', 200) // x์ถ• ์‹œ์ž‘
            .attr('y1', 200) // y์ถ• ์‹œ์ž‘
            .attr('x2', 300) // x์ถ• ๋
            .attr('y2', 300) // y์ถ• ๋
            .attr('stroke', 'black')
        
    </script>
</body>
</html>
  • CSV(์˜์–ด: comma-separated values)๋Š” ๋ช‡ ๊ฐ€์ง€ ํ•„๋“œ๋ฅผ ์‰ผํ‘œ(,)๋กœ ๊ตฌ๋ถ„ํ•œ ํ…์ŠคํŠธ ๋ฐ์ดํ„ฐ ๋ฐ ํ…์ŠคํŠธ ํŒŒ์ผ์ด๋‹ค.
  • D3๋Š” ์„œ๋ฒ„ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰๋œ๋‹ค.

git ๋ช…๋ น์–ด (=๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด)

  • git add . : ๋ชจ๋“  ๋ณ€๊ฒฝ๋‚ด์—ญ์„ ์—…๋กœ๋“œ (.์€ all)

  • git commit -m '๋ฉ”์‹œ์ง€' : ์ปค๋ฐ‹ ๋ฉ”์„ธ์ง€ ์ž…๋ ฅ

  • git push : github์— ์˜ฌ๋ฆฌ๊ธฐ

  • git pull : pull ๋•ก๊ฒจ์˜ค๊ธฐ

  • git diff : ์–ด๋–ค ์ปค๋ฐ‹์ด ์ถ”๊ฐ€๋˜์—ˆ๋Š”์ง€ ํ™•์ธ

  • rm -rf ๊ฐœ๋ฆฌ : ๊ฐœ๋ฆฌ ํด๋” ์‚ญ์ œ

  • code . : vsc๋ฅผ ํ˜„์žฌ ํด๋” ๊ธฐ์ค€์œผ๋กœ ์—ด๊ธฐ

  • git log : ๋กœ๊ทธ ํ™•์ธ

  • touch

  • vi > i > esc + :wq!

  • shift+insert : ๋ถ™์—ฌ๋„ฃ๊ธฐ

  • git clone repo-link . : repo ๋ณต์‚ฌํ•ด์˜ค๊ธฐ (ํŒŒ์ผ๋งŒ * ๊ฐ€์ ธ์˜ค๊ธฐ, ๋งˆ์ง€๋ง‰์— . ์•ˆ์ฐ์œผ๋ฉด ์ƒˆ๋กœ์šด ํด๋”๊ฐ€ ์ƒ๊น€)

  • Settings > Manage access > Add people: ์ ‘๊ทผ ๊ถŒํ•œ ํ—ˆ์šฉ๋Œ

  • git branch : ๋ธŒ๋žœ์น˜ ๋ชฉ๋ก๊ณผ ํ˜„์žฌ ๋ธŒ๋žœ์น˜ ํ™•์ธ

  • git branch ์ด๋ฆ„ : ๋ธŒ๋žœ์น˜ ๋งŒ๋“ค๊ธฐ

git์œผ๋กœ ์ถ”์ ํ•˜๋Š” ํŒŒ์ผ์˜ 4๊ฐ€์ง€ ์ƒํƒœ

  1. untracked : ์ถ”์ ์•ˆ๋จ
  2. tracked : ์ˆ˜์ •์—†์Œ
  3. tracked : ์ˆ˜์ •ํ•จ
  4. tracked : ์Šคํ…Œ์ด์ง€๋จ(ํด๋”์— ์žˆ๋Š” ์ถ”์ ์•ˆ๋จ๊ณผ ์ˆ˜์ •ํ•จ์„ ์Šคํ…Œ์ด์ง€๋กœ ์˜ฌ๋ฆผ, commit ํ›„์—๋Š” ์ˆ˜์ •์—†์Œ์œผ๋กœ ๋˜๋Œ์•„๊ฐ)

warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory (๋ฌด์‹œํ•ด๋„ ๋˜๋Š” warning)

  • commit์€ ๊ธฐ๋Šฅ ๋‹จ์œ„๋กœ, ์ฝ”๋“œ ๋ช‡ ์ค„ ์ถ”๊ฐ€๋˜์—ˆ๋‹ค๊ณ  ์ปค๋ฐ‹ํ•˜๋ฉด ์•ˆ๋Œ (rollback์„ ์œ„ํ•จ)
  • add ํ•˜๋ฉด stage๋กœ ์ด๋™, commitํ•˜๋ฉด version์ด ์ถ”๊ฐ€๋จ
  • version๊ด€๋ฆฌ : ์ด์ „ ๋ฒ„์ „์œผ๋กœ ๋Œ์•„๊ฐˆ ์ˆ˜ ์žˆ์Œ

1๋ถ„์ฝ”๋”ฉ '์œ ์ค€๋ชจ'๋‹˜ ํŠน๊ฐ•

์ธํ„ฐ๋ ‰ํ‹ฐ๋ธŒ ์›น ๊ฐœ๋ฐœ,
์›น์—์„œ 3D๋ฅผ ๋‹ค๋ฃจ๋Š” ๋ฒ•(Three.js)

WebGL

WebGL์€ ์›น ๊ธฐ๋ฐ˜์˜ ๊ทธ๋ž˜ํ”ฝ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ด๋‹ค.
์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋ฅผ ํ†ตํ•ด์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ํ˜ธํ™˜์„ฑ์ด ์žˆ๋Š” ์›น ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒํ•œ 3D ๊ทธ๋ž˜ํ”ฝ์„
์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์ œ๊ณต๋œ๋‹ค.
์ €์ˆ˜์ค€์–ธ์–ด๋ผ Three.js๋“ฑ์˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ๋‹ค.

Three.js ๊ธฐ๋ณธ์š”์†Œ

  • Scene : object๋ฅผ ์˜ฌ๋ฆฌ๋Š” ๋ฌด๋Œ€
  • Camera : ์ด๋™ํ•˜๋ฉฐ ์คŒ์ธ/์•„์›ƒ ๋“ฑ ๊ฐ€๋Šฅ
  • Renderer : ๋ธŒ๋ผ์šฐ์ €์— ๋ณด์ด๋Š” ํ™”๋ฉด
  • Light(ํ•„์ˆ˜์š”์†Œ๋Š” ์•„๋‹˜)

์บ๋ฆญํ„ฐ

Mesh = Geometry(๋ชจ์–‘) + Material(์žฌ์งˆ)

post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€