-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
69e9329
commit 207ff0e
Showing
4 changed files
with
73 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
= Paint Example | ||
|
||
This is a simple example showing how you can use the GPU T1. | ||
|
||
It gets any GPU and any Screen (built-in or via network), | ||
then it clears the screen and adds at the bottom a row of colors you can choose from. | ||
|
||
You can then use your cursor to click on such color and start painting on the screen! |
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,4 @@ | ||
name = "Paint Examples" | ||
short_description = "Simple Paint Program Example using GPU T1" | ||
tags = ["example"] | ||
authors = ["Panakotta00"] |
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,55 @@ | ||
-- get first T1 GPU avialable from PCI-Interface | ||
local gpu = computer.getPCIDevices(classes.GPUT1)[1] | ||
if not gpu then | ||
error("No GPU T1 found!") | ||
end | ||
|
||
-- get first Screen-Driver available from PCI-Interface | ||
local screen = computer.getPCIDevices(classes.FINComputerScreen)[1] | ||
-- if no screen found, try to find large screen from component network | ||
if not screen then | ||
local comp = component.findComponent(classes.Screen)[1] | ||
if not comp then | ||
error("No Screen found!") | ||
end | ||
screen = component.proxy(comp) | ||
end | ||
|
||
-- setup gpu | ||
event.listen(gpu) | ||
gpu:bindScreen(screen) | ||
w, h = gpu:getSize() | ||
|
||
-- clear background | ||
gpu:setBackground(0,0,0,0) | ||
gpu:fill(0, 0, w, h, " ", " ") | ||
|
||
-- setup color palette | ||
colors = {{0,0,0,0},{0,0,0,0},{1,0,0,1},{1,0,0,1},{0,1,0,1},{0,1,0,1},{0,0,1,1},{0,0,1,1},{1,1,1,1},{1,1,1,1}} | ||
|
||
-- draw color palette | ||
for i, color in ipairs(colors) do | ||
gpu:setBackground(color[1], color[2], color[3], color[4]) | ||
gpu:setText(i - 1, h - 1, " ") | ||
end | ||
|
||
gpu:setBackground(1,1,1,1) | ||
|
||
-- draw loop | ||
isDown = false | ||
while true do | ||
e, s, x, y = event.pull() | ||
if e == "OnMouseDown" then | ||
isDown = true | ||
-- is press on color palette, select color | ||
if y == h - 1 and x < #colors then | ||
color = colors[x + 1] | ||
gpu:setBackground(color[1], color[2], color[3], color[4]) | ||
end | ||
elseif e == "OnMouseUp" then | ||
isDown = false | ||
elseif e == "OnMouseMove" and not (y == h - 1 and x < #colors) and isDown then | ||
gpu:setText(x, y, " ") | ||
end | ||
gpu:flush() | ||
end |
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,6 @@ | ||
fin_version = ">= 0.3.20" | ||
|
||
[[EEPROM]] | ||
name = "EEPROM.lua" | ||
title = "EEPROM" | ||
description = "The example program you have to put into your EEPROM." |