Как я использую glutBitmapString () в C++ для рисования текста на экран?

Циклический просмотр данных и их передача в HTML

exampl1.gs:

function getData1(){
  var ss=SpreadsheetApp.getActive();
  var sh=ss.getSheetByName('Sheet48')
  var rg=sh.getDataRange();
  var vA=rg.getValues();
  var html='<style>td,th{border:1px solid #000;}</style><table>';
  if(vA.length>0){
    for(var i=0;i<vA.length;i++){
      html+='<tr>';
      for(var j=0;j<vA[i].length;j++){
        if(i==0){
          html+=Utilities.formatString('<th>%s</th>', vA[i][j]);
        }else{
          html+=Utilities.formatString('<td>%s</td>', vA[i][j]);
        }
      }
    }
    html+='<table>';
  }
  return html;
}

function showExample1Dialog(){
  var userInterface=HtmlService.createTemplateFromFile('example1').evaluate();
  SpreadsheetApp.getUi().showModelessDialog(userInterface, "Example1");
}

css1.html:

<style>
body {background-color:#ffffff;}
input{padding:2px;margin:2px;}
</style>

script1.html:

<script>
  $(function(){
    google.script.run
    .withSuccessHandler(function(hl){
      document.getElementById('table').innerHTML=hl;
    })
    .getData1();
  });
  console.log('My Code');
</script>

res1.html:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

example1.html:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    <?!= include('res1') ?>
    <?!= include('css1') ?>
  </head>
  <body>
   <div id="table"></div>

   <?!= include('script1') ?>
  </body>
</html>
9
задан KingNestor 12 February 2009 в 23:45
поделиться

1 ответ

Необходимо использовать glRasterPos установить растровое положение перед вызовом glutBitmapString(). Обратите внимание что каждый вызов к glutBitmapString() совершенствует растровое положение, таким образом, несколько последующих вызовов распечатают строки один за другим. Можно также установить цвет текста при помощи glColor(). Набор доступных шрифтов перечислен здесь.

// Draw blue text at screen coordinates (100, 120), where (0, 0) is the top-left of the
// screen in an 18-point Helvetica font
glRasterPos2i(100, 120);
glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
glutBitmapString(GLUT_BITMAP_HELVETICA_18, "text to render");
11
ответ дан 4 December 2019 в 20:25
поделиться
Другие вопросы по тегам:

Похожие вопросы: