Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 03-15-2012, 12:09 AM   #1
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Arrow eink algorithmic art shell scripting

(thread title was: "contest: first screen capture = 500 karma points!")



titty

Here is "titty" (tiny tty - display tiny text on eink display, in a retro "artistic statement" fashion):

click image to see the script





tangle

UPDATE: This thread now has a new script called "tangle" that gives Kindle 3 (Keyboard) owners some "triangle fun":

click image to see the script




rippleweave

Here is "rippleweave" (for kindle 4 and touch) that generates 3D function plot images like this:

click image to see the script

Here is PoP's backport of rippleweave for the Kindle 3:
https://www.mobileread.com/forums/sho....php?p=2011822




spoxbrane
Contest rules:
Run the "spoxbrane" script to completion (about 15 minutes), then make a screen capture and post the image here. If you are the first poster, you win 500 mobileread karma points.


UPDATE: I gave 500 karma points to varnie for the first posted screenshots. I also gave 500 karma points to thomass for the first screenshot of the completed picture.

I will not post my own screen capture until later. I want you to be surprised at what "develops" on the touch or K4 eink screen when you run the "spoxbrane" script.

spoxbrane 1.0c:
Spoiler:
PHP Code:
#!/bin/sh
####################################
# spoxbrane - algorithmic art script
# version 1.0c         by geekmaster
# Copyright (C) 2012 geekmaster
# MIT License: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
####################################

#===================================
# spoxbrane - eink moire pattern art
#-----------------------------------
spoxbrane() {
  
local i j r
  eips 
--# flash clear
  
eips 19 18 "Spoxbrane 1.0c"sleep 2
  eips 19 20 
"by Geekmaster"sleep 4
  eips 
--# flash clear
  
i=100; while [[ $i -gt 0 ]];do
    
i=$((i-1)); j=$((150-i)); r=$((i*2+1))
    
circle $HX+35 $HY $rline $((i*4)) 0 $MX $((i*16/3))
    
circle $HX $HY+90 $rline $MX $((i*16/3)) $((j*4)) $MY
    circle $HX
-35 $HY $rline $((j*4)) $MY 0 $((j*16/3))
    
circle $HX $HY-90 $rline 0 $((j*16/3)) $((i*4)) 0
  done
line $MX 0 $MX $MYline $MX $MY 0 $MY
}

#===========================
# initvar - init global vars
#---------------------------
initvar() {
  
DZ=/dev/zero DN=/dev/null DF=/dev/fb0 MX=599 MY=799 HX=300 HY=400
  set 
$(eips -i|grep line_length); VX=$4
}

#==================================
# line - Bresenham's line algorithm
# usage: line x0 y0 x y
#----------------------------------
line() {
  
local x0=$1 y0=$2 x=$3 y=$4local dx dy sx sy e e2
  
if [[ $x -gt $x0 ]];then dx=$((x-x0));sx=1; else dx=$((x0-x));sx=-1;fi
  
if [[ $y -gt $y0 ]];then dy=$((y0-y));sy=1; else dy=$((y-y0));sy=-1;fi
  e
=$((dx+dy)); dd if=$DZ of=$DF bs=1 count=1 seek=$((y*VX+x)) 2>$DN
  
while [[ $x0 -ne $x || $y0 -ne $y ]];do
    
dd if=$DZ of=$DF bs=1 count=1 seek=$((y0*VX+x0)) 2>$DN
    e2
=$((e+e))
    if [[ 
$e2 -gt $dy ]];then e=$((e+dy));x0=$((x0+sx));fi
    
if [[ $e2 -lt $dx ]];then e=$((e+dx));y0=$((y0+sy));fi
  done
eips '' # update display
}

#===================================
# circle - midpoint circle algorithm
# usage: circle cx cy r
#-----------------------------------
circle() {
  
local cx=$1 cy=$2 r=$3local e=$((-r)) x=$r y=0
  
while [[ $x -ge $y ]];do
    
dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy+y)*VX+cx+x))
    
dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy+y)*VX+cx-x))
    
dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy-y)*VX+cx+x))
    
dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy-y)*VX+cx-x))
    
dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy+x)*VX+cx+y))
    
dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy+x)*VX+cx-y))
    
dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy-x)*VX+cx+y))
    
dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy-x)*VX+cx-y))
    
e=$((e+2*y+1)); y=$((y+1))
    if [[ 
$e -ge 0 ]];then e=$((e-2*x-1));x=$((x-1));fi
  done 2
>$DNeips '' # update display
}

initvar # init global vars
spoxbrane # eink moire pattern art 

The "spoxbrane" script (click "Show" in above Spoiler tag) takes about 15 minutes to run to completion on my touch (booted from main), or 13 minutes on my K4 (booted from diags). It runs when booted from main or diags, and it can run from a RUNME.sh script (loaded by data.tar.gz), or from an SSH command line (in main or diags).

It is completely safe (other than consuming your time while you watch it run). As you can see in the code above, it ONLY writes to /dev/fb0 (the eink framebuffer device).

There is less interference from the kindle desktop framework when booted from the main system partition if you tap the power button to start screensaver mode before starting this script from SSH.

You can save the final results with "dd if=/dev/fb0 of=/mnt/us/spoxbrane.raw", then convert that to a 600x800 8-bit grayscale PNG file with IrfanView for Windows, or the Gimp or other favorite app in linux.

Post it here, and if you are the first poster, you get 500 karma points.

Feel free to modify the script to generate different "algorithmic art" pictures, and post those here too.

Enjoy!

UPDATE: Here is the *real* original post that started this series of scripts:
https://www.mobileread.com/forums/sho....php?p=1997659

P.S. This was developed to go with my touchscreen support code, for buttons and onscreen keyboard (all done in /bin/sh script with minimal dependencies on other programs). This is a bit slower than it would be in C, but I think it is cool that it can even be done at all this way. It is an elegant and clever hack, IMHO.

EDIT: I made small cosmetic improvements to the code above and in spoxbrane.gz below, but they are functionally identical to the original code first posted here, so no need to download it again. I also removed unused residual "touchscreen support" code.

You can download spoxbrane.gz (v1.0c) below:
Attached Files
File Type: gz spoxbrane.gz (881 Bytes, 377 views)

Last edited by geekmaster; 10-31-2012 at 02:42 PM. Reason: severe typophrenia
geekmaster is offline   Reply With Quote
Old 03-15-2012, 02:04 AM   #2
varnie
Connoisseur
varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
Posts: 99
Karma: 30196
Join Date: Dec 2011
Device: Kindle Touch
here're my screenshots
ps: by the way I made them using home button technique as described here: https://wiki.mobileread.com/wiki/Kind...ng_screenshots
Attached Thumbnails
Click image for larger version

Name:	screenshot_2012-03-15T12_03_03-0000.gif
Views:	559
Size:	26.5 KB
ID:	83949   Click image for larger version

Name:	screenshot_2012-03-15T12_19_30-0000.gif
Views:	613
Size:	44.9 KB
ID:	83950   Click image for larger version

Name:	screenshot_2012-03-15T13_12_02-0000.gif
Views:	599
Size:	45.9 KB
ID:	83952  

Last edited by varnie; 03-15-2012 at 03:13 AM.
varnie is offline   Reply With Quote
Old 03-15-2012, 05:20 AM   #3
thomass
Wizard
thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.
 
Posts: 1,669
Karma: 2300001
Join Date: Mar 2011
Location: Türkiye
Device: Kindle 5.3.7
Wow, this is cool

Thanks

And, this is the complete version of the screenshot ( by preventing screensaver )
Click image for larger version

Name:	screenshot_2012-03-15T12_02_48-0159.gif
Views:	658
Size:	49.1 KB
ID:	83953

Spoiler:
Code:
#!/bin/sh
####################################
# spoxbrane - algorithmic art script
# version 1.0          by geekmaster
####################################

