Page 7 of 9

Re: RaspberryPi Stacks

Posted: Fri Mar 10, 2017 11:13 am
by SparkOut
Hermann, you are amazing, and brilliant, and brilliantly amazing!

Re: RaspberryPi Stacks

Posted: Fri Mar 10, 2017 11:19 am
by [-hh]
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. ;-)

Re: RaspberryPi Stacks

Posted: Wed Apr 05, 2017 12:14 am
by [-hh]
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.]

Re: RaspberryPi Stacks

Posted: Thu Apr 06, 2017 11:54 pm
by [-hh]
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
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.

Re: RaspberryPi Stacks

Posted: Sun Apr 23, 2017 9:08 pm
by [-hh]
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

Re: RaspberryPi Stacks

Posted: Thu Apr 27, 2017 8:42 pm
by [-hh]
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.

Re: RaspberryPi Stacks

Posted: Mon May 15, 2017 12:46 pm
by [-hh]
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

Re: RaspberryPi Stacks

Posted: Mon May 22, 2017 8:39 pm
by [-hh]
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: 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.

Re: RaspberryPi Stacks

Posted: Fri Jun 30, 2017 4:23 pm
by [-hh]
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.

Re: RaspberryPi Stacks

Posted: Fri Jul 07, 2017 4:26 pm
by [-hh]
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: (sorry, currently not available)

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).
 

Re: RaspberryPi Stacks

Posted: Fri Aug 11, 2017 10:50 pm
by [-hh]
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": (sorry, currently not available)

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').

Re: RaspberryPi Stacks

Posted: Tue Aug 15, 2017 7:56 pm
by [-hh]
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.

Re: RaspberryPi Stacks

Posted: Sun Feb 11, 2018 11:59 am
by [-hh]
Raspberry Pi stacks collection #104 = ColorToneCurve.livecode
(Updated to version 1.0.2: Added RGB channel option and improved speed by 20%)

Color tonality curve for images = LC-Magick #10

A "color tonality curve" is a color function that is applied to the color values of your input image. The input values are on the horizontal axis (x) the output values are on the vertical axis (y).

We set here the curve
  • by an editable formula or
  • by 2 up to 9 handles (control points) that determine either
    • a polygon chain (linear pieces between the control points)
    • a bezier curve of order 1=linear, 2= square ... up to order 8
      (usually most control points are not on the curve)
    • a natural spline curve (control points are on the curve)
    • a clamped spline curve (control points are on the curve)
Example: y=x^2 translates rgb (50, 100, 255) to ((50/255)^2, (100/255)^2, (255/255)^2) and results, transformed back from 0-1 to 0-255 and truncated, in (0.038447*255,0.153787*255,1.0*255) = (10,39,255).

Once again, the result is surprisingly fast if the input image is not too large. Using LC 6 (which is 4-5 times faster than LC 7/8/9 with this technique) we have on RaspberryPi 2/3 computing times around 1-2 seconds for a medium sized image, acceptable for me.

[For use with LC 8/9 we 'outsource' the application of the tone curve to Javascript, done in a browser widget. By that we are very fast (usually < 500 ms for an image of size 1920x1080 pixels, depends on your CPU/GPU). See stack "colorToneCurve89" : (sorry, currently not available)

The current stack is also too large for a forum post. Find "ColorToneCurve6789" : (sorry, currently not available)
This "pure" LC-Script stack runs on Mac/Win/Linux using LC 6/7/8/9, and on RaspberryPi using (the for Raspi available) LC 651 or LC 704. Use it best with LC 6 (from speed reasons).
 

Re: RaspberryPi Stacks

Posted: Tue Feb 13, 2018 8:24 pm
by [-hh]
Raspberry Pi stacks collection #105 = reflectImage.livecode

ReflectImage = LC-Magick #11
version 1.0.1 of Feb 13, 2018

ReflectImage mirrors (a part of) an image and blends the transparency of the mirrored part. This shows, compared to lengthy techniques in "full" image apps, how easy it is to have such effects with LiveCode.

You can select
  • the position of the mirror (top or bottom)
  • the percentage of the image to be mirrored
Once again, the result is fast if the input image and the selected percentage are not too large. Using LC 6 (which is up to 2 times faster than LC 7/8/9 with this technique, 9.0.0-dp11 is only 10% slower than LC 6) we have on RaspberryPi 2/3 computing times around 1 second for a medium sized image.
  • Use LC 6.0.5 (or slower: 7.0.4) on Raspi.
  • Use LC 6.7.11 / 7.1.4 and 8.1.6/ 9.0.0 or later on Mac/Win/linux
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/reflectImage_101.livecode")
    [US] go stack url ("http://hh.on-rev.com/xstacks/reflectImage_101.livecode")
    _or_
  2. by downloading in your browser
    [EU] http://hyperhh.org/xstacks/reflectImage ... vecode.zip
    [US] http://hh.on-rev.com/xstacks/reflectIma ... vecode.zip
    Then open in an LC IDE, version as denoted above.

Re: RaspberryPi Stacks

Posted: Tue Feb 13, 2018 9:57 pm
by bogs
Very envious, you always have the coolest looking images in your rigs :mrgreen: