GSDP:GAM100/CProcessing/sq()

From Inside
Jump to: navigation, search

sq()

Description

Takes in a float and returns its' squared value.

Parameters

sq(float value)

  • value - (float) The value to square.

Example

void square_init()
{
  textFont(defaultFont, 50);
  fill(color(0, 0, 0, 255));
  textAlign(CP_ALIGN_H_CENTER, CP_ALIGN_V_BOTTOM);
}

float random_value = 0.0f;
float time_elapsed = 1.5;
void square_update()
{
  background(color(255, 255, 255, 255));

  if (time_elapsed >= 1.5f)
  {
    random_value = randomRangeFloat(0.0f, 100.0f);
    time_elapsed = 0.0f;
  }
  else
    time_elapsed += dt();

  char num_string[128] = { 0 };
  sprintf_s(num_string, 128, "The square of %.2f is %.2f", random_value, sq(random_value));
  textBox(num_string, 0, canvasHeight / 2, canvasWidth);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>