#===================================
# spoxbrane - eink moire pattern art
#-----------------------------------
spoxbrane() {
  local i j r
  eips -c -f # flash clear
  eips 19 18 "Spoxbrane 1.0"
  sleep 2
  eips 19 20 "by Geekmaster"
  sleep 4
  eips -c -f # flash clear
  i=100; while [[ $i -gt 0 ]];do
    i=$((i-1)); j=$((150-i)); r=$((i*2+1))
    line $((i*4)) 0 599 $((i*16/3))
    circle 335 400 $r
    line 599 $((i*16/3)) $((j*4)) 799
    circle 300 490 $r                
    line $((j*4)) 799 0 $((j*16/3))
    circle 265 400 $r              
    line 0 $((j*16/3)) $((i*4)) 0
    circle 300 310 $r            
  done                 
}     
 
#===========================
# initvar - init global vars
#---------------------------
initvar() {                 
  local i  
  DZ=/dev/zero DN=/dev/null DI=/dev/input DF=/dev/fb0
  T=$(for i in $DI/event*;do evtest info $i|grep zforce>$DN && echo $i;done)
  set $(eips -i|grep line_length); VX=$4                                    
}                                       
 
#==================================
# line - Bresenham's line algorithm
# usage: line x0 y0 x1 y1          
#----------------------------------
line() {                           
  local x0=$1 y0=$2 x1=$3 y1=$4
  local dx dy sx sy            
  if [[ $x1 -gt $x0 ]];then dx=$((x1-x0));sx=1; else dx=$((x0-x1));sx=-1;fi
  if [[ $y1 -gt $y0 ]];then ny=$((y0-y1));sy=1; else ny=$((y1-y0));sy=-1;fi
  e=$((dx+ny))                                                             
  while [[ $x0 -ne $x1 || $y0 -ne $y1 ]];do
    dd if=$DZ of=$DF bs=1 count=1 seek=$((y0*VX+x0)) 2>$DN
    e2=$((e+e))                                           
    if [[ $e2 -gt $ny ]];then e=$((e+ny));x0=$((x0+sx));fi
    if [[ $e2 -lt $dx ]];then e=$((e+dx));y0=$((y0+sy));fi
  done                                                    
  dd if=$DZ of=$DF bs=1 count=1 seek=$((y0*VX+x0)) 2>$DN
  eips '' # update display                              
}                         
 
#===================================
# circle - midpoint circle algorithm
# usage: circle cx cy r             
#-----------------------------------
circle() {                          
  local cx=$1 cy=$2 r=$3
  local e=$((-r)) x=$r y=0
  while [[ $x -ge $y ]];do
    dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy+y)*VX+cx+x))
    dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy+y)*VX+cx-x))
    dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy-y)*VX+cx+x))
    dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy-y)*VX+cx-x))
    dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy+x)*VX+cx+y))
    dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy+x)*VX+cx-y))
    dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy-x)*VX+cx+y))
    dd if=$DZ of=$DF bs=1 count=1 seek=$(((cy-x)*VX+cx-y))
    e=$((e+y)); y=$((y+1)); e=$((e+y))                    
    if [[ $e -ge 0 ]];then e=$((e-x));x=$((x-1));e=$((e-x));fi
  done 2>$DN                                                  
  eips '' # update display
}                         
lipc-set-prop com.lab126.powerd preventScreenSaver 1
initvar # init global vars
spoxbrane # eink moire pattern art  

dd if=/dev/fb0 of=/mnt/us/spoxbrane.raw
lipc-set-prop com.lab126.powerd preventScreenSaver 0

Last edited by thomass; 03-15-2012 at 07:06 AM.
thomass is offline   Reply With Quote
Old 03-15-2012, 06:42 AM   #4
varnie
Connoisseur
varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.varnie can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
Posts: 99
Karma: 30196
Join Date: Dec 2011
Device: Kindle Touch
nice shot! I had no time to wait till the end
Just a thought - we can use the power of the script for creating custom screensavers, can't we? It would be cool to get drawing some fractals on the Kindle Touch's screen when it is being idle for some time.
varnie is offline   Reply With Quote
Old 03-15-2012, 06:50 AM   #5
thomass
Wizard
thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.
 
