Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
obj/
bin/
src/gfx/*.c
src/gfx/*.h
src/gfx/*.8xv
.DS_Store
convimg.yaml.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"transfer_files":
[
"bin/DEMO.8xp"
],
"target":
{
"name": "DEMO",
"isASM": true
},
"sequence":
[
"action|launch",
"delay|300",
"hashWait|1",
"key|enter",
"hashWait|2",
"key|enter",
"hashWait|3",
"key|enter",
"hashWait|4",
"key|enter",
"hashWait|5"
],
"hashes":
{
"1":
{
"description": "Horizontal overlap right",
"start": "vram_start",
"size": "vram_8_size",
"expected_CRCs": [ "9D4993C1" ]
},
"2":
{
"description": "Horizontal overlap left",
"start": "vram_start",
"size": "vram_8_size",
"expected_CRCs": [ "BBD76F1C" ]
},
"3":
{
"description": "Vertical overlap down",
"start": "vram_start",
"size": "vram_8_size",
"expected_CRCs": [ "7C8FC7BE" ]
},
"4":
{
"description": "Vertical overlap up",
"start": "vram_start",
"size": "vram_8_size",
"expected_CRCs": [ "1C46A70A" ]
},
"5":
{
"description": "Test program exit",
"start": "vram_start",
"size": "vram_16_size",
"expected_CRCs": [ "FFAF89BA", "101734A5", "9DA19F44", "A32840C8", "349F4775" ]
}
}
}
15 changes: 15 additions & 0 deletions examples/library_examples/graphx/copy_rectangle_overlap/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ----------------------------
# Makefile Options
# ----------------------------

NAME = DEMO
ICON = icon.png
DESCRIPTION = "CE C Toolchain Demo"
COMPRESSED = NO

CFLAGS = -Wall -Wextra -Oz
CXXFLAGS = -Wall -Wextra -Oz

# ----------------------------

include $(shell cedev-config --makefile)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Copy Rectangle Overlap Demo

This example demonstrates `gfx_CopyRectangle` on overlapping regions of the same buffer.
It shows horizontal and vertical moves in both directions using memmove-like behavior.
118 changes: 118 additions & 0 deletions examples/library_examples/graphx/copy_rectangle_overlap/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#include <stdint.h>
#include <graphx.h>
#include <ti/getcsc.h>

static void draw_base_pattern(void)
{
uint8_t stripe;

gfx_FillScreen(239);

gfx_SetColor(26);
gfx_FillRectangle_NoClip(0, 0, GFX_LCD_WIDTH, 14);
gfx_SetColor(27);
gfx_FillRectangle_NoClip(0, GFX_LCD_HEIGHT - 12, GFX_LCD_WIDTH, 12);

for (stripe = 0; stripe < 6; stripe++)
{
static const uint8_t colors[6] = { 224, 9, 27, 56, 186, 250 };
uint24_t x = 24 + stripe * 40;

gfx_SetColor(colors[stripe]);
gfx_FillRectangle_NoClip(x, 24, 40, 120);

gfx_SetColor(0);
gfx_VertLine_NoClip(x, 24, 120);
gfx_VertLine_NoClip(x + 39, 24, 120);

gfx_SetColor(255);
gfx_FillRectangle_NoClip(x + 6, 34 + stripe * 12, 28, 6);
gfx_FillRectangle_NoClip(x + 6, 108 - stripe * 10, 28, 6);
}

gfx_SetColor(0);
gfx_Rectangle_NoClip(23, 23, 241, 121);

gfx_SetTextFGColor(255);
gfx_SetTextBGColor(26);
gfx_PrintStringXY("gfx_CopyRectangle overlap demo", 6, 3);

gfx_SetTextFGColor(255);
gfx_SetTextBGColor(27);
gfx_PrintStringXY("Black border = SRC White border = DST", 6, GFX_LCD_HEIGHT - 10);
}

static void draw_overlay(const char *title,
uint24_t src_x,
uint8_t src_y,
uint24_t dst_x,
uint8_t dst_y,
uint24_t width,
uint8_t height)
{
gfx_SetColor(0);
gfx_Rectangle_NoClip(src_x - 1, src_y - 1, width + 2, height + 2);

gfx_SetColor(255);
gfx_Rectangle_NoClip(dst_x - 1, dst_y - 1, width + 2, height + 2);

gfx_SetColor(255);
gfx_FillRectangle_NoClip(src_x + 2, src_y + 2, 24, 10);
gfx_SetColor(0);
gfx_Rectangle_NoClip(src_x + 2, src_y + 2, 24, 10);
gfx_SetTextFGColor(0);
gfx_SetTextBGColor(255);
gfx_PrintStringXY("SRC", src_x + 4, src_y + 3);

gfx_SetColor(255);
gfx_FillRectangle_NoClip(dst_x + 2, dst_y + 2, 24, 10);
gfx_SetColor(0);
gfx_Rectangle_NoClip(dst_x + 2, dst_y + 2, 24, 10);
gfx_SetTextFGColor(0);
gfx_SetTextBGColor(255);
gfx_PrintStringXY("DST", dst_x + 4, dst_y + 3);

gfx_SetColor(52);
gfx_FillRectangle_NoClip(188, 2, 130, 10);
gfx_SetTextFGColor(255);
gfx_SetTextBGColor(52);
gfx_PrintStringXY(title, 192, 3);
}

static void show_stage(void)
{
gfx_BlitBuffer();
while (!os_GetCSC())
{
}
}

int main(void)
{
gfx_Begin();
gfx_SetDrawBuffer();

draw_base_pattern();
gfx_CopyRectangle(gfx_buffer, gfx_buffer, 24, 18, 72, 18, 180, 64);
draw_overlay("Move right", 24, 18, 72, 18, 180, 64);
show_stage();

draw_base_pattern();
gfx_CopyRectangle(gfx_buffer, gfx_buffer, 72, 18, 24, 18, 180, 64);
draw_overlay("Move left", 72, 18, 24, 18, 180, 64);
show_stage();

draw_base_pattern();
gfx_CopyRectangle(gfx_buffer, gfx_buffer, 30, 24, 30, 60, 128, 96);
draw_overlay("Move down", 30, 24, 30, 60, 128, 96);
show_stage();

draw_base_pattern();
gfx_CopyRectangle(gfx_buffer, gfx_buffer, 30, 60, 30, 24, 128, 96);
draw_overlay("Move up", 30, 60, 30, 24, 128, 96);
show_stage();

gfx_End();

return 0;
}
Loading
Loading