Skip to content

Commit 727a90c

Browse files
committed
REVIEWED: Formatting to follow raylib conventions
1 parent 6c3ef8d commit 727a90c

33 files changed

+244
-299
lines changed

examples/audio/audio_fft_spectrum_visualizer.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ int main(void)
148148
CaptureFrame(&fft, audioSamples);
149149
RenderFrame(&fft, &fftImage);
150150
UpdateTexture(fftTexture, fftImage.data);
151-
//------------------------------------------------------------------------------
151+
//----------------------------------------------------------------------------------
152152

153153
// Draw
154154
//----------------------------------------------------------------------------------
@@ -269,20 +269,17 @@ static void CaptureFrame(FFTData *fftData, const float *audioSamples)
269269

270270
fftData->lastFftTime = GetTime();
271271
memcpy(fftData->fftHistory[fftData->historyPos], smoothedSpectrum, sizeof(smoothedSpectrum));
272-
fftData->historyPos = (fftData->historyPos + 1) % fftData->fftHistoryLen;
272+
fftData->historyPos = (fftData->historyPos + 1)%fftData->fftHistoryLen;
273273
}
274274

275275
static void RenderFrame(const FFTData *fftData, Image *fftImage)
276276
{
277277
double framesSinceTapback = floor(fftData->tapbackPos/WINDOW_TIME);
278278
framesSinceTapback = Clamp(framesSinceTapback, 0.0, fftData->fftHistoryLen - 1);
279279

280-
int historyPosition = (fftData->historyPos - 1 - (int)framesSinceTapback) % fftData->fftHistoryLen;
281-
if (historyPosition < 0)
282-
historyPosition += fftData->fftHistoryLen;
280+
int historyPosition = (fftData->historyPos - 1 - (int)framesSinceTapback)%fftData->fftHistoryLen;
281+
if (historyPosition < 0) historyPosition += fftData->fftHistoryLen;
283282

284283
const float *amplitude = fftData->fftHistory[historyPosition];
285-
for (int bin = 0; bin < BUFFER_SIZE; bin++) {
286-
ImageDrawPixel(fftImage, bin, FFT_ROW, ColorFromNormalized((Vector4){ amplitude[bin], UNUSED_CHANNEL, UNUSED_CHANNEL, UNUSED_CHANNEL }));
287-
}
284+
for (int bin = 0; bin < BUFFER_SIZE; bin++) ImageDrawPixel(fftImage, bin, FFT_ROW, ColorFromNormalized((Vector4){ amplitude[bin], UNUSED_CHANNEL, UNUSED_CHANNEL, UNUSED_CHANNEL }));
288285
}

examples/audio/audio_music_stream.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ int main(void)
3535

3636
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
3737
bool pause = false; // Music playing paused
38-
38+
3939
float pan = 0.0f; // Default audio pan center [-1.0f..1.0f]
4040
SetMusicPan(music, pan);
41-
41+
4242
float volume = 0.8f; // Default audio volume [0.0f..1.0f]
4343
SetMusicVolume(music, volume);
4444

