RaspberryPi Stacks

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Re: RaspberryPi Stacks

Postby [-hh] » Tue Oct 18, 2016 2:18 am

Raspberry Pi stacks collection #82 = fileSplitAndJoin2c.livecode

This is a file splitter and joiner.
You can split (the copy of) any file into parts of up to <splitSize> length or join such parts again.

Set input path for SPLITTING: drag a file's icon to the upper field or use btn "File to split...".
Set input paths for JOINING: drag numbered file's icons to the lower field or use btn "Files to join...".

Made especially for use with zip files for/of the LC forums (you can upload up to three files of size <= 250 KB). The upload (of parts) to the forums needs endings ".zip" (use check button). The downloader can then use this stack to join such parts again [tested with files of type .lce, .dmg, .zip, .tar and up to 2 GB length].

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

This is a repost for version 2c.
(Through an oversight I had uploaded the 'Mac-only' first version, sorry.)
Attachments
fileSplitAndJoin2c.livecode.zip
(6.25 KiB) Downloaded 111 times
splitAndJoin2.png
Plagiarism is basic to all culture.
(Pete Seeger in a concert, he didn't name an author ...)
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1325
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Sun Oct 30, 2016 5:26 am

Raspberry Pi stacks collection #83 = listUtility_100.livecode

ListUtility v1.0 are scripts for a list field, bundled in a self-contained group (just copy and paste it. Or use the scripts ...). I need that for lists with several hundred lines, this works here (also on Raspi) pretty fast.

The list field is set to have non-contigous multiple selection available.
  • Reorder the list by dragging one line or (may be non-contiguous) blocks of lines.
    Reordering is either slow and repeating every second or fast by using shiftKey.
  • Reorder the list using buttons. Move one line or (may be non-contiguous) blocks of lines.
    Reordering is either fast by using shiftKey or slow and repeating every second.
  • Populate the list with filePaths (default) or the contents of a file.
    Use buttons for that or dragAndDrop to the field.
  • Remove duplicate entries from the list, choose case-sensitivity for that.
  • Sort the list by several criteria (also by foundLines).
  • From a search field search case-sensitive a string and highlite the found locations in the list. Search is triggered either by EnterKey/ReturnKey or after every keyUp.

One function is often needed to build "hilitedLines":
Building contiguous or systematic ranges of numbers.
This is very simple, but (thanks LC) rather powerful.

Code: Select all
-- numbers from n1 to n2 step stp, delimited with (string) dlmtr
-- and prefix pfx and suffix sfx, numberformat as given in nbf
function uRange n1,n2,stp,dlmtr,nbf,pfx,sfx
  if stp is empty then put 1 into stp
  if 0 < (n1-n2)*stp then return empty
  if dlmtr is empty then put cr into dlmtr #<-- cr
  if nbf is not empty then set numberformat to nbf
  repeat with i=n1 to n2-stp/2 step stp
    put dlmtr & pfx & i & sfx after s
  end repeat
  return char 1+length(dlmtr) to -1 of s
end uRange

Recall that for "step" in the repeat fractions (like 1/3, 7/8) and non-integers (like 0.25, 2.5) are also allowed!

Code: Select all
-- short version for comma-delimited lists
function listRange n1,n2,stp
  if stp is empty then put 1 into stp
  if 0 < (n1-n2)*stp then return empty
  repeat with i=n1 to n2-stp/2 step stp
    put comma & i after s
  end repeat
  return char 2 to -1 of s
end listRange


The 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.
Attachments
listUtility_100.livecode.zip
Was erraneously a beta version. Is now latest version v1.0
(12.51 KiB) Downloaded 111 times
listUtility_100.png
Adjust the highliting colors to your needs using the color swatches at top
Plagiarism is basic to all culture.
(Pete Seeger in a concert, he didn't name an author ...)
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1325
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Sun Nov 06, 2016 1:41 am

Raspberry Pi stacks collection #84 = convexHull.livecode

The Convex hull of a set of points is the smallest convex set containing the set (non-math: A rubber band around all points, as tight as possible). For a finite set of points the hull is a polygon using a subset of the points.

The computation of such a polygon is non-trivial. There are several algorithms, see for a good overview
https://en.wikipedia.org/wiki/Convex_hull_algorithms .
This here is an implementation of Andrew's monotone chain algorithm, see link in the script of "ConvexHull".
Some hints.
  • You may use as input random points (check button at top left) or use by the button at top right a file containg lines of points.
  • You may use the shiftKey (selects contiguous) or the cmd-/ctrlKey (selects non-contiguous) for choosing a subset of points in the input field (most right). If you then choose "Use selection" at bottom right, only this subset is used for computing the convex hull.
  • If you use it for a set of controls then simply add all 'extremal points' of each objects to the list of points, e.g. topleft, topright, bottomright and bottomleft of a rectangle.
You may also copy the algorithm only here.

The 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.
Attachments
convexHull.livecode.zip
stackfileversion of the zipped stack is 5.5
(6.31 KiB) Downloaded 103 times
convexHull.png
Plagiarism is basic to all culture.
(Pete Seeger in a concert, he didn't name an author ...)
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1325
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Sun Nov 20, 2016 5:31 pm

Raspberry Pi stacks collection #85 = perspective67.livecode
Update 2017-01-10 ... Added Bernd Niggemann's (bn) antialiasing technique. Thanks Bernd!

Perspective Image Distortion = LC-Magick #4 (Jan 2017)

[Nov 2016] This is my early X-mas gift to the community (if you are not religious take it as new year's gift). It's a gift because I needed a few hours of concentrated work on several days for the final result, a lot of 'deep thoughts' wasted for that ;-) .

The main code is finally only at about 100 lines and is based on ideas presented on imageMagick's distortion page (thanks to Anthony Thyssen):

This is the LiveCode implementation of the (quadrilateral) perspective distortion technique.
For each new 'distortion' the algorithm has to build and solve a system of 8 linear equations for 8 parameters. These are then used to 'reverse lookup' for each target pixel appropriate pixels in the source image --- a technique that ensures that there are no 'missing' pixels in the target distortion.

The result is surprising. I never thought this could be made fast enough for the LC IDE. But:

Using LC 6 (which is up to 3 times faster than LC 7/8/9 with this technique) we have on RaspberryPi 2/3 computing times around 1 second for a medium sized (distorted) target image, acceptable as I find.

The stack has because of included "Test"-images a size that is not acceptable in the forum. So it is available (fast) via the "Sample Stacks" item of the toolbar or (slower) at livecodeshare.

The 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.
Attachments
antialiasedDistortion.png
Distorted 310x350 image, needs 450 ms on Mac mini 2.5GHz using LC 6.7.11.
Uses antialiased border.
antialiasedDistortion.png (108.13 KiB) Viewed 498 times
perspective.png
Distorted 310x350 image, needs 280 ms on Mac mini 2.5GHz using LC 6.7.11.
perspective.png (38.97 KiB) Viewed 886 times
buchenberg.jpg
Original 480x360 image
Last edited by [-hh] on Tue Jan 10, 2017 9:42 pm, edited 4 times in total.
Plagiarism is basic to all culture.
(Pete Seeger in a concert, he didn't name an author ...)
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1325
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby SparkOut » Sun Nov 20, 2016 8:44 pm

Wow, that's another brilliant piece of work Hermann, vielen Dank!
SparkOut
 
Posts: 1545
Joined: Sun Sep 23, 2007 4:58 pm

Re: RaspberryPi Stacks

Postby capellan » Mon Nov 21, 2016 3:10 pm

Amazing work, Hermann! :D
Many Thanks for sharing all these Math Gems.

How about this for a new challenge?
https://www.willmcgugan.com/blog/tech/post/a-texture-mapped-spinning-3d-globe-rendered-with-javascript-and-html/

Alejandro
capellan
 
Posts: 238
Joined: Wed Aug 15, 2007 11:09 pm

Re: RaspberryPi Stacks

Postby [-hh] » Mon Jan 02, 2017 11:46 am

Raspberry Pi stacks collection #86 = jigsawPuzzle2c.livecode

JigsawPuzzle v2c

Technique used: The pieces are polygon graphics of linear and cubic bezier curves. They are filled with backpattern-images from portions of the whole imagedata. Highlighting is done by setting the ink, shaping the pieces includes random parts: Top and left are adjusted to fit the upper and left neighbour, right and bottom have at random "in" or "out" connectors.

You may
** choose a built-in image or import one.
** choose the width of the basic square of all pieces. This determines the number of pieces. If the image has not appropriate size then it is cropped (the imagedata only).
** choose to allow rotation of the pieces
** choose to collect the 'border' pieces at card's bottomRight.
** choose to indicate a correct location by highlighting the currently dragged piece.

The stack has a size that is not acceptable in the forum. So it is available (fast) via the "Sample Stacks" item of the toolbar or (slower) at livecodeshare.

The 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.
As always the scripts are free for non-commercial use only.
Attachments
jigsawPuzzle.png
jigsawPuzzle.png (146.63 KiB) Viewed 629 times
Plagiarism is basic to all culture.
(Pete Seeger in a concert, he didn't name an author ...)
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1325
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Sun Jan 08, 2017 9:49 am

Raspberry Pi stacks collection #87 = circularDistortionV300.livecode
Updated to v3.0.0 on 2017-01-20 ... Improved antialiasing, first common version

Circular (Polar) Image Distortion = LC-Magick #5 (Jan 2017)
By Hermann Hoch and Bernd Niggemann


This is the LiveCode implementation of the well known polar-plot-technique.
For each new 'distortion' the algorithm computes the polar coords of the target and looks up the pixel data at the corresponding cartesian coords of the source image.
The main code is only at about 80 lines and is once again based on ideas presented on imageMagick's distortion page (thanks to Anthony Thyssen).

You can have circular arcs up to a full circle, filled between an inner and outer radius. Optionally the imagedata can be flipped or mirrored at midth.

Once again, the result is surprisingly fast if the targeted object is not too large, say diameter < 500 px. I did several optimization loops for speed. Using LC 6 (which is 2-3 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 (distorted) target image, acceptable for me.

The stack has a size that is not acceptable in the forum. So it is available (fast) via the "Sample Stacks" item of the toolbar or (slower) at livecodeshare.

The stack has help, the main script is commented.
You can import source images, export/copy target images or use a text field as input.

The 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. On Raspi use LC 651 for increasing speed!
Attachments
edinburghAntialiased.png
Edinburgh panorama, mirrored both horizontally and vertically at midth.
Used border-antialiasing.
Needs 1 to 2 seconds (LC 6 to 9) in total on a medium fast machine (2.5 GHz)
outputHNY.jpg
Circular Arc from text input
inputHNY.jpg
The text input (a simple fied)
Last edited by [-hh] on Fri Jan 20, 2017 1:08 am, edited 1 time in total.
Plagiarism is basic to all culture.
(Pete Seeger in a concert, he didn't name an author ...)
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1325
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Mon Jan 16, 2017 4:59 am

Raspberry Pi stacks collection #88 = recentStackFiles.livecode

This is a simple utility stack for managing the contents of the menu item

File / Open recent File

of LiveCode 6/7/8/9. You can
  • delete or add all entries,
  • delete or add single entries,
  • export the current list to a text file,
  • import a text file of stack paths and
    add to or replace the current list of entries with it.
  • remove duplicate entries or at that path no longer-existing files,
  • use the current work list as launcher for a stack by rightClicking a path line.

That's why I made the stack:
If one is working with different projects one can have by that easily a different menu of "recent files" for each project.

The 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.
Attachments
RecentStackFiles.livecode.zip
(3.53 KiB) Downloaded 62 times
RecentStackFiles.png
Last edited by [-hh] on Mon Jan 16, 2017 5:16 am, edited 1 time in total.
Plagiarism is basic to all culture.
(Pete Seeger in a concert, he didn't name an author ...)
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1325
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Sun Jan 22, 2017 7:18 am

Raspberry Pi stacks collection #89 = SEhelper1b.livecode(*)

This is a simple utility for helping to work with the script editor:

  • A dark/light colour-theme switcher.
    Of course, the scripteditor has to be open for this one-click solution to work.
    This simply "inverts" your current settings from the preferences by setting the ink.
    All tabs of one editor window have the same theme, different editor windows can have different ink.
    LC resets to your (preferred) 'light theme' on every startup.
    The script for this button only I posted here: viewtopic.php?p=150426#p150426
  • A marks menu, that jumps to special comments (marks).
    A mark is a (possibly indented) line that starts with any of
    '--:M ' or '--:M ' or '#:M '
    that is: commentChar(s) &colon& "M" & space
    You write marks into your script and it does nothing than commenting if not read only and evaluated by the "Marks" button.
    This works also with "dirty" (i.e. unsaved) scripts.
Both scripts don't change any part of your scripts, they don't add any backscript or forescript, they don't change any engine files and they cost (nearly) NO additional time for editing or compiling.
The theme is reset by LC itself to "Light" with every startup of it.

For optional use is also included
  • A "pairs"-balancer for the currently edited script, that searches for the next unmatched opening to the left and for the next unmatched closing part of the pair to the right. This works also with "dirty" (i.e. unsaved) scripts.
  • A field for 'quoting/unquoting' several lines of code that may contain quotes.

More help is included in the stack.
You can drag the window around by grabbing it near it's border.

You may use the stack as ordinary stack (as it is), use it as plugin or simply use the scripts.

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

---
(*) Update to version 1b: Improved 'balanced' selection of content between pairs.
Attachments
SEhelper1b.livecode.zip
The stack, v1b as of Jan 23, 2017.
(5.36 KiB) Downloaded 50 times
SEhelper1-3.png
The three size states of the helper.
SEhelper1-3.png (5.83 KiB) Viewed 364 times
darkTheme.png
The dark variant of the default colorization.
darkTheme.png (7.53 KiB) Viewed 364 times
Plagiarism is basic to all culture.
(Pete Seeger in a concert, he didn't name an author ...)
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1325
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Tue Jan 31, 2017 11:38 pm

Raspberry Pi stacks collection #90 = BilinearPerspective141.livecode
[Version 1.4.1 of Feb 1, 2017 -- avoid now linux ink-bug]

Bilinear (quadrilateral) Image Distortion = LC-Magick #6
[By Hermann Hoch and Bernd Niggemann]

This is the LiveCode implementation of the well known bilinear distortion technique.
For each new 'distortion' the algorithm solves 8 linear equations and looks up the pixel data at the corresponding coords of the source image. The 'core' code is only at about 110 lines. Based on the description here: http://www.imagemagick.org/Usage/distorts/

* Drag the handles of the 'distortion-generating' polygon.
* Use the 'helper' buttons for flipping the image or mirroring the polygon
* Inflate or deflate the 'distortion-generating' polygon ('zoom').
* Antialias or and/or frame the distorted result.
* Copy the result or save it to a file.
* Use a text field for input, to generate distorted 'banners'.
* Use the images menu for testing with some examples.
* Import your own images into the example images menu.

The stack has help. Parts of the main scripts are commented.

Once again, the result is surprisingly fast if the targeted object is not too large. Using LC 6 (which is 2-3 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 distorted target image, acceptable for me. (Antialiasing may double these times -- beauty has its price.)

The stack has a size that is not acceptable in the forum. So it is available (fast) via the "Sample Stacks" item of the toolbar or (slower) at livecodeshare.

The 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.
Attachments
edi_bilinear.png
Bilinear perspective (4-point-) distortion
edi_linear.png
Linear perspective (4-point-) distortion
edi_source.png
Source image
Plagiarism is basic to all culture.
(Pete Seeger in a concert, he didn't name an author ...)
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1325
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: RaspberryPi Stacks

Postby [-hh] » Wed Feb 15, 2017 9:45 pm

Raspberry Pi stacks collection #91 = BeautifyScriptInField_103.livecode

This is a simple utility for helping to work with script formatting.

'Beautify' formats any *text selection* of a field (or the whole filed) by calling handlers of LC's script editor. Thus the indentation and colorisation is the same as if you had done this, using your SE prefs, in the script editor and then copied as styled text to a field.

  • Beautify
    Indents and colorizes the current selection or, if nothing is selected, the whole field. If you choose to use your SE prefs, the result is identical to doing this 'manually' in SE.
  • Line Numbers
    Add line numbers to a selection or, if nothing is selected, to the whole field (this is NOT a separate numbering, it inserts numbers). Vice versa remove all integers which are word 1 of a line (fragile, of course).
  • LightsOff
    Uses a dark theme (reverses your SE clorization prefs) for the card.
You can moreover drag the window around by grabbing it near its border.

The stack is complementary to well known SE helper stacks of Max V. and Paul H.
(see 'Sample stacks' or livecodeshare.runrev.com).

The stack uses a switch for versions LC 6/7 and LC 8/9. It runs fine in LC 6/8/9, formatting is very slow in LC 7.
The script works on Mac/Win/Linux using LC 6/7/8/9, and on RaspberryPi using (the for Raspi available) LC 651 or LC 704.
Attachments
BeautifyScriptInField_103b.livecode.zip
(v103b works around a lock-cursor-bug)
(8.37 KiB) Downloaded 16 times
beautify.png
At bottom a selection in a field, in midth the 'beautified' selection,
at top added moreover line numbers.
beautify.png (17.81 KiB) Viewed 81 times
Plagiarism is basic to all culture.
(Pete Seeger in a concert, he didn't name an author ...)
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Livecode Membership
 
Posts: 1325
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