Please Login First
×
Create a new article
Write your page title here:
We currently have 322 articles on Inside. Type your article name above or click on one of the titles below and start writing!



    Inside

    GSDP:GAM100/CProcessing/sq()

    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