RaspberryPi Stacks

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Re: RaspberryPi Stacks

Postby SparkOut » Fri Mar 10, 2017 11:13 am

Hermann, you are amazing, and brilliant, and brilliantly amazing!
SparkOut
 
Posts: 1627
Joined: Sun Sep 23, 2007 4:58 pm

Re: RaspberryPi Stacks

Postby [-hh] » Fri Mar 10, 2017 11:19 am

Thanks SparkOut.
Four years ago I started 'LiveCoding'. You were (and still are) one of these wonderful community members who help beginners to learn fast. So you are partially praising yourself. ;-)
shiftLock happens
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1487
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Wed Apr 05, 2017 12:14 am

Raspberry Pi stacks collection #94 = Cuboid.livecode
(v1.0.1 of Apr 04/2017)
(Thanks to the LC-Team for removing the "layering-bug" in LC 8/9)

Cuboid ('pure' LiveCode script) = LC-Magick #7
A Cuboid is a cubic form that allows different width, height and depth. Some call it simpler "3d-box".
We use "Perspective Image Distortion" for all 6 faces of a cuboid. The base shape is a unit cube (which has 1.00 = baseWidth = baseHeight = baseDepth). Use other values of baseWidth, baseHeight and baseDepth to set other size relations of your box.

  • Each of the six faces may use a colored rect or an image as input.
  • Faces can be made 0-100 % transparent, so that you can also look through to 'back' faces (=early iMac effect, we could call our object an "iCube").
  • You have the arrowkeys and buttons zoom/rotateX/rotateY/rotateZ for fine-tuning. Fast animation is done by clicking (hold mouse down) at an "in/out-ring" at topLeft and and a "windrose" at topRight.
  • Clicking button 'Cube' (re-)starts the cuboid with your current size settings. RightClick for a cube with 2.00 = baseWidth = baseHeight = baseDepth.

You'll find more detailed help in the stack. Scripts are 'essentially' commented.
The antialiasing uses, once again, Bernd's gradient-technique. Thanks BerndN!

  • Use LC 6.0.5 (or slower: 7.0.4) on Raspi.
  • Use LC 6.7.11/ 7.1.4 and 8.1.4/ 9.0.0-dp7 or later on Mac/Win/linux (LC 8.1.3 and 9.0.0-dp6 contain a layering bug)
The stack is too large for the forum. You can have it

  1. by opening an LC IDE, version as denoted above, then type in or copy-paste to msg:
    [EU] go stack url ("http://hyperhh.org/xstacks/cuboid_101.livecode")
    [US] go stack url ("http://hh.on-rev.com/xstacks/cuboid_101.livecode")
    _or_
  2. by downloading in your browser
    [EU] http://hyperhh.org/xstacks/cuboid_101.livecode.zip
    [US] http://hh.on-rev.com/xstacks/cuboid_101.livecode.zip
    [You may use Raspi stack #33 to check the sums:
    md5=5eda09e792cdcc2f75f880ab19c18586
    sha1=fd7cf2a50489aa2484b2045d88aed28cc8de426e]
    Then open in an LC IDE, version as denoted above.

[Edit. Removed a typo.]
Attachments
cuboid.png
Last edited by [-hh] on Wed Apr 26, 2017 1:46 pm, edited 1 time in total.
shiftLock happens
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1487
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Thu Apr 06, 2017 11:54 pm

Raspberry Pi stacks collection #95 = MoonEffect.livecode

MoonEffect (Elliptical distortion/Fisheye) = LC-Magick #8
[By Hermann Hoch and Bernd Niggemann]

This is our "easter-egg" for the community"!

You have

(a) A full moon.
A rectangular image is elliptical distorted (kind of "fisheye display").
  • You can add 'Effects': a bright moonshadow.
  • Choose horizontal/ vertical radius ('RadiusX'/ 'RadiusY') of the oval.
  • Choose a fixed 'Relation' between them, based on the selected one of X or Y.
  • Choose an 'Angle' for the display.
  • Choose a (proportional) 'Scale' for the display.
(b) A partial moon.
  • Set 'Percentage %'
  • Choose by btn ">" the increasing/ waxing phase
  • Choose by btn "<" the decreasing/ waning phase
It's NOT done, as in real life, by a moving shadow, but by showing the corresponding horizontal percentages of the source image. Horizontal flip respects these percentages, also Effects (the moonshadow).

Moreover you can 'animate':

  • 'Animate' is slow, but can be done in selectable percentage steps.
  • 'SaveAnim' creates a 1-step animation with the current settings in the folder of your stack (= 201 PNGs = if 300x300 around 14 MByte). Before saving an animation the stack should be saved to your local disk to have a folder for saving the image-series.
  • 'ShowAnim' selects such a collection for replaying (works only correctly if loaded from the stacks folder). You choose the refresh rate in millisecs, so it is much more flexible than a gif animation .