Posts: 1,669
Karma: 2300001
Join Date: Mar 2011
Location: Türkiye
Device: Kindle 5.3.7
Quote:
Originally Posted by varnie View Post
nice shot! I had no time to wait till the end
Just a thought - we can use the power of the script for creating custom screensavers, can't we? It would be cool to get drawing some fractals on the Kindle Touch's screen when it is being idle for some time.
activating the screensaver at the beginning of script (and some semi-random draws) it would be awesome . This would be an additional item for SSModeSwitcher

are there any way to check the screensaver's activity? ( whether it is in usage )
we can insert a check point for this in the first while loop

Last edited by thomass; 03-15-2012 at 07:38 AM.
thomass is offline   Reply With Quote
Old 03-15-2012, 09:29 AM   #6
JustAMan
Groupie
JustAMan doesn't litterJustAMan doesn't litter
 
JustAMan's Avatar
 
Posts: 153
Karma: 113
Join Date: Jan 2012
Location: Russia
Device: Kindle Touch
If you do use it for custom screensaver generation I think you'd have to say "bye-bye, nice to meet you, battery life"...
JustAMan is offline   Reply With Quote
Old 03-15-2012, 09:46 AM   #7
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Question

Quote:
Originally Posted by JustAMan View Post
If you do use it for custom screensaver generation I think you'd have to say "bye-bye, nice to meet you, battery life"...
@JustAMan: Good point for portable use, but it would use less battery if it were recoded in C instead of an interpreted shell script. Also, battery life is not an issue while it is plugged into USB so it can charge. And of course, this could be used to generate static images that could be put into your screensaver folder and used as "normal" screensaver images.

I added 500 karma points to varnie for the first posted screenshots, and another 500 points to thomass for the first complete screenshot.

Here is the screenshot I took using the all-powerful "dd" command:


spoxbrane.png


Q1) From what cultural reference (popular TV episode) was the name of this script derived?
A1) Star Trek, Spock's Brain: http://www.youtube.com/watch?v=2zKDQfVbWqc

Q2) What two properties of the title character of that TV episode fit the image created by this "spoxbrane" script?
A2) Well, the dark inner part of the image looks like a brain in an artistic sort of way, and it was created analytically, which is a trademark property of the title character of that TV episode.

Q3) Does the screensaver interfere with this script?
A3) Not when you run it from diags SSH like I do.

Q4) It takes 13 to 15 minutes to generate the image with this shell script. Faster image generation would consume less battery when not connected to USB. How fast is this image generated after converting the spoxbrane script to a C program?
A4) I don't know. It's on my "To Do" list. Anybody with "spare time" want to provide that answer?

P.S. The original spoxbrane script (before being simplified for this post) could generate different images based on random values obtained like this:
set $(hexdump -n10 /dev/urandom); local n1=$2 n2=$3 n3=$4 n4=$5 n5=$6
Then you need to scale these (0-65535) random numbers to fit the 600x800 display like this:
x=$((n1*600/65536)) y=$((n2*800/65536))

Enjoy playing with this stuff!

P.S. Here is a little "Spock-related" bonus humor for your enjoyment:


Last edited by geekmaster; 03-22-2012 at 03:18 PM.
geekmaster is offline   Reply With Quote
Old 03-16-2012, 11:34 AM   #8
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Now that the contest is over, the title of this thread has changed from "contest: first screen capture = 500 karma points!" to "eink algorithmic art shell scripting" to reflect its interesting (to some) and potentially useful (to many) content.

Let's see some "different" eink graphical art posted to this thread!

Thanks.

Last edited by geekmaster; 03-16-2012 at 11:36 AM.
geekmaster is offline   Reply With Quote
Old 03-16-2012, 04:08 PM   #9
PoP
 curly᷂͓̫̙᷊̥̮̾ͯͤͭͬͦͨ ʎʌɹnɔ
PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.
 
PoP's Avatar
 
Posts: 3,002
Karma: 50506927
Join Date: Dec 2010
Location: ♁ ᴺ₄₅°₃₀' ᵂ₇₃°₃₇' ±₆₀"
Device: K3₃.₄.₃ PW3&4₅.₁₃.₃
Pretty neat Geekmaster. On my Kindle Keyboard, it draws white on white (/def/zero over eips -c background. I cheated by removing the clear and starting spoxbrane over a black screensaver.

Cool:
Spoiler:

Click image for larger version

Name:	spoxbrane.gif
Views:	747
Size:	21.7 KB
ID:	84047
PoP is offline   Reply With Quote
Old 03-16-2012, 05:17 PM   #10
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by PoP View Post
Pretty neat Geekmaster. On my Kindle Keyboard, it draws white on white (/def/zero over eips -c background. I cheated by removing the clear and starting spoxbrane over a black screensaver.

Cool:
@PoP: Good job! I was going to add support for the K3 when I convert this to a C program (some day). It is nice to see somebody take the initiative to do new things (for which I usually bump their karma to 2600, like I just *tried* to do for you). Unfortunately, mobileread usually has an "off by one" error when adding karma points, but this time it showed my adjustment as an extra point, so you got an extra point. (To *earn* all that karma, please post another screenshot after making the adjustments suggested below.)

On the K3, each byte is two pixels, so to get proper horizontal aliasing for the moire pattern, you should adjust the horizontal step size and divide the widths by 2 (i.e. VX=300 MX=300, etc.).

Although I did not test it yet, spoxbrane should work on a DX and DXG too (with the above K3 adjustments), but it would only draw on the upper-left 600x800 unless you adjusted the code to use more of the screen space.

Last edited by geekmaster; 03-16-2012 at 06:02 PM.
geekmaster is offline   Reply With Quote
Old 03-16-2012, 05:34 PM   #11
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by thomass View Post
Code:
lipc-set-prop com.lab126.powerd preventScreenSaver 1
initvar # init global vars
spoxbrane # eink moire pattern art  

dd if=/dev/fb0 of=/mnt/us/spoxbrane.raw
lipc-set-prop com.lab126.powerd preventScreenSaver 0
Rather than doing a lipc command to stop the screensaver, I usually prevent all display overwrites by pausing the framework like this:

killall -stop Xorg cvm 2>/dev/null # pause framework
spoxbrane # draw stuff on framebuffer
killall -cont cvm Xorg 2>/dev/null # resume framework

Pausing and resuming the framework is almost instant, unlike a very slow "normal" framework stop and restart like the way other native apps (like Qt) do it. The downside of doing it my way is that the paused framework still consumes a lot of memory, while a full stop frees up all that memory. We do not need much memory, so I like just transparently and instantly pausing and resuming the framework as shown above.

On a K4 or earlier, you can remove "Xorg" from those "killall" commands.

Last edited by geekmaster; 03-16-2012 at 06:09 PM.
geekmaster is offline   Reply With Quote
Old 03-16-2012, 05:51 PM   #12
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Arrow rippleweave 1.0



rippleweave

Surprise! I have been busy lately. Here is a little gem I whipped up to keep this thread alive. I am actually quite surprised how little interest there seems to be in this stuff, considering how well eink displays work for algorithmic graphic art. How about some feedback so I do not feel so all alone here...

I find it rather interesting to watch the artwork while it is being created, which reveals the inside of the 3D shape as layers are drawn on the display. Like the midpoint circle algorithm used in the spoxbrane script, this script also "multitasks" by exploiting the 8-way symmetry of the "pseudo-mexhat" function being plotted.

Although the Taylor series sine function used here could be made a bit faster by limiting it to an O(5) series half-cycle instead of an O(7) series full-cycle, it would require mirroring the half-cycle (similar to the full-cycle looping now used, but with added reflection). I opted to keep the code as simple as possible by leaving out this potential speed optimization.

rippleweave 1.0a:
Spoiler:
PHP Code:
#!/bin/sh
######################################
# rippleweave - algorithmic art script
# version 1.0a           by geekmaster
# Copyright (C) 2012 geekmaster
# MIT License: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
######################################

#===========================
# initvar - init global vars
#---------------------------
initvar() {
  
DZ=/dev/zero DN=/dev/null DF=/dev/fb0 MX=599 MY=799 HX=300 HY=400
  set 
$(eips -i|grep line_length); VX=$4
  FP
=1000 # fixed-point scale factor
  
FH=500 # FP/2 (for rounding)
  
PI=3142 # PI (scaled)
  
P2=6283 # 2*PI (scaled)
  
PN=-3142 # -PI (scaled)
}

#==================================
# line - Bresenham's line algorithm
# usage: line x0 y0 x y
#----------------------------------
line() {
  
local x0=$1 y0=$2 x=$3 y=$4local dx dy sx sy e e2 xw xp=$x0
  
if [[ $x -gt $x0 ]];then dx=$((x-x0));sx=1; else dx=$((x0-x));sx=-1;fi
  
if [[ $y -gt $y0 ]];then dy=$((y0-y));sy=1; else dy=$((y-y0));sy=-1;fi
  e
=$((dx+dy)); dd if=$DZ of=$DF bs=1 count=1 seek=$((y*VX+x)) 2>$DN
  
while [[ $x0 -ne $x -o $y0 -ne $y ]];do
    
xw=$((x0-xp)); [[ $xw -lt 0 ]]&& xw=$((-xw))
    
dd if=$DZ of=$DF bs=1 count=1 seek=$((y0*VX+x0)) 2>$DN
    e2
=$((e+e))
    if [[ 
$e2 -gt $dy ]];then e=$((e+dy));x0=$((x0+sx));fi
    
if [[ $e2 -lt $dx ]];then
      xp
=$x0;e=$((e+dx));y0=$((y0+sy))
    
fi
  done
;
}

#=================================
# line3d - draw 3D line to (x,y,z)
# usage: line3d x0 y0 x y z cx cy
#   x,y:-50..50 z:-150..150
#   cy,cy:center graph coords
#   x0,y0:old graph coords
# STDOUT: xg yg (new graph coords)
#---------------------------------
line3d() {
  
local x0=$1 y0=$2 x=$3 y=$4 z=$5 cx=$6 cy=$7local xg yg
  xg
=$((cx+x*6+(y*2))); yg=$(((cy-y*4+x*2)-z))
  [[ 
$x0 -ge 0 && $y0 -ge 0 ]]&& line $y0 $x0 $yg $xg
  
echo $xg $yg
}

#==================================
# sin - Taylor series sine function
# usage: sin x  (-PI..PI)
# STDOUT: sin(x)  (0..1K)
# O(5) @ +-90 deg, O(7) @ +-180 deg
# 1K fixed-point scale factor 
#----------------------------------
sin() {
  
local x=$1
  
while [[ $x -gt $PI ]];do x=$((x-$P2));done
  
while [[ $x -lt $PN ]];do x=$((x+$P2));done
  local a
=$x xs=$(((x*x+FH)/FP))
  
local xn=$(((x*xs+FH)/FP)) fn=# O(3)
  
a=$((a-(xn+fn/2)/fn)) xn=$(((xn*xs+FH)/FP)) fn=$((fn*20)) # O(5)
  
a=$((a+(xn+fn/2)/fn)) xn=$(((xn*xs+FH)/FP)) fn=$((fn*42)) # O(7)
  
a=$((a-(xn+fn/2)/fn)); echo $(((a+FP+1)/2))
}

#==============================
# mexhat - mexican hat function
# usage: mexhat x y  (-50..50)
# STDOUT: mexhat  (*1K)
#------------------------------
mexhat() {
  
local x=$1 y=$2local yf yx xf xs rs s
  yf
=$((y*FP/13)); ys=$(((yf*yf+FH)/FP))
  
xf=$((x*FP/13)); xs=$(((xf*xf+FH)/FP))
  
rs=$((xs+ys)); s=$(sin $rs)
  if [[ 
$rs -gt $((FP*8/10)) ]];then echo $((s*FP/rs))
  else echo $((
FP*18/10-rs));fi
}

#================================
# rippleweave - 3d function plot
# mexhat 8-way symmetry graph
# (800x600 landscape mode)
#---------------------------------
rippleweave() {
  
local cx=$HY cy=$HX y1 y2 y3 y4 y5 y6 y7 y8
  line 0 0 $MX 0
line $MX 0 $MX $MYline $MX $MY 0 $MYline 0 $MY 0 0
  
for y in $(seq 0 2 50);do
    
y1=-1 y2=-1 y3=-1 y4=-1 y5=-1 y6=-1 y7=-1 y8=-1
    
for x in $(seq 0 2 50);do
      
f=$(mexhat $((x-50)) $((y-50))); fg=$((-150*f/FP))
      
set $(line3d $x1 $y1 $((x-50)) $((y-50)) $fg $cx $cy); x1=$1 y1=$2
      set 
$(line3d $x2 $y2 $((x-50)) $((50-y)) $fg $cx $cy); x2=$1 y2=$2
      set 
$(line3d $x3 $y3 $((50-x)) $((50-y)) $fg $cx $cy); x3=$1 y3=$2
      set 
$(line3d $x4 $y4 $((50-x)) $((y-50)) $fg $cx $cy); x4=$1 y4=$2
      set 
$(line3d $x5 $y5 $((y-50)) $((x-50)) $fg $cx $cy); x5=$1 y5=$2
      set 
$(line3d $x6 $y6 $((y-50)) $((50-x)) $fg $cx $cy); x6=$1 y6=$2
      set 
$(line3d $x7 $y7 $((50-y)) $((50-x)) $fg $cx $cy); x7=$1 y7=$2
      set 
$(line3d $x8 $y8 $((50-y)) $((x-50)) $fg $cx $cy); x8=$1 y8=$2
      eips 
'' # update display (removed from line function for speed)
    
done
  done
}
                    
lipc-set-prop com.lab126.powerd preventScreenSaver 1
killall 
-stop Xorg cvm # pause framework

eips --f
initvar 
# init global vars
rippleweave # 3d function plot

dd if=/dev/fb0 bs=1K count=512 of=/mnt/us/rippleweave.raw
killall 
-cont cvm Xorg # resume framework
lipc-set-prop com.lab126.powerd preventScreenSaver 0 

The "rippleweave" script (click "Show" in above Spoiler tag) takes less than 3 minutes to run to completion on my touch (booted from main).

It is completely safe (other than consuming your time while you watch it run). As you can see in the code above, it ONLY writes to /dev/fb0 (the eink framebuffer device).

This script disables screensaver mode using the method provided by thomass, but also pauses the framework to prevent framework status messages from polluting the artwork. The framework is resumed and screensaver mode reenabled after a completed screenshot image is saved to "rippleweave.raw" on the USB drive.

You can convert the raw screenshot image to an 800x600 8-bit grayscale PNG file with IrfanView for Windows, or the Gimp or other favorite app in linux.

Here is a full-size 800x600 (landscape mode) converted screenshot from this rippleweave script:
Spoiler:

Here are some reduced-size screenshots taken while the function was being plotted on the eink screen:




Feel free to modify this script to generate different "algorithmic art" pictures, and post those here too.

Enjoy!

Q1) What's "rippleweave"?
A1) Ripple Weave Socks: http://mimoknits.typepad.com/photos/...lue_socks.html

