forked from lowfatcode/pretty-poly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jonathan Williamson
committed
Sep 23, 2023
1 parent
b505ccf
commit 11ab525
Showing
8 changed files
with
145 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "C/C++: clang++ build and debug active file", | ||
"type": "cppdbg", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/build/${relativeFileDirname}/${fileBasenameNoExtension}", | ||
"args": [], | ||
"stopAtEntry": false, | ||
"cwd": "${workspaceFolder}", | ||
"environment": [], | ||
"externalConsole": false, | ||
"MIMode": "lldb", | ||
"preLaunchTask": "C/C++: clang++ build active file", | ||
"postDebugTask": "Open image" | ||
} | ||
] | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "C/C++: clang++ build and debug active file", | ||
"type": "cppdbg", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/build/${relativeFileDirname}/${fileBasenameNoExtension}", | ||
"args": [], | ||
"stopAtEntry": false, | ||
"cwd": "${workspaceFolder}", | ||
"environment": [], | ||
"externalConsole": false, | ||
"MIMode": "lldb", | ||
"preLaunchTask": "C/C++: clang++ build active file", | ||
"postDebugTask": "Open image" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "shell", | ||
"label": "C/C++: clang++ build active file", | ||
"command": "/usr/bin/clang++", | ||
"args": [ | ||
"-std=c++17", | ||
"-stdlib=libc++", | ||
"-g", | ||
"${file}", | ||
"-I", | ||
".", | ||
"-o", | ||
"${workspaceFolder}/build/${relativeFileDirname}/${fileBasenameNoExtension}" | ||
], | ||
"options": { | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
"problemMatcher": ["$gcc"], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"detail": "Task generated by Debugger." | ||
}, | ||
{ | ||
"type": "shell", | ||
"label": "Open image", | ||
"command": "open", | ||
"args": [ | ||
"/tmp/out.png" | ||
] | ||
} | ||
] | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "shell", | ||
"label": "C/C++: clang++ build active file", | ||
"command": "/usr/bin/clang++", | ||
"args": [ | ||
"-std=c++17", | ||
"-stdlib=libc++", | ||
"-g", | ||
"${file}", | ||
"-I", | ||
".", | ||
"-o", | ||
"${workspaceFolder}/build/${relativeFileDirname}/${fileBasenameNoExtension}" | ||
], | ||
"options": { | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
"problemMatcher": [ | ||
"$gcc" | ||
], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"detail": "Task generated by Debugger." | ||
}, | ||
{ | ||
"type": "shell", | ||
"label": "Open image", | ||
"command": "open", | ||
"args": [ | ||
"/tmp/out.png" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
|
||
project(examples C) | ||
|
||
set(CMAKE_C_STANDARD 17) | ||
|
||
project(examples C) | ||
|
||
include_directories( | ||
. | ||
) | ||
|
||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror") | ||
|
||
add_subdirectory(examples) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
include(character.cmake) | ||
include(geometry.cmake) | ||
include(logo.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#define STB_IMAGE_WRITE_IMPLEMENTATION | ||
#include "stb_image_write.h" | ||
|
||
#define PP_DEBUG | ||
|
||
#include "pretty-poly.h" | ||
|
||
const int WIDTH = 1024; | ||
const int HEIGHT = 1024; | ||
uint32_t buffer[WIDTH][HEIGHT]; | ||
|
||
|
||
void callback(const pp_tile_t tile) { | ||
for(int32_t y = 0; y < tile.bounds.h; y++) { | ||
for(int32_t x = 0; x < tile.bounds.w; x++) { | ||
uint8_t alpha = pp_tile_get_value(&tile, x, y); | ||
uint8_t r = 234; | ||
uint8_t g = 78; | ||
uint8_t b = 63; | ||
buffer[y + tile.bounds.y][x + tile.bounds.x] = alpha << 24 | b << 16 | g << 8 | r; | ||
} | ||
} | ||
} | ||
|
||
int main() { | ||
//(callback, PP_AA_X4, {0, 0, WIDTH, HEIGHT}); | ||
|
||
pp_tile_callback(callback); | ||
pp_antialias(PP_AA_X4); | ||
pp_clip((pp_rect_t){0, 0, WIDTH, HEIGHT}); | ||
|
||
for(int y = 0; y < HEIGHT; y++) { | ||
for(int x = 0; x < WIDTH; x++) { | ||
buffer[x][y] = ((x / 8) + (y / 8)) % 2 == 0 ? 0xff302010 : 0xff000000; | ||
} | ||
} | ||
|
||
pp_point_t square_outline[] = { // outline contour | ||
{-256, -256}, {256, -256}, {256, 256}, {-256, 256} | ||
}; | ||
|
||
pp_contour_t square_contours[] = { | ||
(pp_contour_t){.points = square_outline, .point_count = sizeof(square_outline) / sizeof(pp_point_t)} | ||
}; | ||
|
||
pp_polygon_t square = (pp_polygon_t){.contours = square_contours, .contour_count = sizeof(square_contours) / sizeof(pp_contour_t)}; | ||
|
||
pp_mat3_t transform = pp_mat3_identity(); | ||
transform = pp_mat3_mul(transform, pp_mat3_translation(512, 512)); | ||
transform = pp_mat3_mul(transform, pp_mat3_rotation(45)); | ||
pp_transform(&transform); | ||
draw_polygon(square); | ||
|
||
stbi_write_png("/tmp/out.png", WIDTH, HEIGHT, 4, (void *)buffer, WIDTH * sizeof(uint32_t)); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
add_executable( | ||
character | ||
character.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters