## RaspberryPi Stacks

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

Raspberry Pi stacks collection #69 = Gears.livecode

My goal was to make gears with polygons only. The animation is again a rotation of the polygons, no use of images. This is a mathematical "prototype" approach for the simplest case, it's much more complicated in mechanical engeneering (for a first good overview see https://en.wikipedia.org/wiki/Gear).

You can adjust (also while the animation is running)
• N = the num of teeth (2,4,6,8,12,16,24,48) for each of the three gears.
The radius is then set to keep the ratio radius/N = constant (here constant=10).
• the "rotation speed" of millisecs per rotation-step (step is here 48/N degrees).
Each of the loops (one angle status) computes the rotated points for the three gears.
The average needed times per loop are
• On a Raspberry Pi 2: Around 35|65 ms on LC 6|LC 7,
• On a Raspi B: Around 135|255 ms on LC 6|LC 7.
• On a 2.5 GHz machine: Around 3|7 ms on LC 6|LC 7.
[ The simplified math used here for the gear's curves is given by
( g*cos(t), g*sin(t) ) where t is the angle ( t=degree*pi/180 )
N2 = N/2 and g = 10*(N2 + tanh(N2*cos(N2*t)*sin(N2*t))) ]

Use it for fun, explore and change the (medium difficult) script.

The stack runs on Mac/Win/Linux using LC 6-8, and on RaspberryPi using (the only available) LC 6.5.1 or 7.0.4
Attachments
Gears3.livecode.zip
Simple 16 - 6 - 24 teeth gears
gears3.png (30.98 KiB) Viewed 7208 times
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

Our next goal is to handle mini displays like the 84x48 Mini-LCD-display (ready to use available for 10\$ (Adafruit,Sunfounder); this is in fact the Nokia 5110 display of an early mobile phone).

We'll do this in 3 steps, only step [3] depends on Raspi hardware.
The first two steps may be of it's own LC-related "scripting interest" for all platforms.

[1] Prepare the 'pure' math. This may be applied to ANY display (which has also, if scaling a clipped region high enough, the behaviour of a mini display). I'll post that part in the "easy math"-thread of this subforum: Relations I and II, see here.

[2] Build some scripts for creating "images" (the pixel-displays) on such a display. Will be the next post here.

[3] Using the hardware (how to put a display from card to the miniLCD). Of course we use available resources and infos from the Raspi community here.
I'll post that part in an own "hardware"-thread in this subforum.
Attachments
Here a "software"-preview from step [2].
miniLCD3.png (65.81 KiB) Viewed 7201 times
Two 'enlarged' displays which we'll use in step [2]
miniLCD2.png (139.36 KiB) Viewed 7205 times
A 'real look' of the display (84x48 "pixels")
miniLCD1.png (4.35 KiB) Viewed 7205 times
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