@@ -67,29 +67,29 @@ int main(void)
6767
if (pause) PauseMusicStream(music);
6868
else ResumeMusicStream(music);
6969
}
70-
70+
7171
// Set audio pan
72-
if (IsKeyDown(KEY_LEFT))
72+
if (IsKeyDown(KEY_LEFT))
7373
{
7474
pan -= 0.05f;
7575
if (pan < -1.0f) pan = -1.0f;
7676
SetMusicPan(music, pan);
7777
}
78-
else if (IsKeyDown(KEY_RIGHT))
78+
else if (IsKeyDown(KEY_RIGHT))
7979
{
8080
pan += 0.05f;
8181
if (pan > 1.0f) pan = 1.0f;
8282
SetMusicPan(music, pan);
8383
}
84-
84+
8585
// Set audio volume
86-
if (IsKeyDown(KEY_DOWN))
86+
if (IsKeyDown(KEY_DOWN))
8787
{
8888
volume -= 0.05f;
8989
if (volume < 0.0f) volume = 0.0f;
9090
SetMusicVolume(music, volume);
9191
}
92-
else if (IsKeyDown(KEY_UP))
92+
else if (IsKeyDown(KEY_UP))
9393
{
9494
volume += 0.05f;
9595
if (volume > 1.0f) volume = 1.0f;
@@ -109,7 +109,7 @@ int main(void)
109109
ClearBackground(RAYWHITE);
110110

111111
DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY);
112-
112+
113113
DrawText("LEFT-RIGHT for PAN CONTROL", 320, 74, 10, DARKBLUE);
114114
DrawRectangle(300, 100, 200, 12, LIGHTGRAY);
115115
DrawRectangleLines(300, 100, 200, 12, GRAY);
@@ -121,7 +121,7 @@ int main(void)
121121

122122
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, LIGHTGRAY);
123123
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, LIGHTGRAY);
124-
124+
125125
DrawText("UP-DOWN for VOLUME CONTROL", 320, 334, 10, DARKGREEN);
126126
DrawRectangle(300, 360, 200, 12, LIGHTGRAY);
127127
DrawRectangleLines(300, 360, 200, 12, GRAY);

examples/audio/audio_raw_stream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ int main(void)
166166
memcpy(writeBuf + writeCursor, data + readCursor, writeLength*sizeof(short));
167167
168168
// Update cursors and loop audio
169-
readCursor = (readCursor + writeLength) % waveLength;
169+
readCursor = (readCursor + writeLength)%waveLength;
170170
171171
writeCursor += writeLength;
172172
}

examples/audio/audio_sound_positioning.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ int main(void)
9595

9696
CloseWindow(); // Close window and OpenGL context
9797
//--------------------------------------------------------------------------------------
98-
98+
9999
return 0;
100100
}
101101

examples/core/core_highdpi_testbed.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ int main(void)
2727
const int screenWidth = 800;
2828
const int screenHeight = 450;
2929

30+
SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE);
3031
InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi testbed");
3132

32-
// TODO: Load resources / Initialize variables at this point
33+
int gridSpacing = 40; // Grid spacing in pixels
3334

3435
SetTargetFPS(60);
3536
//--------------------------------------------------------------------------------------
@@ -48,11 +49,12 @@ int main(void)
4849

4950
ClearBackground(RAYWHITE);
5051

51-
// TODO: Draw everything that requires to be drawn at this point
52+
// Draw grid
53+
for (int h = 0; h < 20; h++) DrawLine(0, h*gridSpacing, GetRenderWidth(), h*gridSpacing, LIGHTGRAY);
54+
for (int v = 0; v < 40; v++) DrawLine(v*gridSpacing, 0, v*gridSpacing, GetScreenHeight(), LIGHTGRAY);
5255

53-
DrawLineEx((Vector2){ 0, 0 }, (Vector2){ screenWidth, screenHeight }, 2.0f, RED);
54-
DrawLineEx((Vector2){ 0, screenHeight }, (Vector2){ screenWidth, 0 }, 2.0f, RED);
55-
DrawText("example base code template", 260, 400, 20, LIGHTGRAY);
56+
// Draw UI info
57+
DrawText(TextFormat("SCREEN SIZE: %ix%i", GetScreenWidth(), GetScreenHeight()), 10, 10, 20, BLACK);
5658

5759
EndDrawing();
5860
//----------------------------------------------------------------------------------

examples/core/core_input_gestures_testbed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ int main(void)
202202
DrawText("Log", (int)gestureLogPosition.x, (int)gestureLogPosition.y, 20, BLACK);
203203