You'll find more detailed help in the stack, scripts are 'essentially' commented.

  • Use LC 6.0.5 (or slower: 7.0.4) on Raspi.
  • Use LC 6.7.11/ 7.1.4/ 8.1.4/ 9.0.0 on Mac/Win/linux
The stackfileversion is 5.5 (LC 6 is faster animating than LC 7/8/9).
The stack has 2 MByte (incl. images), too large for the forum. You can have it

  • by opening one of LC 6/7/8/9 IDE and type or copy and paste in msg:
    [EU] go stack url ("http://hyperhh.org/xstacks/moonEffect_101.livecode")
    [US] go stack url ("http://hh.on-rev.com/xstacks/moonEffect_101.livecode")
    _or_
  • by downloading in your browser
    [EU] http://hyperhh.org/xstacks/moonEffect_101.livecode.zip
    [US] http://hh.on-rev.com/xstacks/moonEffect ... vecode.zip
    [You may use Raspi stack #33 to check the sums:
    md5=12f3383ff9f3f8135dd88d8e50613d93
    sha1=ac1c618924da950016f79083aa45ed59660697fa]
    Then unpack and open in one of 6/7/8/9 LC IDE.
For a demo of the replay you can download zipped image-series (201 PNGs each), made with the stack:
(5M) [EU] EasterEggJ-anim, (5M) [EU] HeadRed-anim, (2M) [EU] LCInfinity-anim,
_or_
(5M) [US] EasterEggJ-anim, (5M) [US] HeadRed-anim, (2M) [US] LCInfinity-anim.
Just put the folders into the folder where your stack resides. The animations are antialiased only, adding effects increases the size.

p.s. The eastereggs in our stack are alike the ones in bn's stack Eastergg of livecodeshare.
Attachments
moonEffectWaning.png
moonEffectWaning.png (24.38 KiB) Viewed 1787 times
moonEffectFull.png
moonEffectFull.png (33.86 KiB) Viewed 1787 times
moonEffectWaxing.png
moonEffectWaxing.png (25.09 KiB) Viewed 1787 times
shiftLock happens
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1487
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Sun Apr 23, 2017 9:08 pm

Raspberry Pi stacks collection #96 = Legofy67.livecode

Legofy (is 'pure' LiveCode script)
This is a special (and partially improved) form of pixelate/pointillize, see
Stack #72 = LC-Magick 2

Choose the size of the lego-1x1-brick that is then used to build the 'plate' colored (overlayed) by your image.

  • Use LC 6.0.5/7.0.4 on Raspi.
  • Use any stable version of LC 6/7/8/9 on Mac/Win/linux
Attachments
legofy67.livecode.zip
(215.66 KiB) Downloaded 136 times
legofiedThistle.jpg
The (legofied) thistle that thistles at Thistle Street NW, Edinburgh.
shiftLock happens
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1487
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Thu Apr 27, 2017 8:42 pm

Raspberry Pi stacks collection #97 = rangeSlider.livecode

The stack is a builder utility for rangeSlider controls.

A rangeSlider is a self-contained group that represents a horizontal or vertical Slider that has one, two or three knobs:
The usual slider knob and/or knobs for the lower and upper bounds of a range.


Example.
Say you have a slider base that represents the values 0-100.
You define the range 20-85 out of that by setting the lower thumb to 20 and the upper thumb to 85.
Optionally you can now set a slider thumb selecting values within that range 20-85.
(Or you use, like with 'usual' sliders, only a slider thumb, no lower or upper thumb, and select from the base range 0-100).

The stack shows as examples 15 of the possible variations of rangeSlider and lets you variate all these:
= Choose one slider thumb, two range thumbs or both.
= Choose the orientation (vertical/horzontal) of the rangeSlider.
= Choose the baseColor, the thumb colors and the text color.
= Choose which values to display as text (incl. percentages).

You can get and set the sliderValues by script (see the documentation/help in the attached "builder" stack).

  • Use LC 6.0.5/7.0.4 on Raspi.
  • Use any stable version of LC 6/7/8/9 on Mac/Win/linux.
The stack contains a button that shows the few lines needed to call in LC 6/7/8/9 the property inspector for an object by script and how to set its topleft.

p.s. I'll make a corresponding LC 8/9 widget as soon as the widget format is fixed, so that that we need to build only ONE version for LC 8/9 widgets.
Attachments
rangeSlider_v100.livecode.zip
The builder stack: Copy ready-made groups from it.
(17.39 KiB) Downloaded 134 times
rangeSliders.png
Screenshot of a part of the builder stack
(click the image to zoom in).
shiftLock happens
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1487
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Mon May 15, 2017 12:46 pm

Raspberry Pi stacks collection #98 = GuessImage.livecode