[Placeholder for Raspberry Pi stacks collection #70 (still unfinished)]
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

[Placeholder for Raspberry Pi stacks collection #71 (still unfinished)]
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

Raspberry Pi stacks collection #72 = Pointillize.livecode

Pointillize and Hatching = LC-Magick 2 could this stack be called, because it gives you very fast (fast enough for Raspi B!) an image effect, that 'imageMagick' serves and creates with a similar technique.

Blur and Pixelate = LC-Magick 1 would be then, also similar to techniques of 'imageMagick', a stack in which Scott Rossi shows us how to use resizing at different quality levels in order to blur or pixelate (ScottR's blog.)

The technique used here is to pixelate the image and then to draw a polygon that masks these enlarged pixels with its markerPoints, which are appropriate (computed) regular polygons. The masking is achieved by simply setting the ink of the pixelated image and the polygon, as described in Raspi stack #59 (= keyhole.livecode). Since the technique builds on pixelation, the methods of LC-Magick 1 are included in LC-Magick 2 -- switch Pointillizing off for that (or apply both).

Kind of a "Hatching effect" is achieved by setting vertices to 2 and using angles.
The image example is the Thistle from Thistle Street NW, Edinburgh. You can import your own 'thistle' (and then export your 'artwork').

The stack runs on Mac/Win/Linux using LC 6 to 8, and on RaspberryPi using (the only available) LC651 or LC704.
Attachments
pointillize.livecode.zip
Pointillized Thistle from Thistle Street
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

Raspberry Pi stacks collection #73 = imageMultiplexer2c.livecode

ImageMultiplexing = LC-Magick 3 could this stack be called.
It gives you very fast an interesting aspect of image manipulation.

I've see this several times in "big imaging apps" and wondered if this could be done fast enough even for Raspi with the "on-board-tools" of LC. The answer is yes. The resulting stack is below.

It is all done with 'solid' image data (and alphadata) handling, no tricks, no external helper. Not, not the single pixels are used, this would be far too slow. Wherever possible, the data is prepared in a way, that 'blocks of pixels' can be used.

The times needed are surprising: 80-300 ms on a medium fast machine, 500-2000 ms on a Raspi2.
That is, on a medium fast machine you have the result 'on mouseUp': LC-Magick ...

An included image example is again the Thistle from Thistle Street NW, Edinburgh. You can import your own 'thistle' (and then export your 'artwork').

The stack runs on Mac/Win/Linux using LC 6 to 8, and on RaspberryPi (using LC651 or LC704).
The stackFileversion is 5.5.
.
Attachments
imageMultiplexer2c.livecode.zip
The input for the horizontal cut
plexerIn.png (24.03 KiB) Viewed 6986 times
A simple result: 4 copies of a horizontal
cut of a full moon and 4x4 full moons
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

Raspberry Pi stacks collection #74 = SundayGameNb5.livecode

SundayGame number 5 is a "Digits-Frequency-Race".

You choose one of Pi, Sqrt(2) or Exp(1). Then fix N (1 <= N <= 10000) of its digits as "population". The stacks computes the frequency distribution of the digits 0-9 in that population.

The game is now to bet on a winning digit:
Which digit has the highest frequency in the current population?

For each "round" of the game you can set your own N (by an input field) or get a random N out of 1000 or out of 10000. For N < 1000 there is more variation in the frequencies. For larger N the frequencies are close to 10% (the 'theoretical' value if the digits have a discrete uniform distribution).

The script includes a 'tied-rank-computation'.

You may play the game also online with it's HTML5-standalone "digitRace" frome here (EU) or from here (US).

The stack runs on Mac/Win/Linux using LC 6 to 8, and on RaspberryPi (using LC651 or LC704). The stackFileversion is 5.5.
Attachments
sundayGameNb5.livecode.zip
digitsRace.png (7.3 KiB) Viewed 6920 times
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

Raspberry Pi stacks collection #75 = Rotate3D-XY.livecode

A Simple (non-perspective) 3D rotation of a shape (and snapshot-text from a field).
You can choose the number of vertices of the 'shape', a regular polygon.
'Speed' is hard-coded, easily adjustable to your special needs in the script.

We don't have widgets available on Raspi, so we have to make our own utilities.
[Widgets would be much too slow for Raspi anyway.]
Our series has started just now, this is 'R-widget #1'.

A similar example of such a simple 3D-rotation (of a masked image) is available online as HTML5-standalone, choose from the overview here (EU) or here (US).

The stack runs on Mac/Win/Linux using LC 6 to 8, and on RaspberryPi (using LC651 or LC704). The stackFileversion is 5.5.
Attachments
rotate3D-XY.livecode.zip
Shape and text (updated every second from field) are rotated around
vertical or horizontal axis
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

Raspberry Pi stacks collection #76 = wireFrames1b.livecode

This is the IDE version of my simple font tracing algorithms,
tracing styles Contours, Horizontal, Vertical, Gutter or Points.
[It is a 'byproduct' of the preparation of my talk in August, Edinburgh.]

This version uses only optionally the webFonts of the HTML5 version, only if you install them.
Default is to show the available fontNames (the fonts of your OS that LC can see).

The scripts run very fast in LC 6 (on Raspi 2/3 significantly faster than the HTML5 version, on a medium fast machine ca. 10-15 times faster than the HTML5 version, depending on web browser used). In LC 7/8 it slows down graciously and you need a very fast machine to have still fun with that.

Usage hint.
One source of fast algorithms is the 'dont-check-everything-twice'. So sometimes you will get unwanted 'connections' between letters. These usually disappear if you choose a larger textSize and decrease the scale of the traced poly (use menus). Of course this need more computation time, seen also from the number of needed lines (which include empty lines for separating subpolys).

We don't have widgets available on Raspi, so take this as 'R-widget #2'.
Look at the HTML5-version from the overview here (EU) or here (US).

The stack runs on Mac/Win/Linux using LC 6 to 8, and on RaspberryPi (using LC651 or LC704). The stackFileversion is 5.5.
Attachments
hhWireFrames.zip
(includes info to used webFonts)
Zoom in to see a traced text in style 'gutter'.
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

Raspberry Pi stacks collection #77 = SundayGameNb6.livecode

SundayGame number 6 is a "RGB-Puzzle":
You create a picture from a subset of all 24 bit different RGB colors, use each of the different colors exactly once.

This is inspired by the great site https://allrgb.com
(Use there all 24 bit = 16777216 = 256x256x256 = 4096x4096 different RGB-colors).

Of course 2^24 is much too large for a sunday game, so we have to use a proper subset, I offer 8x8, 12x18, 64x64 or 72x81 (the last two in case you wish to play from sunday to sunday). The graphics are created 'on-the-fly' what takes some time, especially on Raspi better start with the first two.
[Scripts make heavy use of 'mod' and 'div' -- in case you are beginner and wish to exercise that.]

You may play the game also (simplified) online with it's HTML5-standalone "RGBPuzzle" frome here (EU) or from here (US).

The stack runs on Mac/Win/Linux using LC 6 to 8, and on RaspberryPi (using LC651 or LC704). The stackFileversion is 5.5.
Attachments
sundayGameNb6.livecode.zip
The 8x8 game (simplest size).
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

Raspberry Pi stacks collection #78 = AlertBuilder2a.livecode

The stack, may be also called 'R-widget #3', is too large for a download in the LC-forum (1.2 MB, contains 756 HiRes-icons).
You may download it from livecodeshare or *much* faster via the link "Sample Stacks" from LC's topBar (which works pretty well now in LC 6/7/8).
-------
It is tested on "desktop" with Mac 10.6-10.11 / Win 7-10 / Ubuntu 15.10-16.04.
It runs on Raspi B+ (Debian)/ Raspi 2 (Lubuntu)/ Raspi 3 (Xubuntu), using LC 6.5.1 and 7.0.4.
[Using a built alert on Android and iOS will need some additional work.]
-------
There is large help available in the stack.
-------
Short info:
The stack builds a (sub-)stack, that you can use as an alert.
[+] The built alertStack is 'windowshaped' and disappears after N seconds (counting down the seconds).
[+] Available shapes: Rectangle, roundRect, oval and regular polys (3 to 24 vertices).
[+] The shapes are resizable and (if regular polygons) 'reshapable' by handles.
[+] BackColor, foreColor (border) and lineSize of the shape may be set.
[+] The text is editable (textSize, textFont, textColor).
[+] 756 HiRes-icons (PNG) from Google's set are available
... https://github.com/google/material-desi ... master.zip (60 MByte)
[+] The icons are resizable (scale down).
[+] We colorise the icons by ourselves in the editing stack or the built alert.
[+] A small subset of the icons is attached to the built alert.
=======
Have fun! [-hh]

[Given time, I'll make a special LC 8 version, that uses the SVG versions of the icons ...]
Attachments
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

Raspberry Pi stacks collection #79 = LCD-01e.livecode

This is the example stack "LCD scroller", presented at the LC conference, Edinburgh 2016. For help and info on the technique used see the
accompanying PDF.

It is tested on "desktop" with Mac 10.6-10.12 / Win 7-10 / Ubuntu 15.10-16.04.
It runs on Raspi B+ (Debian)/ Raspi 2 (Lubuntu)/ Raspi 3 (Xubuntu), using LC 6.5.1 and 7.0.4.

Attachments
LCD-01e6.livecode.zip
the stackfileversion is 5.5
Halfcircle: One of 9 available transformations of the display rectangle.
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

Raspberry Pi stacks collection #80 = worldNews.livecode

[2019] Doesn't work any more because of a changed input format. I'll leave it as a "template.

The stack displays headlines from news@Reuters as a "runningText" with weblinks to the articles.

The following info/help is _not_ included in the stack.
• * RightClick at the _lower_ half of the runningText to shift the Text up or down.
• RightClick at the _upper_ half of the runningText to drag the stack.
• Click at the runningText to start/stop it running.
• Move mouse from above into the stack's window to show an action/info group.
• Move mouse to top or bottom of the stack's window to hide the action/info group.
• * RightClick at the (most right) date-field of this group to shift its text up or down.
• Click at this field of this group to enlarge/shrink it. The field is displaying a countDown in seconds until the next refresh.
• RightClick the button "Refresh" of the action/info group to choose a textFont.
• Click at one of the four orange rects of the stack window's corners to move the stack to the corresponding corner of the working screenRect.
• The action/info group shows buttons "News" (with the main script), a region option, Start/Stop, Color 'swatches', Previous, Next and Refresh. The speed of the animation may be adjusted (for Raspi to fastest desktop box) by the right option menu (slowest=1 to 7=fastest).
[* may be needed after choosing a different textFont or switching LC 7 and LC 8 for the display. Default is the otf-Font "Churchill" (added in the zip, install it by a double-click).]

The stack runs on Mac/Win/Linux using LC 7 or 8, and on RaspberryPi using (the for Raspi available) LC704.

We use LC > 6, because most messages contain unicode chars. The stack runs also with LC 6 (if the stackfileversion is changed), but such chars have then a wrong display and you have to work around that.

[2019] Doesn't work any more because of a changed input format. I'll leave it as a "template".

Attachments
worldNews.zip
Contains the stack and the default otf-font.
Left and right half of the display with the info/action group on top of it.
At bottom the center of the display without the group.
worldNews.png (8.44 KiB) Viewed 6093 times
Last edited by [-hh] on Sat Apr 20, 2019 10:14 am, edited 3 times in total.
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
Posts: 2072
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

### Re: RaspberryPi Stacks

Raspberry Pi stacks collection #81 = contrastRatio2.livecode

A Contrast Ratio helper. Formulas for relative luminance and contrast ratio are based on the W3C's recommendation for Accessibility.
• You can set by "oneClick" the backColor and textColor of a text field. Then the relative luminance and the contrast ratio of the two colors are computed.
The colors may also be set by a color dialog (click the corresponding 'color swatches').
• There is a 'first' algorithm that *tries* to find a foreColor on base of the current foreColor (the backColor remains fixed) such that a contrast ratio > 7 is reached.
Try to improve it for your needs.
The stack runs on Mac/Win/Linux using LC 6/7/8, and on RaspberryPi using (the for Raspi available) LC 651 or LC 704.
Attachments
contrastRatio2.livecode.zip
The stack.