Q2) What function is plotted on those socks anyway?
A2) Umm... Good question!

Q3) What's a "mexhat" function?
A3) The most common "mexhat" function is the Ricker Wavelet, but rippleweave uses a variation of a simpler sinusoidal wavelet function (also sometimes called a mexhat function).

You can download rippleweave.gz (v1.0) below:
Attached Files
File Type: gz rippleweave.gz (1.6 KB, 439 views)

Last edited by geekmaster; 03-31-2012 at 12:26 PM. Reason: fix typos
geekmaster is offline   Reply With Quote
Old 03-18-2012, 02:23 PM   #13
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
What? No computer graphics fans, math-heads, or script-kiddies hang out in this forum?

Check out the rippleweave script in the previous post in this thread. If you do *any* scripting, you might learn something from the script source code. And feel free to modify it to plot other math functions. Please post screenshots here.

Thanks.

EDIT: If you examine my source code, you will see that I like to write solid condensed code, which fits nicely on 80x25 text displays without requiring a lot of vertical scrolling. I do this to support my "keyboard-only" coding-trance sessions, which are severely hampered by hand-eye coordination required by mouse and GUI menus. When I modify other peoples' code, I try to make my changes transparently blend into their code. Please keep modifications to my code that you post here in my condensed style so that I can reuse it. If you prefer finger-length variable names or fluffy "popcorn" code littered with whitespace (e.g. lab126 scripts), please post that to your own threads. Thanks.