204204
// Loop in both directions to print the gesture log array in the inverted order (and looping around if the index started somewhere in the middle)
205-
for (i = 0, ii = gestureLogIndex; i < GESTURE_LOG_SIZE; i++, ii = (ii + 1) % GESTURE_LOG_SIZE) DrawText(gestureLog[ii], (int)gestureLogPosition.x, (int)gestureLogPosition.y + 410 - i*20, 20, (i == 0 ? gestureColor : LIGHTGRAY));
205+
for (i = 0, ii = gestureLogIndex; i < GESTURE_LOG_SIZE; i++, ii = (ii + 1)%GESTURE_LOG_SIZE) DrawText(gestureLog[ii], (int)gestureLogPosition.x, (int)gestureLogPosition.y + 410 - i*20, 20, (i == 0 ? gestureColor : LIGHTGRAY));
206206
Color logButton1Color, logButton2Color;
207207
switch (logMode)
208208
{

examples/core/core_input_multitouch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int main(void)
4646
// Clamp touch points available ( set the maximum touch points allowed )
4747
if (tCount > MAX_TOUCH_POINTS) tCount = MAX_TOUCH_POINTS;
4848
// Get touch points positions
49-
for (int i = 0; i < tCount; ++i) touchPositions[i] = GetTouchPosition(i);
49+
for (int i = 0; i < tCount; i++) touchPositions[i] = GetTouchPosition(i);
5050
//----------------------------------------------------------------------------------
5151

5252
// Draw
@@ -55,7 +55,7 @@ int main(void)
5555

5656
ClearBackground(RAYWHITE);
5757

58-
for (int i = 0; i < tCount; ++i)
58+
for (int i = 0; i < tCount; i++)
5959
{
6060
// Make sure point is not (0, 0) as this means there is no touch for it
6161
if ((touchPositions[i].x > 0) && (touchPositions[i].y > 0))

examples/core/core_monitor_detector.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ int main(void)
142142
Vector2 windowPosition = (Vector2){ (GetWindowPosition().x + monitorOffsetX)*monitorScale + 140, GetWindowPosition().y*monitorScale + 80 };
143143

144144
// Draw window position based on monitors
145-
DrawRectangleV(windowPosition, (Vector2){screenWidth * monitorScale, screenHeight * monitorScale}, Fade(GREEN, 0.5));
145+
DrawRectangleV(windowPosition, (Vector2){screenWidth*monitorScale, screenHeight*monitorScale}, Fade(GREEN, 0.5));
146146
}
147147
else DrawRectangleLinesEx(rec, 5, GRAY);
148148
}

examples/core/core_undo_redo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,15 @@ int main(void)
187187
if (lastUndoIndex > firstUndoIndex)
188188
{
189189
for (int i = firstUndoIndex; i < currentUndoIndex; i++)
190-
DrawRectangleRec((Rectangle){gridPosition.x + states[i].cell.x * GRID_CELL_SIZE, gridPosition.y + states[i].cell.y * GRID_CELL_SIZE,
190+
DrawRectangleRec((Rectangle){gridPosition.x + states[i].cell.x*GRID_CELL_SIZE, gridPosition.y + states[i].cell.y*GRID_CELL_SIZE,
191191
GRID_CELL_SIZE, GRID_CELL_SIZE }, LIGHTGRAY);
192192
}
193193
else if (firstUndoIndex > lastUndoIndex)
194194
{
195195
if ((currentUndoIndex < MAX_UNDO_STATES) && (currentUndoIndex > lastUndoIndex))
196196
{
197197
for (int i = firstUndoIndex; i < currentUndoIndex; i++)
198-
DrawRectangleRec((Rectangle) { gridPosition.x + states[i].cell.x * GRID_CELL_SIZE, gridPosition.y + states[i].cell.y * GRID_CELL_SIZE,
198+
DrawRectangleRec((Rectangle) { gridPosition.x + states[i].cell.x*GRID_CELL_SIZE, gridPosition.y + states[i].cell.y*GRID_CELL_SIZE,
199199
GRID_CELL_SIZE, GRID_CELL_SIZE }, LIGHTGRAY);
200200
}
201201
else

0 commit comments

Comments
 (0)