GuessImage = SundayGameNb7
This is a basic usage of different paint tools in order to reveal ("unpaint") an image by painting. It required a not so simple blending technique to have this working on Mac/Win/linux and Raspi:
An image in back is covered by an (empty) image that is the "drawing canvas" and has ink "blendDstIn". On linux (and Raspi) this opens the stack window to look through to desktop, so we had to cover it (on top) by a disabled opaque graphic of ink "noOp".

I tried to have this stack also running as a HTML5 standalone but there the _only_ paint tool that works is the pencil.

  • Use LC 6.0.5/7.0.4 on Raspi.
  • Use any stable version of LC 6/7/8/9 on Mac/Win/linux
Attachments
guessImage.livecode.zip
(237.17 KiB) Downloaded 131 times
guessImage.png
A partially "unpainted" image.
shiftLock happens
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1487
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Mon May 22, 2017 8:39 pm

Raspberry Pi stacks collection #99 = SelectiveGray.livecode

SelectiveGray = LC-Magick 9
is a special technique to display selective colored grayLevel images typical is the"redLips effect" (also called "Pleasantville-effect" or Sin-City-effect" after movies that used it).

The effect is attained by overlaying an image by its own grayLevel version and then colorizing parts by creating transparent regions (setting the mask). We do this by

  • using paint tools (mostly for the 'fine' adjustments)
  • selecting parts by a polygon for masking its enclosed region or the complement of the enclosed region
  • selecting parts that have in the original image a color-distance (the 3D-euclidian distance) of at most a selectable value.
    The euclidian 3D-distance of two colors (r1,g1,b1) and (r0,g0,b0) is
              sqrt((r1-r0)^2+(g1-g0)^2+(b1-b0)^2).
The stack is available in three variants:
  • a pure LC Script-version (fast enough for Raspi):

    [EU] go stack url ("http://hyperhh.org/xstacks/selectiveGray6789_100.livecode")
    [US] go stack url ("http://hh.on-rev.com/xstacks/selectiveGray6789_100.livecode")
    Usable with LC 6.0.5/7.0.4 on Raspi.
    Usable with any stable version of LC 6/7/8/9 on Mac/Win/linux.
       
  • a LC Script-version that optionally uses revBrowser's canvas2d:

    [EU] go stack url ("http://hyperhh.org/xstacks/selectiveGray6789_mac_100.livecode")
    [US] go stack url ("http://hh.on-rev.com/xstacks/selectiveGray6789_mac_100.livecode")
    Usable with any stable version of LC 6/7/8/9 on Mac only.
       
  • a LC Script-version that optionally uses browser widget's canvas2d:

    [EU] go stack url ("http://hyperhh.org/xstacks/selectiveGray89_100.livecode")
    [US] go stack url ("http://hh.on-rev.com/xstacks/selectiveGray89_100.livecode")
    Usable with any stable version of LC 8/9 on Mac/Win/linux.

For these "go stack"-links open an LC IDE, version as denoted above, then type them or copy-paste to the message box.
Or you can use URLs given above, add ".zip" and download the zipped version of the stacks.

All stacks have help and let you import images and export your artwork.
The filesizes (incl. demo images) are 2.1 MByte each and 1.8 MByte each for their zips.
Attachments
final.png
final selectiveGray
final.png (91.06 KiB) Viewed 1164 times
polyselect.png
UsePoly: Inside distance 290 to magenta
polyselect.png (51.7 KiB) Viewed 1164 times
original.png
original
original.png (140.34 KiB) Viewed 1164 times
shiftLock happens
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1487
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Fri Jun 30, 2017 4:23 pm

Raspberry Pi stacks collection #100 = mapGoogle.livecode

This basic map stack was made in April 2017 on base of a discussion in the use-list,
mapGoogle2.livecode is an update according to the current discussion (shows coordinates of the SW and NE edges of the map).

Usable with LC 6.0.5/7.0.4 on Raspi.
Usable with any stable version of LC 6/7/8/9 on Mac/Win/linux.
Attachments
mapGoogle2.livecode.zip
(81.36 KiB) Downloaded 69 times
mapGoogle.livecode.zip
(39.14 KiB) Downloaded 65 times
mapGoogle.png
shiftLock happens
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1487
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Fri Jul 07, 2017 4:26 pm

Raspberry Pi stacks collection #101 = rotationControl2.livecode
(updated to v2)

This is a *very basic* stack that shows how to build a custom "rotation"-control:
  • How to get the angle of a click on an object relative to the loc of the object.
  • How to display the angle with two ovals and use of startangle and arcangle, running clockwise and starting at 12 o'clock.
  • How to use a behavior property.
The stack contains a graphics group including an invisible behavior button that shows on mouseDown the circular slider control.

Attach the button as behavior to any LC object that has an angle property.
Click anywhere on the target, a bit away from it's location and drag the mouse at about along a circle around the location of the target.
Then select one of two methods for the result of the dragging: (second method new in v2)
  • TO ANGLE: gets the angle of the mouseloc relative to the loc of the target and sets the angle of the target accordingly.
  • BY ANGLE: gets the angle of the mouseloc relative to the loc of the target as baseAngle and sets the angle of the target additive to the current angle of the target. Variant "diff" displays the difference to the current angle, variant "full" displays the resulting angle.
For method "ToAngle" imagine a clock with a very long hour hand around the loc of the target object.
Then click far from that clock at the hand at ...
... 12 o'clock to have a value around 0 degrees,
... 3 o'clock to have a value around 90 degrees,
... 6 o'clock to have a value around 180 degrees,
... 9 o'clock to have a value around 270 degrees.

The essential part of script is short but the attached demo images make it too large for posting it here.
So download it from "Sample stacks" of the LC toolbar or from

http://livecodeshare.runrev.com/stack/8 ... ionControl

Usable with LC 6.0.5/7.0.4 on RaspberryPi 2/3.
Usable with any stable version of LC 6/7/8/9 on Mac/Win/linux.

For mobile (or at any rate ...) you may have to adjust the layout of the slider-group (basics are already in the behavior script).
 
Attachments
RotationControl2.png
Clicked anywhere in the image. Then dragged circular to set the slider
to 66 degrees. [The "OvalSlider"-group hides on mouseUp.]
shiftLock happens
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1487
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Fri Aug 11, 2017 10:50 pm

Raspberry Pi stacks collection #102 = JPNG.livecode

JPNG (named using JPEG and PNG) is not an image format but a compression method.
When saving it to files we use the file ending ".lcjpng" for that.

It takes features from both JPEG (setting JPEGquality to compress the imageData) and from the PNG compression (the alphaData/transparency). It saves the alphaData, optionally the maskData, and the JPEG-compressed imageData in one file. The JPNG-compressed image has here, using a JPEGquality of 80, around 25% of the PNG-compressed size.

So this may be interesting for people who wish to compress (significantly in size) the PNG-images containing transparency in their stack/standalone and decompress only some images for "current" use, at runtime.

Compression/Decompression is very fast.
The compress/decompress scripts are short ( < 30 lines each) so you can use it in your own stack.
  • The stacks can export JPNG to files and reimport it from such files.
  • It shows how to save compressed images into numbered properties and how to decompress them.
  • As part of the JPNG-compressions: How to apply JPEG compression at different qualities.
An expert's report from the LC use-list.
Mark Waddingham wrote: ...the JPNG idea exploits the fact that color images tend to withstand data-loss, but alpha data (masks) do not - JPEG is lossy, it removes information which our eyes cannot see. PNG compression (a variant of gzip IIRC) is loss-less, it preserves the exact values of the inputs.
So you use the lossy method (JPEG) on the part of the image which makes no difference to our eyes, and the loss-less method (PNG) on the part of the image which our eyes would notice a difference in.

Download the stack "JPNG" from "Sample stacks" of the LC toolbar or from

http://livecodeshare.runrev.com/stack/841/JPNG

Usable with LC 6.5.1/7.0.4 on RaspberryPi 2/3 (7.0.4 has a few bugs).
Usable with any stable version of LC 6/7/8/9 on Mac/Win/linux.


Recommended use on Mac/Win/linux: LC 9
which is significantly fastest
(probably the upgraded Skia library 'pushes').
Attachments
JPNG.png
JPNG.png (19.02 KiB) Viewed 448 times
shiftLock happens
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1487
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Tue Aug 15, 2017 7:56 pm

Raspberry Pi stacks collection #103 = SimplifyPoly.livecode
(Ramer-Douglas-Peucker algorithm)

Often I have the situation of too many points in a polygon, slowing down the post processing of these graphics. Examples are auto-traced opaque region of images or outlines coming from a map ("coastlines"), or simply a signature or "curves" from freehand-drawings (do it in the attached stack).

So the question arises how to reduce the number of points of such polygons and preserve the "visual shape" as good as possible, according to a "tolerance" given for deviations.

Ramer and Douglas&Peucker found independently a simplification algorithm for this problem. I translated that to LC Script. It is fast enough for use on RaspberryPi and is very effective.

The algorithm is currently for a "connected" polygon only (no empty lines in it). If you have a polygon which is separated into parts by empty lines then simply apply the algorithm to each part of connected points (containing more than 2 points each).

Usable with LC 6.5.1/7.0.4 on RaspberryPi 2/3.
Usable with any stable version of LC 6/7/8/9 on Mac/Win/linux.
Attachments
simplifyPoly.livecode.zip
(39.99 KiB) Downloaded 63 times
simplifyPoly.png
shiftLock happens
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1487
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Previous

Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 1 guest