EDIT 2: And remember, what is important here is the fact that we can do cool stuff with our kindles now that we have SSH access to them. And these scripts require very little support from external programs (but this one cheats and uses "seq" here when it could use shell arithmetic loop control like spoxbrane did). These graphical scripts even work from a RUNME.sh script called from my data.tar.gz payload, used for debricking kindles. I plan to use the kindle framebuffer graphics script library I am developing for use in my "universal kindle debricking system", but they have far more uses than just that. This is *why* I am delving into eink algorithmic art (to test my functions, and to gain "followers" to my line of thought).

Last edited by geekmaster; 03-18-2012 at 06:39 PM.
geekmaster is offline   Reply With Quote
Old 03-18-2012, 02:34 PM   #14
lukeroge
Enthusiast
lukeroge began at the beginning.
 
Posts: 35
Karma: 10
Join Date: Feb 2012
Device: Kindle Touch
Quote:
Originally Posted by geekmaster View Post
What? No computer graphics fans, math-heads, or script-kiddies hang out in this forum?

Check out the rippleweave script in the previous post in this thread. If you do *any* scripting, you might learn something from the script source code. And feel free to modify it to plot other math functions. Please post screenshots here.

Thanks.
I'll give this a try later
lukeroge is offline   Reply With Quote
Old 03-18-2012, 04:07 PM   #15
PoP
 curly᷂͓̫̙᷊̥̮̾ͯͤͭͬͦͨ ʎʌɹnɔ
PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.
 
PoP's Avatar
 
Posts: 3,002
Karma: 50506927
Join Date: Dec 2010
Location: ♁ ᴺ₄₅°₃₀' ᵂ₇₃°₃₇' ±₆₀"
Device: K3₃.₄.₃ PW3&4₅.₁₃.₃
Quote:
Originally Posted by geekmaster View Post

EDIT: If you examine my source code, you will see that I like to write solid condensed code,
...
Please keep modifications to my code that you post here in my condensed style so that I can reuse it.
Sure. In its time I liked APL too though it bit me more than once.

I just want to plead innocence and point that on my KK v3.3 (blame it on an older or perhaps buggy shell interpreter) I had to expand constructs such as
Code:
while [[ $x0 -ne $x || $y0 -ne $y ]];do
into
Code:
while [[ $x0 -ne $x ]] || [[ $y0 -ne $y ]];do
to make the script work (loop would otherwise fail with an error message).
PoP is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripting with epub-meta averyml Calibre 20 11-17-2016 10:13 AM
Bunny + Scripting + Calibre = here tBunnyMan Introduce Yourself 4 02-06-2012 12:16 AM
Possible scripting engine for Sigil Valloric Sigil 48 10-17-2009 09:58 AM
Any NetNewsWire Scripting Pros out there? adinb Sony Reader 0 02-25-2007 01:44 AM


All times are GMT -4. The time now is 11:32 PM.


MobileRead.com is a privately owned, operated and funded community.