Merge pull request #694 from pimoroni/patch-cosmic-paint

Cosmic Unicorn: Port paint example.
This commit is contained in:
Philip Howard 2023-02-27 14:30:02 +00:00 committed by GitHub
commit 9c1c9e6b8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 14 deletions

View File

@ -1,6 +1,6 @@
# Galactic Paint
# Cosmic Paint
Galactic Paint lets you paint pixels onto your Galatic Unicorn over WiFi, in realtime!
Cosmic Paint lets you paint pixels onto your Cosmic Unicorn over WiFi, in realtime!
## Setting Up

View File

@ -2,15 +2,15 @@ import os
from microdot_asyncio import Microdot, send_file
from microdot_asyncio_websocket import with_websocket
from phew import connect_to_wifi
from galactic import GalacticUnicorn
from picographics import PicoGraphics, DISPLAY_GALACTIC_UNICORN as DISPLAY
from cosmic import CosmicUnicorn
from picographics import PicoGraphics, DISPLAY_COSMIC_UNICORN as DISPLAY
from WIFI_CONFIG import SSID, PSK
gu = GalacticUnicorn()
cu = CosmicUnicorn()
graphics = PicoGraphics(DISPLAY)
mv_graphics = memoryview(graphics)
gu.set_brightness(0.5)
cu.set_brightness(0.5)
WIDTH, HEIGHT = graphics.get_bounds()
@ -24,12 +24,12 @@ server = Microdot()
@server.route("/", methods=["GET"])
def route_index(request):
return send_file("galactic_paint/index.html")
return send_file("cosmic_paint/index.html")
@server.route("/static/<path:path>", methods=["GET"])
def route_static(request, path):
return send_file(f"galactic_paint/static/{path}")
return send_file(f"cosmic_paint/static/{path}")
def get_pixel(x, y):
@ -86,7 +86,7 @@ async def echo(request, ws):
except ValueError:
if data == "show":
gu.update(graphics)
cu.update(graphics)
if data == "fill":
data = await ws.receive()

View File

@ -2,14 +2,14 @@
<html>
<head>
<meta charset="utf-8">
<title>Galactic Paint</title>
<title>Cosmic Paint</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="//cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/static/paint.css">
</head>
<body>
<div class="window">
<h1>Galactic Paint</h1>
<h1>Cosmic Paint</h1>
<table cellspacing="0" cellpadding="0" border-collapse="collapse">
<tbody></tbody>
</table>

View File

@ -64,7 +64,7 @@ body {
}
.window {
width: 976px;
width: 640px;
position: relative;
background: #0E071A;
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.5);

View File

@ -1,5 +1,7 @@
'use strict';
var WIDTH = 32;
var HEIGHT = 32;
var md = false;
var color = tinycolor('#840000');
var update;
@ -20,9 +22,9 @@ $(document).ready(function(){
return false;
});
for (var y = 0; y < 11; y++) {
for (var y = 0; y < HEIGHT; y++) {
var row = $('<tr></tr>');
for (var x = 0; x < 53; x++) {
for (var x = 0; x < WIDTH; x++) {
row.append('<td></td>');
}
$('tbody').append(row);