Walking Trip …

Walking Trip

Walking Trip

Offenbach's Suite ... Warts 'n All

Offenbach's Suite ... Warts 'n All

 📅  

If this was interesting you may be interested in this too.

Posted in Photography, Trips | Tagged , , | 34 Comments

Xcode Executable Finding and Executing Environment Tutorial

Xcode Executable Finding and Executing Environment Tutorial

Xcode Executable Finding and Executing Environment Tutorial

If a project is generic enough in concepts, it is bound to favour, not necessarily at it’s genesis, thoughts regarding “layers of expansion”, and with the project of yesterday’s Xcode Executable Finding and Executing Arguments Tutorial we can think of a couple, or maybe even a few, such layers, the “first cab off the rank” considering …

the Environment the PHP runs in

Today, we give meaning to a public domain Environment means of running the find_xcode_executable.php PHP within, that involving new considerations to the workings of the web application URL …


https://www.rjmprogramming.com.au/find_xcode_executable.php

… is pointing at having some practical usage and meaning, that, today, is happening because we allow, for find_xcode_executable.php PHP usage up at the public RJM Programming domain …

  1. user can enter a URL of interest (with or without arguments) … in a new input type=url element … possible by feeding previous PHP passthru calls through a PHP wrapper function as per …
    <?php

    function ourpassthru($passwhat) {
    if (strpos($passwhat, "\\\"http") !== false || strpos($passwhat, "\\\"//") !== false) {
    if (strtoupper(PHP_OS) == 'DARWIN') {
    $rest=explode('"',explode("\\\"", $passwhat)[2])[0];
    echo "tab 1 of window ";
    $upref="";
    if (strpos($passwhat, "\\\"//") !== false) {
    $upref="https:";
    }
    if (strpos($rest, '&') !== false) {
    return exec('open "' . $upref . explode("\\\"", $passwhat)[1] . trim($rest) . '"');
    } else {
    return exec('open ' . $upref . explode("\\\"", $passwhat)[1] . trim($rest));
    }
    } else {
    $rest=explode('"',explode("\\\"", $passwhat)[2])[0];
    echo "<html><body onload=\"document.getElementById('mya').click();\"><a target=_blank href=\"" . explode("\\\"", $passwhat)[1] . trim($rest) . "\" id=mya style=text-decoration:none;>tab 1 of window</a>";
    exit;
    }
    }
    if (!isset($argc)) {
    if (strpos($_SERVER['SERVER_NAME'], 'localhost') === false) {
    return exec($passwhat);
    }
    }
    return passthru($passwhat);
    }

    ?>
  2. should a user enter into the existant Executable path textbox, using find_xcode_executable.php PHP up at the public RJM Programming domain way, an Xcode project executable path the web application there will try to open a macOS or Windows local web server URL window (just in cases)

… in the changed find_xcode_executable.php third draft now with more meaning as a live run link.


Previous relevant Xcode Executable Finding and Executing Arguments Tutorial is shown below.

Xcode Executable Finding and Executing Arguments Tutorial

Xcode Executable Finding and Executing Arguments Tutorial

Yesterday’s Xcode Executable Finding and Executing Tutorial set up a “first draft” PHP (via a macOS web browser address bar MAMP local web server based URL) web application means to select an Xcode project, glean it’s executable and from an HTML form have the web application execute that Xcode executable within the Terminal desktop application.

It allowed for arguments to be entered within that form, but this first draft needed more thinking regarding that part, as per …

  • our double quote encompassing of the arguments, in the code (as we did for the executable path), is rarely the right approach, and we’ve fixed this in a second draft …
  • to just term these “Argument(s)” is too simplistic … as of second draft we term it …

    Arguments and/or pipes and/or redirects and/or switches

  • and after an execution run using a piped command part | tee -a x.x and finding output was sent to x.x but, weirdly, the prompts for interactive entries disappeared, and so, we asked use of pipe to tee in macos caused prompting to disappear so is there an alternative command to log a program but leave the prompts showing to receive the good macOS advice below …

    Run script followed by your log file name and the command you want to run:
    bash
    script output.log your_command –flags

    … and so coded to help users achieve this via a Logging checkbox

  • we added more functionality to the Xcode *.xcodeproj finding arrangements …

    URL suffix such as ?startin=/ will scour whole disk rather than just off MAMP Document Root for *.xcodeproj Xcode project files.

  • we style the webpage better as per …

    <style>
    select { background-color: #f0f0f0; }
    #execexec { background-color: #fadadd; }
    #argsare { background-color: #d6fffe; }
    </style>

… in the changed find_xcode_executable.php second draft.


Previous relevant Xcode Executable Finding and Executing Tutorial is shown below.

Xcode Executable Finding and Executing Tutorial

Xcode Executable Finding and Executing Tutorial

The Xcode IDE on macOS, as a desktop application, for …


Xcode -> New -> Project... -> macOS / Command Line Tool -> Product Name: [up to you] Language: C

… represents, perhaps, the simplest and immediately approachable Xcode Project combination to try. But even here, you will find it as easy as falling off a log to create an executable that “runs” within the Xcode IDE environment (where, behind the scenes, Xcode has compiled your code into an executable program or application). But Xcode does a great job at making it hard for you to track down where, on your hard disk, it created the executable. And because we are very much “old school” from the command line days where paths to executables were known and a part of the mix for programmers to be totally au fait around, we’re going to write …

  • using PHP server language
  • under a macOS MAMP Apache/PHP local web server environment …
  • following great advice of can a command line xcode command determine the executable path for an xcode project name? we base the logic around setting up command like …

    xcodebuild -project YourProject.xcodeproj -scheme YourScheme -showBuildSettings | grep -E “^\s*(TARGET_BUILD_DIR|EXECUTABLE_PATH) =”

    … exemplified by, for us …

    xcodebuild -project "My Next File C Program.xcodeproj" -scheme "My Next File C Program" -showBuildSettings | grep -E "^\s*(TARGET_BUILD_DIR|EXECUTABLE_PATH) ="

    … resulting in …

    2026-11-22 17:57:15.240 xcodebuild[30786:4838683] [MT] IDERunDestination: Supported platforms for the buildables in the current scheme is empty.
    — xcodebuild: WARNING: Using the first of multiple matching destinations:
    { platform:macOS, arch:arm64, id:00008103-000328410EA2001E, name:My Mac }
    { platform:macOS, arch:x86_64, id:00008103-000328410EA2001E, name:My Mac }
    { platform:macOS, name:Any Mac }
    EXECUTABLE_PATH = My Next File C Program
    TARGET_BUILD_DIR = /Users/user/Library/Developer/Xcode/DerivedData/My_Next_File_C_Program-blfjoaxttlpyniaghlsxiantcafy/Build/Products/Debug

… as a means forward to help “unlock the secrets of the Xcode“!

From there, as many programmers will know, as soon as keyboard interactive entry gets to be involved with the execution of a compiled language (in our case C) program, starting with a web browser address bar, it’s really difficult to arrange up at the public RJM Programming, but here on macOS MAMP within an
http://localhost:8888/find_xcode_executable.php
web browser address bar call we are allowed to code for PHP …


passthru

… (deemed a security threat up at the public RJM Programming web server) but which was our macOS MAMP pass through to …

  • macOS Terminal desktop application …
  • called to run our newly found Xcode C executable, like (with the C code used in C 2D Array via File Tutorial) via command like …

    "/Users/user/Library/Developer/Xcode/DerivedData/My_C_Command_Line_Project-dzaieipcrytesxglwgctjnfynayq/Build/Products/Debug/My C Command Line Project"

    … via passthru command calls like …

    osascript -e 'tell application "Terminal" to do script "\"/Users/user/Library/Developer/Xcode/DerivedData/My_C_Command_Line_Project-dzaieipcrytesxglwgctjnfynayq/Build/Products/Debug/My C Command Line Project\""'

… allowing for interactive entry within that, perhaps new, Terminal window (not necessarily the top window) being a possibility.

And so, day one here, got us to our find_xcode_executable.php proof of concept first draft for this Xcode innards understanding helper web application we run around here up at the address bar of a web browser, and on from there, depending on where the user takes it.


Previous relevant C 2D Array via File Tutorial is shown below.

C 2D Array via File Tutorial

C 2D Array via File Tutorial

You don’t have to use an IDE to do C programming. There is Digital Mars C as an example of that. We have talked about the Xcode command line tools before, that frees the gcc compiler to (also) be a command line tool to write C programs from the command line separate to any IDE usage.

So it is today with this tutorial reading a file of numbers that define the workings of a 2D int array the program requires, inspired by this (old) Yahoo Answers question.

We use stdlib.h’s memory management function calloc to handle the memory management here. The use of calloc, malloc and realloc can aid with dynamically changeable arrangements with your C program’s memory management, and you may be interested in the related previous Xcode Debug C Strings Program Tutorial as shown below.

So feel free to download the C programming source code here and rename it to file_2d_array.c

Hope you enjoy this tutorial showing you some command line C gcc compilation work.

Roberts-MacBook-Pro:tools robertmetcalfe$ cat file_2d_array.c
// file_2d_array.c ... read input file's data into a 2d array
#include "stdio.h"
#include "stdlib.h"
int main (int argc, char* argv[]) {
FILE* spIn;
int rownum;
int colnum;
int** table;
int row;
int column;
int value;
spIn = fopen (argv[1], "r");
if (spIn == NULL)
{
printf (" Did not open haha an");
exit (1);
}
fscanf(spIn,"%d", &rownum);
fscanf(spIn,"%d", &colnum);
table = (int**)calloc ((rownum * colnum), sizeof(int*));
for (row = 0; row < rownum; row++)
{
table[row] = (int*)calloc ((rownum * 1), sizeof(int));
for (column = 0; column < colnum; column++)
{
fscanf(spIn, "%d", &value);
table[row][column] = value;
printf(" table[%d][%d] = %d n", row, column, table[row][column]);
}
}
fclose(spIn);
return 0;
}
Roberts-MacBook-Pro:tools robertmetcalfe$ cat file_2d_array.txt
2 3 1 2 3 12 12
Roberts-MacBook-Pro:tools robertmetcalfe$ gcc file_2d_array.c -o file_2d_array
Roberts-MacBook-Pro:tools robertmetcalfe$ ls -l file_2d_array*
-rwxr-xr-x 1 robertmetcalfe staff 8728 9 Mar 09:00 file_2d_array
-rw-r--r-- 1 robertmetcalfe staff 729 9 Mar 08:59 file_2d_array.c
-rw-r--r-- 1 robertmetcalfe staff 17 9 Mar 08:37 file_2d_array.txt
Roberts-MacBook-Pro:tools robertmetcalfe$ ./file_2d_array file_2d_array.txt
table[0][0] = 1
table[0][1] = 2
table[0][2] = 3
table[1][0] = 12
table[1][1] = 12
table[1][2] = 12
Roberts-MacBook-Pro:tools robertmetcalfe$

A really helpful tutorial for code above is shown here … thanks.


Previous Xcode Debug C Strings Program Tutorial is shown below.

Xcode Debug C Strings Program Tutorial

Xcode Debug C Strings Program Tutorial

Have a bit of an esoteric C programming scenario today, and because it is esoteric, and some or all of you may fall asleep, am also going to show you how to debug in Xcode … and only now just realized with the podcast of this tutorial that we went, on a Mac, control-command-Y a lot and should have, instead, shown you this in menu manipulation terms as Product->Debug->Continue … anyway, if you get into this, you’ll know what is going on.

Okay, so the C scenario in Xcode is a bit esoteric, as sometimes happens when you are answering “a brief” (a Yahoo Answers brief). The brief was not to use strcat in the making of a single string buffer from an array of zero-byte terminated char* strings in an array, with an added stipulation of a maximum string buffer length. Sounds simple, and it is if you use strcat and/or global strings, but my understanding of the brief would be that global variables will be frowned upon, as a lot of programmers will tell you. Mind you, personally, global strings are not a problem for me. Not using global strings and not using strcat, and making this work in a self-sufficient single function is quite interesting, and basically that is what we do here with this tutorial, via memory management using malloc & realloc.

So feel free to download the Xcode C programming source code here and rename it to main.cpp (or main.c … is pretty conservative in its construction … probably would work with Digital Mars C).

Hope you enjoy this tutorial showing you some cute Xcode debugging functionality.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Operating System, Software, Tutorials, Xcode | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Xcode Executable Finding and Executing Arguments Tutorial

Xcode Executable Finding and Executing Arguments Tutorial

Xcode Executable Finding and Executing Arguments Tutorial

Yesterday’s Xcode Executable Finding and Executing Tutorial set up a “first draft” PHP (via a macOS web browser address bar MAMP local web server based URL) web application means to select an Xcode project, glean it’s executable and from an HTML form have the web application execute that Xcode executable within the Terminal desktop application.

It allowed for arguments to be entered within that form, but this first draft needed more thinking regarding that part, as per …

  • our double quote encompassing of the arguments, in the code (as we did for the executable path), is rarely the right approach, and we’ve fixed this in a second draft …
  • to just term these “Argument(s)” is too simplistic … as of second draft we term it …

    Arguments and/or pipes and/or redirects and/or switches

  • and after an execution run using a piped command part | tee -a x.x and finding output was sent to x.x but, weirdly, the prompts for interactive entries disappeared, and so, we asked use of pipe to tee in macos caused prompting to disappear so is there an alternative command to log a program but leave the prompts showing to receive the good macOS advice below …

    Run script followed by your log file name and the command you want to run:
    bash
    script output.log your_command –flags

    … and so coded to help users achieve this via a Logging checkbox

  • we added more functionality to the Xcode *.xcodeproj finding arrangements …

    URL suffix such as ?startin=/ will scour whole disk rather than just off MAMP Document Root for *.xcodeproj Xcode project files.

  • we style the webpage better as per …

    <style>
    select { background-color: #f0f0f0; }
    #execexec { background-color: #fadadd; }
    #argsare { background-color: #d6fffe; }
    </style>

… in the changed find_xcode_executable.php second draft.


Previous relevant Xcode Executable Finding and Executing Tutorial is shown below.

Xcode Executable Finding and Executing Tutorial

Xcode Executable Finding and Executing Tutorial

The Xcode IDE on macOS, as a desktop application, for …


Xcode -> New -> Project... -> macOS / Command Line Tool -> Product Name: [up to you] Language: C

… represents, perhaps, the simplest and immediately approachable Xcode Project combination to try. But even here, you will find it as easy as falling off a log to create an executable that “runs” within the Xcode IDE environment (where, behind the scenes, Xcode has compiled your code into an executable program or application). But Xcode does a great job at making it hard for you to track down where, on your hard disk, it created the executable. And because we are very much “old school” from the command line days where paths to executables were known and a part of the mix for programmers to be totally au fait around, we’re going to write …

  • using PHP server language
  • under a macOS MAMP Apache/PHP local web server environment …
  • following great advice of can a command line xcode command determine the executable path for an xcode project name? we base the logic around setting up command like …

    xcodebuild -project YourProject.xcodeproj -scheme YourScheme -showBuildSettings | grep -E “^\s*(TARGET_BUILD_DIR|EXECUTABLE_PATH) =”

    … exemplified by, for us …

    xcodebuild -project "My Next File C Program.xcodeproj" -scheme "My Next File C Program" -showBuildSettings | grep -E "^\s*(TARGET_BUILD_DIR|EXECUTABLE_PATH) ="

    … resulting in …

    2026-11-22 17:57:15.240 xcodebuild[30786:4838683] [MT] IDERunDestination: Supported platforms for the buildables in the current scheme is empty.
    — xcodebuild: WARNING: Using the first of multiple matching destinations:
    { platform:macOS, arch:arm64, id:00008103-000328410EA2001E, name:My Mac }
    { platform:macOS, arch:x86_64, id:00008103-000328410EA2001E, name:My Mac }
    { platform:macOS, name:Any Mac }
    EXECUTABLE_PATH = My Next File C Program
    TARGET_BUILD_DIR = /Users/user/Library/Developer/Xcode/DerivedData/My_Next_File_C_Program-blfjoaxttlpyniaghlsxiantcafy/Build/Products/Debug

… as a means forward to help “unlock the secrets of the Xcode“!

From there, as many programmers will know, as soon as keyboard interactive entry gets to be involved with the execution of a compiled language (in our case C) program, starting with a web browser address bar, it’s really difficult to arrange up at the public RJM Programming, but here on macOS MAMP within an
http://localhost:8888/find_xcode_executable.php
web browser address bar call we are allowed to code for PHP …


passthru

… (deemed a security threat up at the public RJM Programming web server) but which was our macOS MAMP pass through to …

  • macOS Terminal desktop application …
  • called to run our newly found Xcode C executable, like (with the C code used in C 2D Array via File Tutorial) via command like …

    "/Users/user/Library/Developer/Xcode/DerivedData/My_C_Command_Line_Project-dzaieipcrytesxglwgctjnfynayq/Build/Products/Debug/My C Command Line Project"

    … via passthru command calls like …

    osascript -e 'tell application "Terminal" to do script "\"/Users/user/Library/Developer/Xcode/DerivedData/My_C_Command_Line_Project-dzaieipcrytesxglwgctjnfynayq/Build/Products/Debug/My C Command Line Project\""'

… allowing for interactive entry within that, perhaps new, Terminal window (not necessarily the top window) being a possibility.

And so, day one here, got us to our find_xcode_executable.php proof of concept first draft for this Xcode innards understanding helper web application we run around here up at the address bar of a web browser, and on from there, depending on where the user takes it.


Previous relevant C 2D Array via File Tutorial is shown below.

C 2D Array via File Tutorial

C 2D Array via File Tutorial

You don’t have to use an IDE to do C programming. There is Digital Mars C as an example of that. We have talked about the Xcode command line tools before, that frees the gcc compiler to (also) be a command line tool to write C programs from the command line separate to any IDE usage.

So it is today with this tutorial reading a file of numbers that define the workings of a 2D int array the program requires, inspired by this (old) Yahoo Answers question.

We use stdlib.h’s memory management function calloc to handle the memory management here. The use of calloc, malloc and realloc can aid with dynamically changeable arrangements with your C program’s memory management, and you may be interested in the related previous Xcode Debug C Strings Program Tutorial as shown below.

So feel free to download the C programming source code here and rename it to file_2d_array.c

Hope you enjoy this tutorial showing you some command line C gcc compilation work.

Roberts-MacBook-Pro:tools robertmetcalfe$ cat file_2d_array.c
// file_2d_array.c ... read input file's data into a 2d array
#include "stdio.h"
#include "stdlib.h"
int main (int argc, char* argv[]) {
FILE* spIn;
int rownum;
int colnum;
int** table;
int row;
int column;
int value;
spIn = fopen (argv[1], "r");
if (spIn == NULL)
{
printf (" Did not open haha an");
exit (1);
}
fscanf(spIn,"%d", &rownum);
fscanf(spIn,"%d", &colnum);
table = (int**)calloc ((rownum * colnum), sizeof(int*));
for (row = 0; row < rownum; row++)
{
table[row] = (int*)calloc ((rownum * 1), sizeof(int));
for (column = 0; column < colnum; column++)
{
fscanf(spIn, "%d", &value);
table[row][column] = value;
printf(" table[%d][%d] = %d n", row, column, table[row][column]);
}
}
fclose(spIn);
return 0;
}
Roberts-MacBook-Pro:tools robertmetcalfe$ cat file_2d_array.txt
2 3 1 2 3 12 12
Roberts-MacBook-Pro:tools robertmetcalfe$ gcc file_2d_array.c -o file_2d_array
Roberts-MacBook-Pro:tools robertmetcalfe$ ls -l file_2d_array*
-rwxr-xr-x 1 robertmetcalfe staff 8728 9 Mar 09:00 file_2d_array
-rw-r--r-- 1 robertmetcalfe staff 729 9 Mar 08:59 file_2d_array.c
-rw-r--r-- 1 robertmetcalfe staff 17 9 Mar 08:37 file_2d_array.txt
Roberts-MacBook-Pro:tools robertmetcalfe$ ./file_2d_array file_2d_array.txt
table[0][0] = 1
table[0][1] = 2
table[0][2] = 3
table[1][0] = 12
table[1][1] = 12
table[1][2] = 12
Roberts-MacBook-Pro:tools robertmetcalfe$

A really helpful tutorial for code above is shown here … thanks.


Previous Xcode Debug C Strings Program Tutorial is shown below.

Xcode Debug C Strings Program Tutorial

Xcode Debug C Strings Program Tutorial

Have a bit of an esoteric C programming scenario today, and because it is esoteric, and some or all of you may fall asleep, am also going to show you how to debug in Xcode … and only now just realized with the podcast of this tutorial that we went, on a Mac, control-command-Y a lot and should have, instead, shown you this in menu manipulation terms as Product->Debug->Continue … anyway, if you get into this, you’ll know what is going on.

Okay, so the C scenario in Xcode is a bit esoteric, as sometimes happens when you are answering “a brief” (a Yahoo Answers brief). The brief was not to use strcat in the making of a single string buffer from an array of zero-byte terminated char* strings in an array, with an added stipulation of a maximum string buffer length. Sounds simple, and it is if you use strcat and/or global strings, but my understanding of the brief would be that global variables will be frowned upon, as a lot of programmers will tell you. Mind you, personally, global strings are not a problem for me. Not using global strings and not using strcat, and making this work in a self-sufficient single function is quite interesting, and basically that is what we do here with this tutorial, via memory management using malloc & realloc.

So feel free to download the Xcode C programming source code here and rename it to main.cpp (or main.c … is pretty conservative in its construction … probably would work with Digital Mars C).

Hope you enjoy this tutorial showing you some cute Xcode debugging functionality.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Operating System, Software, Tutorials, Xcode | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Xcode Executable Finding and Executing Tutorial

Xcode Executable Finding and Executing Tutorial

Xcode Executable Finding and Executing Tutorial

The Xcode IDE on macOS, as a desktop application, for …


Xcode -> New -> Project... -> macOS / Command Line Tool -> Product Name: [up to you] Language: C

… represents, perhaps, the simplest and immediately approachable Xcode Project combination to try. But even here, you will find it as easy as falling off a log to create an executable that “runs” within the Xcode IDE environment (where, behind the scenes, Xcode has compiled your code into an executable program or application). But Xcode does a great job at making it hard for you to track down where, on your hard disk, it created the executable. And because we are very much “old school” from the command line days where paths to executables were known and a part of the mix for programmers to be totally au fait around, we’re going to write …

  • using PHP server language
  • under a macOS MAMP Apache/PHP local web server environment …
  • following great advice of can a command line xcode command determine the executable path for an xcode project name? we base the logic around setting up command like …

    xcodebuild -project YourProject.xcodeproj -scheme YourScheme -showBuildSettings | grep -E “^\s*(TARGET_BUILD_DIR|EXECUTABLE_PATH) =”

    … exemplified by, for us …

    xcodebuild -project "My Next File C Program.xcodeproj" -scheme "My Next File C Program" -showBuildSettings | grep -E "^\s*(TARGET_BUILD_DIR|EXECUTABLE_PATH) ="

    … resulting in …

    2026-11-22 17:57:15.240 xcodebuild[30786:4838683] [MT] IDERunDestination: Supported platforms for the buildables in the current scheme is empty.
    — xcodebuild: WARNING: Using the first of multiple matching destinations:
    { platform:macOS, arch:arm64, id:00008103-000328410EA2001E, name:My Mac }
    { platform:macOS, arch:x86_64, id:00008103-000328410EA2001E, name:My Mac }
    { platform:macOS, name:Any Mac }
    EXECUTABLE_PATH = My Next File C Program
    TARGET_BUILD_DIR = /Users/user/Library/Developer/Xcode/DerivedData/My_Next_File_C_Program-blfjoaxttlpyniaghlsxiantcafy/Build/Products/Debug

… as a means forward to help “unlock the secrets of the Xcode“!

From there, as many programmers will know, as soon as keyboard interactive entry gets to be involved with the execution of a compiled language (in our case C) program, starting with a web browser address bar, it’s really difficult to arrange up at the public RJM Programming, but here on macOS MAMP within an
http://localhost:8888/find_xcode_executable.php
web browser address bar call we are allowed to code for PHP …


passthru

… (deemed a security threat up at the public RJM Programming web server) but which was our macOS MAMP pass through to …

  • macOS Terminal desktop application …
  • called to run our newly found Xcode C executable, like (with the C code used in C 2D Array via File Tutorial) via command like …

    "/Users/user/Library/Developer/Xcode/DerivedData/My_C_Command_Line_Project-dzaieipcrytesxglwgctjnfynayq/Build/Products/Debug/My C Command Line Project"

    … via passthru command calls like …

    osascript -e 'tell application "Terminal" to do script "\"/Users/user/Library/Developer/Xcode/DerivedData/My_C_Command_Line_Project-dzaieipcrytesxglwgctjnfynayq/Build/Products/Debug/My C Command Line Project\""'

… allowing for interactive entry within that, perhaps new, Terminal window (not necessarily the top window) being a possibility.

And so, day one here, got us to our find_xcode_executable.php proof of concept first draft for this Xcode innards understanding helper web application we run around here up at the address bar of a web browser, and on from there, depending on where the user takes it.


Previous relevant C 2D Array via File Tutorial is shown below.

C 2D Array via File Tutorial

C 2D Array via File Tutorial

You don’t have to use an IDE to do C programming. There is Digital Mars C as an example of that. We have talked about the Xcode command line tools before, that frees the gcc compiler to (also) be a command line tool to write C programs from the command line separate to any IDE usage.

So it is today with this tutorial reading a file of numbers that define the workings of a 2D int array the program requires, inspired by this (old) Yahoo Answers question.

We use stdlib.h’s memory management function calloc to handle the memory management here. The use of calloc, malloc and realloc can aid with dynamically changeable arrangements with your C program’s memory management, and you may be interested in the related previous Xcode Debug C Strings Program Tutorial as shown below.

So feel free to download the C programming source code here and rename it to file_2d_array.c

Hope you enjoy this tutorial showing you some command line C gcc compilation work.

Roberts-MacBook-Pro:tools robertmetcalfe$ cat file_2d_array.c
// file_2d_array.c ... read input file's data into a 2d array
#include "stdio.h"
#include "stdlib.h"
int main (int argc, char* argv[]) {
FILE* spIn;
int rownum;
int colnum;
int** table;
int row;
int column;
int value;
spIn = fopen (argv[1], "r");
if (spIn == NULL)
{
printf (" Did not open haha an");
exit (1);
}
fscanf(spIn,"%d", &rownum);
fscanf(spIn,"%d", &colnum);
table = (int**)calloc ((rownum * colnum), sizeof(int*));
for (row = 0; row < rownum; row++)
{
table[row] = (int*)calloc ((rownum * 1), sizeof(int));
for (column = 0; column < colnum; column++)
{
fscanf(spIn, "%d", &value);
table[row][column] = value;
printf(" table[%d][%d] = %d n", row, column, table[row][column]);
}
}
fclose(spIn);
return 0;
}
Roberts-MacBook-Pro:tools robertmetcalfe$ cat file_2d_array.txt
2 3 1 2 3 12 12
Roberts-MacBook-Pro:tools robertmetcalfe$ gcc file_2d_array.c -o file_2d_array
Roberts-MacBook-Pro:tools robertmetcalfe$ ls -l file_2d_array*
-rwxr-xr-x 1 robertmetcalfe staff 8728 9 Mar 09:00 file_2d_array
-rw-r--r-- 1 robertmetcalfe staff 729 9 Mar 08:59 file_2d_array.c
-rw-r--r-- 1 robertmetcalfe staff 17 9 Mar 08:37 file_2d_array.txt
Roberts-MacBook-Pro:tools robertmetcalfe$ ./file_2d_array file_2d_array.txt
table[0][0] = 1
table[0][1] = 2
table[0][2] = 3
table[1][0] = 12
table[1][1] = 12
table[1][2] = 12
Roberts-MacBook-Pro:tools robertmetcalfe$

A really helpful tutorial for code above is shown here … thanks.


Previous Xcode Debug C Strings Program Tutorial is shown below.

Xcode Debug C Strings Program Tutorial

Xcode Debug C Strings Program Tutorial

Have a bit of an esoteric C programming scenario today, and because it is esoteric, and some or all of you may fall asleep, am also going to show you how to debug in Xcode … and only now just realized with the podcast of this tutorial that we went, on a Mac, control-command-Y a lot and should have, instead, shown you this in menu manipulation terms as Product->Debug->Continue … anyway, if you get into this, you’ll know what is going on.

Okay, so the C scenario in Xcode is a bit esoteric, as sometimes happens when you are answering “a brief” (a Yahoo Answers brief). The brief was not to use strcat in the making of a single string buffer from an array of zero-byte terminated char* strings in an array, with an added stipulation of a maximum string buffer length. Sounds simple, and it is if you use strcat and/or global strings, but my understanding of the brief would be that global variables will be frowned upon, as a lot of programmers will tell you. Mind you, personally, global strings are not a problem for me. Not using global strings and not using strcat, and making this work in a self-sufficient single function is quite interesting, and basically that is what we do here with this tutorial, via memory management using malloc & realloc.

So feel free to download the Xcode C programming source code here and rename it to main.cpp (or main.c … is pretty conservative in its construction … probably would work with Digital Mars C).

Hope you enjoy this tutorial showing you some cute Xcode debugging functionality.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Operating System, Software, Tutorials, Xcode | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

CSS Transform Function Ideas Orderly Sharing Tutorial

CSS Transform Function Ideas Orderly Sharing Tutorial

CSS Transform Function Ideas Orderly Sharing Tutorial

They say …

  • sharing is caring

    … and …

  • chaos was the law of nature; order was the dream of man

… and these two concepts come together as the ways to move forward from CSS Transform Function Ideas Primer Tutorial with our current CSS Transform Function Ideas project today, as per …

sharing

function emailit() {
var anchor = document.createElement('a');
anchor.href = 'mailto:?subject=' + encodeURIComponent('CSS Transform Ideas ... ' + (location.search.split('css=')[1] ? 'Last being ... img { ' + decodeURIComponent(location.search.split('css=')[1].split('&')[0]).replace(/\+/g,' ') + ' } ' : '')) + '&body=' + encodeURIComponent(document.URL);
anchor.style.display='none';
anchor.innerHTML='Email';
anchor.target='_top';
anchor.click();
}

function smsit() {
var anchor = document.createElement('a');
anchor.href = 'sms:&body=' + encodeURIComponent(document.URL);
anchor.style.display='none';
anchor.innerHTML='Email';
anchor.target='_top';
anchor.click();
}
order

function reorder(itexto) {
var neword=[], keep_going=true, jof=0, lookfor=1, nextass=2;
if (('' + itexto.id).trim() != '') {
if (eval('' + ordersofar.length) == 0) {
ordersofar.push(itexto.id);
//cp=String.fromCodePoint(eval('0x00003' + nextinorder),0x00fe0f,0x0020e3);
//alert(cp);
//itexto.style.backgroundImage="url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewport='0 0 100 100' style='font-family:Verdana;font-size:10px;color:rgba(0,0,0,0.5);'><text y='50%'>" + "\\00003" + nextinorder + "\\00fe0f\0020e3" + "</text></svg>\")";
itexto.style.backgroundImage="url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewport='0 0 100 100' style='font-family:Verdana;font-size:10px;color:rgba(0,0,0,0.5);'><text y='50%'>" + String.fromCodePoint(eval('0x00003' + nextinorder),0x00fe0f,0x0020e3) + "</text></svg>\")";
itexto.style.backgroundRepeat='no-repeat';
itexto.style.backgroundPosition='center right';
itexto.setAttribute('data-order', '' + nextinorder);
nextinorder++;
} else if (ordersofar.indexOf(itexto.id) != -1) {
if (itexto.outerHTML.indexOf(' data-order="') != -1 && itexto.outerHTML.indexOf(' data-order="1"') == -1) {
neword=[itexto.id];
while (keep_going) {
keep_going=false;
for (jof=0; jof<ordersofar.length; jof++) {
if (ordersofar[jof] != neword[0] && !keep_going) {
if (('' + document.getElementById(ordersofar[jof]).getAttribute('data-order')) == ('' + lookfor)) {
neword.push(ordersofar[jof]);
document.getElementById(ordersofar[jof]).setAttribute('data-order', '' + nextass);
document.getElementById(ordersofar[jof]).style.backgroundImage="url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewport='0 0 100 100' style='font-family:Verdana;font-size:10px;color:rgba(0,0,0,0.5);'><text y='50%'>" + String.fromCodePoint(eval('0x00003' + nextass),0x00fe0f,0x0020e3) + "</text></svg>\")";
nextass++;
lookfor++;
if (('' + document.getElementById(neword[0]).getAttribute('data-order')) == ('' + lookfor)) {
lookfor++;
}
keep_going=true;
}
}
}
}
document.getElementById(neword[0]).style.backgroundImage="url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewport='0 0 100 100' style='font-family:Verdana;font-size:10px;color:rgba(0,0,0,0.5);'><text y='50%'>" + String.fromCodePoint(eval('0x00003' + 1),0x00fe0f,0x0020e3) + "</text></svg>\")";
document.getElementById(neword[0]).setAttribute('data-order', '1');
ordersofar=neword;
}
} else {
ordersofar.push(itexto.id);
itexto.style.backgroundImage="url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewport='0 0 100 100' style='font-family:Verdana;font-size:10px;color:rgba(0,0,0,0.5);'><text y='50%'>" + String.fromCodePoint(eval('0x00003' + nextinorder),0x00fe0f,0x0020e3) + "</text></svg>\")";
itexto.style.backgroundRepeat='no-repeat';
itexto.style.backgroundPosition='center right';
itexto.setAttribute('data-order', '' + nextinorder);
nextinorder++;
}
}
document.getElementById('mysub').focus();
}

… involving emoji Keycaps and what we’d call dual purposing, or being fancy about it all, “double valuing” (like we first started trying with Cowsay Cartoon User Styling Tutorial) for textbox ondblclick event (ie. double clicking a textbox) purposes where …

  1. double click when a “transform” textbox has no value yet makes the value be the same as it’s placeholder and assigns a relevant emoji Keycap number to show the order (so far) … else …
  2. double click when a “transform” textbox already has a value makes that textbox emoji Keycap be 1 (and shuffle any other textbox emoji Keycap numbers down the list) in order of transform applications (and you will find dealing with CSS transform property, order is relevant, and order can make a difference to the resultant display look)

… like with order, all about context. So, feel free to (re-)try our changed transform_ideas.html web application you can also try below.


Previous relevant CSS Transform Function Ideas Primer Tutorial is shown below.

CSS Transform Function Ideas Primer Tutorial

CSS Transform Function Ideas Primer Tutorial

One of the most impactive CSS properties would have to be the …


transform

… property, to do with how a webpage look can be affected. It got a look in, as a CSS property when we presented a web application trying out some of the CSS functions that might appear ( after a colon : in some CSS (with selector) such as …

<style>

img { transform: scale(0.333); }

</style>

… ) to the right of the property above with the recent CSS Function Ideas Finally Finalized Tutorial.

As such, allowing a user to learn more, we’re hoping, we’ve written a pretty simple web application to see some of it’s work, in action, with today’s proof of concept transform_ideas.html web application you can also try below …

Okay Boomer Did You Know?

Was playing the “very transformative” Piña Colada Song as one does, the other day, and it finally occurred to me. It being …

  1. The Piña Colada Song was released in 1979 and at one stage it says …

    [Verse 1]
    I was tired of my lady
    We’d been together too long
    Like a worn out recording
    Of a favorite song
    So while she lay there sleeping
    I read the paper in bed
    And in the personal columns
    There was this letter I read

    [Chorus]
    If you like piña coladas
    And gettin’ caught in the rain
    If you’re not into yoga
    If you have half a brain
    If you like making love at midnight
    In the dunes on the cape
    Then I’m the love that you’ve looked for
    Write to me and escape

    [Verse 2]
    I didn’t think about my lady
    I know that sounds kind of mean
    But me and my old lady
    Had fallen into the same old dull routine
    So I wrote to the paper
    Took out a personal ad
    And though I’m nobody’s poet
    I thought it wasn’t half bad

    [Chorus]
    Yes, I like piña coladas
    And gettin’ caught in the rain
    I’m not much into health food
    I am into champagne
    I’ve got to meet you by tomorrow noon
    And cut through all this red tape
    At a bar called O’Malley’s
    Where we’ll plan our escape

    [Verse 3]
    So I waited with high hopes
    And she walked in the place
    I knew her smile in an instant
    I knew the curve of her face
    It was my own lovely lady
    And she said, “Aw, it’s you”
    Then we laughed for a moment
    And I said, “I never knew”

    [Chorus]
    That you like piña coladas
    And gettin’ caught in the rain
    And the feel of the ocean
    And the taste of champagne
    If you like making love at midnight
    In the dunes on the cape
    You’re the lady I’ve looked for
    Come with me and escape

  2. … okay, now hold that thought, as we recall being a child of the 60’s ( the 1960’s that is ) and hearing all the time (especially in the context of me being the youngest of 5) addressed to me …

    If you had half a brain, it’d be lonely.

And so, my question to you … yes, you … is …

So what happened between, say, 1969 and 1979 that started to accept “half a brain” being acceptable?!

Hmmmmm?


Previous relevant CSS Function Ideas Finally Finalized Tutorial is shown below.

CSS Function Ideas Finalized Tutorial

CSS Function Ideas Finally Finalized Tutorial

Of course, with yesterday’s CSS Function Ideas Finalized Tutorial …

We weren’t actually finalized!

But I might have been?

Aren’t you supposed to be faithful and loyal and forgiving?

But, just humans aside here, regarding the “C” (ie. “cascading”) in CSS, there are …

  • hierarchy … and …
  • order

… considerations with the CSS that can improve the functionality here. Take the CSS filter (and apparently “innerHTML” would like to come along for the ride) property …

… yes … to the beach would be ideal … thanks. And would you be able to give The Lu the afternoon off?!

That filter property can be space separated with it’s CSS so as to support many “filter clauses” and depending on the order you define, it can cause a different display effect. Similar is the CSS transform property, and so, today, we cater a bit for that idea by offering up a new “Compound” checkbox a user can use to see some of this “hierarchical order” CSS consideration, in action.

Feel free to try this out with a finally completed until further noted day 3 “Nuance Day” of css_function_ideas.html CSS Function ideas web application you can try below.


Previous relevant CSS Function Ideas Finalized Tutorial is shown below.

CSS Function Ideas Finalized Tutorial

CSS Function Ideas Finalized Tutorial

We’ve gone from “n to “z” today, completing yesterday’s CSS Function Ideas Tutorial‘s “a” to “m” start creating an inhouse look at CSS Functions usage converted into a web application you can try yourself, and inspired by the great W3school’s CSS Functions webpage, thanks.

And what was your biggest surprise?

We found the potential of CSS function ray() …

Defines the offset-path line segment that an animated element should follow

… pretty interesting, and totally new to us.

Try this out with the completed day 2 of css_function_ideas.html CSS Function ideas web application you can try below.


Previous relevant CSS Function Ideas Tutorial is shown below.

CSS Function Ideas Tutorial

CSS Function Ideas Tutorial

Can you just move a bit to the right?

Now a tad sideways? That’s almost it. If you’d just, now, stand on your head. Okay, that’s it, thank you kindly?!

We’re just reacclimatizing ourselves here, having had our eyes fully opened, having stumbled onto W3school’s CSS Functions webpage, thanks. We’ve only tipped our toes into the variety of CSS (Javascript script like) capabilities that are out there. And yes, we covered “invert” so you can stand up again now … ta, muchly.

We’re showing Keyboard Based Cursor Image CSS Filter Tutorial below because CSS Functions cover a lot of image (ie. img element) CSS styling smarts, and we have touched on this, as well as good ol’ “calc”.

In today’s two day project start we’ve allowed users the chance to try CSS Functions from “a” to “m”. In today’s work …

  1. we started the first draft a bit non-generically … and then …
  2. straightened up … ready to …
  3. fly … right …

    Oh … you’re there! You can move back to square one … ta, muchly, like?!

… with day 1 of 2 “a” to “m” css_function_ideas.html CSS Function ideas web application you can try below …


Previous relevant Keyboard Based Cursor Image CSS Filter Tutorial is shown below.

Keyboard Based Cursor Image CSS Filter Tutorial

Keyboard Based Cursor Image CSS Filter Tutorial

What next for the Lorem Picsum (or RJM Programming WordPress Blog Posting tutorial pictures) resource usage web application regarding the recent Keyboard Based Cursor Image Blog Source Link Tutorial?

We’re a bit sheepish about how easy it was to feel like we are in some Photoshop studio applying CSS such as …

<style>

html { filter: drop-shadow(16px 16px 20px blue); }

</style>

… to change how ever many background images you have involved with the background images of your webpage using the changed body_mouse_deepdive.html‘s “parent” single background image web application (or, for example, “parent” eight background RJM Programming Blog Tutorial Picture image web application).

The user access all hangs off a first Shift key press followed by a numeric key (on QWERTY keyboard the “0123456789” correspond to “)!@#$%^&*(” characters) point at the first ten entries in …


var kcmap=["filter: blur(5px);","filter: brightness(0.4);","filter: contrast(200%);","filter: drop-shadow(16px 16px 20px blue);","filter: grayscale(50%);","filter: hue-rotate(90deg);","filter: invert(75%);","filter: opacity(25%);","filter: saturate(30%);","filter: sepia(60%);","filter: none;];"]; // thanks to https://developer.mozilla.org/en-US/docs/Web/CSS/filter

… used in amongst the “onkeypress” event Javascript function …


if (evt.keyCode >= 48 && evt.keyCode <= 57) { newu+=('' + eval(-48 + evt.keyCode)); if (lastshiftcursor) { kpdone=false; document.head.innerHTML+=' <style> html { ' + kcmap[eval(-48 + evt.keyCode)] + ' } </style>'; lastbit=document.title.split('Cursor change ')[1]; document.title='' + kcmap[eval(-48 + evt.keyCode)] + ' ... Cursor change ' + lastbit; return true; }
}

Stop Press

Thinking on arrangements above we figured it would give the user more control so that if they repeatedly pressed the same numerical key that would increment or decrement numerical components within the CSS filter specification requiring a changed call …


if (evt.keyCode >= 48 && evt.keyCode <= 57) { newu+=('' + eval(-48 + evt.keyCode)); if (lastshiftcursor) { kpdone=false; dcr=doublecheck(kcmap[eval(-48 + evt.keyCode)]); document.head.innerHTML+=' <style> html { ' + dcr + ' } </style>'; lastbit=document.title.split('Cursor change ')[1]; document.title='' + dcr + ' ... Cursor change ' + lastbit; return true;
}

… of the new Javascript …


function doublecheck(infid) {
var outfid=infid;
var within=infid.split('(')[1].split(')')[0];
var entries=within.split(',');
if (entries[0].replace(/^\ /g,'').indexOf(' ') != -1) { entries=within.replace(/\(\ /g,'(').split(' '); }
var withind='';
if (document.title.indexOf('(') != -1) { withind=document.title.split('(')[1].split(')')[0]; }
var entriesd=withind.split(',');
if (entriesd[0].replace(/^\ /g,'').indexOf(' ') != -1) { entriesd=withind.replace(/\(\ /g,'(').split(' '); }
var anum=0.0, bnum=0.0;
var isdeg=false;
if ((entriesd[0] + 'x').indexOf(' ') != -1) { isdeg=true; }


if (document.title.indexOf(infid.split('(')[0]) == 0) {
for (var ii=0; ii<entriesd.length; ii++) {
if (entriesd[ii].indexOf('%') != -1) {
anum=eval(entriesd[ii].trim().replace('%',''));
bnum=eval(entries[ii].trim().replace('%',''));
if (anum < 100 && !isdeg) {
outfid=outfid.replace('' + bnum + '%', '' + eval(1 + anum) + '%');
} else if (anum == 0) {
isdeg=false;
outfid=outfid.replace(/\(\ /g,'(');
outfid=outfid.replace('' + bnum + '%', '' + eval(1 + anum) + '%');
} else {
isdeg=true;
outfid=outfid.replace('' + bnum + '%', '' + eval(-1 + anum) + '%');
}
} else if (entriesd[ii].indexOf('px') != -1) {
console.log('entries[' + ii + ']=' + entriesd[ii] + ' within outfid=' + outfid)
anum=eval(entriesd[ii].trim().replace('px',''));
bnum=eval(entries[ii].trim().replace('px',''));
if (anum < 100 && !isdeg) {
outfid=outfid.replace('' + bnum + 'px', '' + eval(1 + anum) + 'px');
} else if (anum == 0) {
isdeg=false;
outfid=outfid.replace(/\(\ /g,'(');
outfid=outfid.replace('' + bnum + 'px', '' + eval(1 + anum) + 'px');
} else {
isdeg=true;
outfid=outfid.replace('' + bnum + 'px', '' + eval(-1 + anum) + 'px');
}
} else if (entriesd[ii].indexOf('deg') != -1) {
anum=eval(entriesd[ii].trim().replace('deg',''));
bnum=eval(entries[ii].trim().replace('deg',''));
if (anum < 90 && !isdeg) {
outfid=outfid.replace('' + bnum + 'deg', '' + eval(1 + anum) + 'deg');
} else if (anum == 0) {
isdeg=false;
outfid=outfid.replace(/\(\ /g,'(');
outfid=outfid.replace('' + bnum + 'deg', '' + eval(1 + anum) + 'deg');
} else {
isdeg=true;
outfid=outfid.replace('' + bnum + 'deg', '' + eval(-1 + anum) + 'deg');
}
} else if (entriesd[ii].indexOf('.') != -1) {
anum=eval(entriesd[ii].trim());
bnum=eval(entries[ii].trim());
if (anum < 1.0 && !isdeg) {
outfid=outfid.replace('' + bnum + '', '' + eval(0.1 + anum) + '');
} else if (anum == 0.0) {
isdeg=false;
outfid=outfid.replace(/\(\ /g,'(');
outfid=outfid.replace('' + bnum + '', '' + eval(0.1 + anum) + '');
} else {
isdeg=true;
outfid=outfid.replace('' + bnum + '', '' + eval(-0.1 + anum) + '');
}
}
}
if (isdeg) { outfid=outfid.replace(/\(\ /g,'(').replace('(', '( '); }
}
return outfid;
}


Previous relevant Keyboard Based Cursor Image Source Tutorial is shown below.

Keyboard Based Cursor Image Source Tutorial

Keyboard Based Cursor Image Source Tutorial

Another layer of functionality thinking on top of the work of yesterday’s Keyboard Based Cursor Multiple Background Images Tutorial …

  • multiple background image functionality … could be today’s …
  • image source choice to add to the generous Lorem Picsum image resource … thanks … that of a resource of the tutorial images amongst those of this RJM Programming WordPress Blog you are reading

… channelling the ever nuanced start we made in this regard when we presented Image Pair Fitting into a Given Dimension Sources Tutorial, with its interfacing to an increasing role for the WordPress codex TwentyTen theme 404.php role dealing with the HTTP error 404 well known as “Webpage Not Found”.

To make this happen, in code, we had to start breaking up (parameterizing, if you prefer) the hardcoding …

//picsum.photos

… into (variable) …


thesource

… and …

?random=

… into (variable usage) …


themp + '?random='

… reflected into code snippet example below …


var thesource=location.search.split('numbi=')[1] ? (decodeURIComponent(location.search.split('numbi=')[1].split('&')[0]).replace('+',' ').replace(' ',' ').replace('-',' ').substring(0,1) == ' ' ? '//www.rjmprogramming.com.au/ITblog' : '//picsu' + 'm.photos') : '//picsu' + 'm.photos';
var themp='';
if (thesource != '//picsu' + 'm.photos') {
themp='/';
}

if (numbi != '') {
if (eval('' + numbi) == 2) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top right; background-size: 50% 100%, 50% 100%; background-repeat: no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 3) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top center, top right; background-size: 33% 100%, 34% 100%, 33% 100%; background-repeat: no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 4) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top right, bottom left, bottom right; background-size: 50% 50%, 50% 50%, 50% 50%, 50% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 5) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 50147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top center, top right, bottom left, bottom right; background-size: 33% 50%, 34% 50%, 33% 50%, 50% 50%, 50% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 6) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 10143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 50147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top center, top right, bottom left, bottom center, bottom right; background-size: 33% 50%, 34% 50%, 33% 50%, 33% 50%, 34% 50%, 33% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 7) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 27143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 10143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 50147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top center, top right, center center, bottom left, bottom center, bottom right; background-size: 33% 50%, 34% 33%, 33% 50%, 34% 34%, 33% 50%, 34% 33%, 33% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 8) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 27143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 87123646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 10143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 50147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top center, top right, center left, center center, bottom left, bottom center, bottom right; background-size: 33% 33%, 34% 33%, 33% 50%, 33% 34%, 34% 34%, 33% 33%, 34% 33%, 33% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 9) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 27143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 67143446) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 87123646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 10143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 50147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top center, top right, center left, center center, center right, bottom left, bottom center, bottom right; background-size: 33% 33%, 34% 33%, 33% 33%, 33% 34%, 34% 34%, 33% 34%, 33% 33%, 34% 33%, 33% 33%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (thesource != '//picsu' + 'm.photos') {
document.head.innerHTML+='<style> ' + document.head.innerHTML.split('<style>')[1].split('</style>')[0].replace(/\/\/picsum\.photos/g, thesource).replace(/\?random\=/g, themp + '?random=').replace(/00\)/g, '00' + themp + '?random=' + Math.floor(Math.random() * 198765434) + ')') + ' </style>';
}
} else if (thesource != '//picsu' + 'm.photos') {
document.head.innerHTML+='<style> ' + document.head.innerHTML.split('<style>')[1].split('</style>')[0].replace(/\/\/picsum\.photos/g, thesource).replace(/\?random\=/g, themp + '?random=').replace(/00\)/g, '00' + themp + '?random=' + Math.floor(Math.random() * 198765434) + ')') + ' </style>';
}

… in our changed body_mouse_deepdive.html‘s “parent” single background image web application (or, for example, “parent” eight background RJM Programming Blog Tutorial Picture image web application) where a user can latch onto the new image source via a first key press is a + plus character …

Click and type and see the cursor change as you use Alt or Shift or Control that can be reset via Caps Lock with a click copying cursor into content … RJM Programming … May, 2022 … thanks to https://picsum.photos/ Lorem Picsum You can change emojis if you know the \002602 form of UTF-16 (hex) entry (our example is umbrella and if you express it as \\002602 that leaves cursor just as your emoji). Double click existant foreground emoji element to clear all the foreground emoji elements. With complex emoji entries do not zero leftpad until your last simple entity eg. \\1F6A3\200D\2640\00FE0F could define a Woman Rowing complex emoji. Optionally make emojis bigger after \ with + two time multipliers. Share with email or SMS happens via screenshots (macOS control-command-shift-3 or Windows Prnt-Scrn) followed by File menu Paste option causing chance to share after which File menu Undo can work. If first key is (+ is RJM image else) from 1 to 9 that will be number of background images displayed.


Previous relevant Keyboard Based Cursor Multiple Background Images Tutorial is shown below.

Keyboard Based Cursor Multiple Background Images Tutorial

Keyboard Based Cursor Multiple Background Images Tutorial

For the images, those background ones, used in the recent Canvas Graphics Editing in Zoomed Webpage Tutorial, we use the great Lorem Picsum resource. So far that has been the one background image covering the background of the webpage …


<style>

body {
display: inline-block;
font-size: 128px;
line-height: 1.2;
text-align: center;
background: url(//picsum.photos/1000/1000) center center no-repeat;
background-size: cover;
background-clip: text;
-webkit-background-clip: text;


color: rgba(255,0,0,0.6);

span { color: transparent; }
}

div {
background-color: transparent;
caret-color: transparent;
}

@media only screen and (max-width: 1000px) {
div {
background: url(//picsum.photos/1000/1000) center center no-repeat;
}
}

div:focus {
outline: none !important;
}

html {
height: 100%;
display: flex;
cursor: Url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='126' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(0,255,0,0.3);fill:black;font-family:Verdana;font-size:16px;'><text y='80%'>Shift/Alt/Ctrl\002753</text></svg>") 16 0, crosshair;
}

</style>

… nominally background-positioned “center center”. But there are 9 background-position of that similar ilk available …

  • top left
  • top center
  • top right
  • center left
  • center center
  • center right
  • bottom left
  • bottom center
  • bottom right

… which we’d like to, optionally, be involved with how a user uses our changed body_mouse_deepdive.html‘s “parent” single background image web application (or, for example, “parent” four background image web application).

So, how to make it be able to be controlled by those users? Well, those previous keyboard logics involving emojis always involved a leading “\” backslash, so that leaves open numbers from 1 to 9 entered as a first keyboard character entered meaning that that is how many background images is wanted by that user …

Click and type and see the cursor change as you use Alt or Shift or Control that can be reset via Caps Lock with a click copying cursor into content … RJM Programming … May, 2022 … thanks to https://picsum.photos/ Lorem Picsum You can change emojis if you know the \002602 form of UTF-16 (hex) entry (our example is umbrella and if you express it as \\002602 that leaves cursor just as your emoji). Double click existant foreground emoji element to clear all the foreground emoji elements. With complex emoji entries do not zero leftpad until your last simple entity eg. \\1F6A3\200D\2640\00FE0F could define a Woman Rowing complex emoji. Optionally make emojis bigger after \ with + two time multipliers. Share with email or SMS happens via screenshots (macOS control-command-shift-3 or Windows Prnt-Scrn) followed by File menu Paste option causing chance to share after which File menu Undo can remove pasted part as required. If first key is from 1 to 9 that will be number of background images displayed.

… supported by …


var numbi=location.search.split('numbi=')[1] ? reduce(decodeURIComponent(location.search.split('numbi=')[1].split('&')[0])) : '1';

if (numbi != '') {
if (eval('' + numbi) == 2) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top right; background-size: 50% 100%, 50% 100%; background-repeat: no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 3) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top center, top right; background-size: 33% 100%, 34% 100%, 33% 100%; background-repeat: no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 4) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=70143646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top right, bottom left, bottom right; background-size: 50% 50%, 50% 50%, 50% 50%, 50% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 5) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=70143646), url(//picsum.photos/1000/1000?random=50147646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top center, top right, bottom left, bottom right; background-size: 33% 50%, 34% 50%, 33% 50%, 50% 50%, 50% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 6) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=10143646), url(//picsum.photos/1000/1000?random=70143646), url(//picsum.photos/1000/1000?random=50147646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top center, top right, bottom left, bottom center, bottom right; background-size: 33% 50%, 34% 50%, 33% 50%, 33% 50%, 34% 50%, 33% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 7) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=27143646), url(//picsum.photos/1000/1000?random=10143646), url(//picsum.photos/1000/1000?random=70143646), url(//picsum.photos/1000/1000?random=50147646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top center, top right, center center, bottom left, bottom center, bottom right; background-size: 33% 50%, 34% 33%, 33% 50%, 34% 34%, 33% 50%, 34% 33%, 33% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 8) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=27143646), url(//picsum.photos/1000/1000?random=87123646), url(//picsum.photos/1000/1000?random=10143646), url(//picsum.photos/1000/1000?random=70143646), url(//picsum.photos/1000/1000?random=50147646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top center, top right, center left, center center, bottom left, bottom center, bottom right; background-size: 33% 33%, 34% 33%, 33% 50%, 33% 34%, 34% 34%, 33% 33%, 34% 33%, 33% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 9) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=27143646), url(//picsum.photos/1000/1000?random=67143446), url(//picsum.photos/1000/1000?random=87123646), url(//picsum.photos/1000/1000?random=10143646), url(//picsum.photos/1000/1000?random=70143646), url(//picsum.photos/1000/1000?random=50147646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top center, top right, center left, center center, center right, bottom left, bottom center, bottom right; background-size: 33% 33%, 34% 33%, 33% 33%, 33% 34%, 34% 34%, 33% 34%, 33% 33%, 34% 33%, 33% 33%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
}
}


function reduce(invl) {
if (('' + invl).trim() == '') { return '1'; }
if (('' + invl).trim().replace(/0/g,'').replace(/1/g,'').replace(/0/g,'').replace(/2/g,'').replace(/3/g,'').replace(/4/g,'').replace(/5/g,'').replace(/6/g,'').replace(/7/g,'').replace(/8/g,'').replace(/9/g,'') != '') { return '1'; }
var retval=0, ij=0;
var cinvl='' + invl;
var xcinvl='';
for (ij=0; ij<cinvl.length; ij++) {
if (cinvl.substring(ij).substring(0,1) != '-') {
retval+=eval(cinvl.substring(ij).substring(0,1));
}
}
xcinvl='' + retval;
while (xcinvl.length > 1) {
retval=0;
for (ij=0; ij<xcinvl.length; ij++) {
if (xcinvl.substring(ij).substring(0,1) != '-') {
retval+=eval(xcinvl.substring(ij).substring(0,1));
}
}
xcinvl='' + retval;
}
if (retval == 0) { retval=1; }
return '' + retval;
}


Previous relevant Keyboard Based Cursor Canvas Content Copy Tutorial is shown below.

Keyboard Based Cursor Canvas Content Copy Tutorial

Keyboard Based Cursor Canvas Content Copy Tutorial

You may have noticed with yesterday’s Keyboard Based Cursor Share Content Copy Tutorial, crucial to the sharing code, was the use of the incredible HTML5 introduced canvas element, helped by that middleperson link to those public email and SMS sharing conduits, overseeing the great random Lorem Picsum background images and user created emoji and/or text initial annotations.

And this got us wondering whether there was a private (ie. inhouse) web application of the past that could further value add as another optional middleperson tool for (user) personalization (of the content) purposes. And yes, do you remember the canvas work involved in the featured web application of Emoji Borders and Backgrounds Canvas Annotation Tutorial?

It uses an interesting approach with the transference of data across from a canvas in one application to the canvas in that user_of_signature_signature.htm web application. Once our changed body_mouse_deepdive.html‘s “parent” web application has organized its canvas contents, it’s just a matter of …


var awo=null;
awo=window.open('./user_of_signature_signature.htm','_blank','top=100,left=100,width=800,height=800');

… for the “child” canvas annotator to effectively “suck up” the canvas data into its canvas via …


var cancont='';
var elemode=location.search.split('elemode=')[1] ? (location.search.split('elemode=')[1].split('&')[0]) : "canvas";

if (('' + window.opener).replace('null','') != '') {
var cans=window.opener.document.getElementsByTagName(elemode);
if (cans.length > 0) {
if (elemode == 'img') {
cancont=cans[0].src;
} else {
cancont=cans[0].toDataURL('image/png');
}
if (cancontw < 0 && canconth < 0) { cancontw=cans[0].width; canconth=cans[0].height; } } }

... possible because both "parent" and "child" exist on the same RJM Programming domain (web server).

Once there, another woooooorrrrrlllddd of image manipulations, via canvas, can await the user, perhaps ready for ongoing sharing possibilities with that "child".


Previous relevant Keyboard Based Cursor Share Content Copy Tutorial is shown below.

Keyboard Based Cursor Share Content Copy Tutorial

Keyboard Based Cursor Share Content Copy Tutorial

Yesterday's Keyboard Based Cursor Personalized Content Copy Tutorial has probably reached a point where some sharing mechanism is apt, for accountability and usefulness purposes, at the very least, regarding our recent web application allowing for foreground content on top of a random Lorem Picsum background image.

We've been helped out greatly by javascript - Can I take a screenshot from the clipboard? - Stack Overflow and html - How to render a blob on a canvas element? - Stack Overflow in the following new relevant Javascript code ...


function renderNoImage(canvas, blob) { // thanks to https://stackoverflow.com/questions/38004917/how-to-render-a-blob-on-a-canvas-element
const ctx = canvas.getContext('2d');
const img = new Image();
img.onload = (event) => {
URL.revokeObjectURL(event.target.src) // This is important. If you are not using the blob, you should release it if you don't want to reuse it. It's good for memory.
ctx.drawImage(event.target, 0, 0)
img.style.display='none';
img.style.zIndex='-123';
};
img.src = URL.createObjectURL(blob);
}


function renderImage(canvas, blob) { // thanks to https://stackoverflow.com/questions/38004917/how-to-render-a-blob-on-a-canvas-element
const ctx = canvas.getContext('2d');
const img = new Image();
img.onload = (event) => {
URL.revokeObjectURL(event.target.src) // This is important. If you are not using the blob, you should release it if you don't want to reuse it. It's good for memory.
ctx.drawImage(event.target, 0, 0)
};
img.src = URL.createObjectURL(blob);
}


addEventListener("paste", ev => { // thanks to https://stackoverflow.com/questions/55559432/can-i-take-a-screenshot-from-the-clipboard
for(const item of ev.clipboardData.items) { /// Clipboard may contain multiple elements of different type -- text, image, etc
if(item.type.startsWith("image/")) { /// We are only interested in clipboard data that is an image
if (emailee == '') {
emailee=prompt('Your clipboard has a useful image you could share the image with. Optionally, please enter an email address or SMS number to share with.');
if (emailee == null) { emailee=''; }
}
if (emailee.indexOf('@') != -1) {
document.getElementById('mydiv').style.overflow='scroll';
document.getElementById('mycanvas').innerHTML='<br><canvas style="position:absolute;z-index:98;top:0px;left:0px;" id=thecanvas width=' + screen.width + ' height=' + screen.height + '></canvas>';
elem=document.getElementById('thecanvas');
context=elem.getContext('2d');
renderImage(elem, item.getAsFile()); //context.drawImage(item.getAsFile(), 0, 0);
document.getElementById('aemail').href=document.getElementById('aemail').href.replace(':?', ':' + emailee + '?');
document.getElementById('aemail').click();
document.getElementById('mycanvas').innerHTML='';
} else if (emailee != '' && emailee.replace(/0/g,'').replace(/1/g,'').replace(/2/g,'').replace(/3/g,'').replace(/4/g,'').replace(/5/g,'').replace(/6/g,'').replace(/7/g,'').replace(/8/g,'').replace(/9/g,'') == '') {
document.getElementById('mydiv').style.overflow='scroll';
document.getElementById('mycanvas').innerHTML='<br><canvas style="position:absolute;z-index:98;top:0px;left:0px;" id=thecanvas width=' + screen.width + ' height=' + screen.height + '></canvas>';
elem=document.getElementById('thecanvas');
context=elem.getContext('2d');
renderImage(elem, item.getAsFile()); //context.drawImage(item.getAsFile(), 0, 0);
document.getElementById('asms').href=document.getElementById('asms').href.replace(':&', ':' + emailee + '&');
document.getElementById('asms').click();
document.getElementById('mycanvas').innerHTML='';
} else {
//document.getElementById('mydiv').style.overflow='scroll';
document.getElementById('mycanvas').innerHTML='<br><canvas style="display:none;position:absolute;z-index:-98;top:0px;left:0px;" id=thecanvas width=' + screen.width + ' height=' + screen.height + '></canvas>';
elem=document.getElementById('thecanvas');
context=elem.getContext('2d');
renderNoImage(elem, item.getAsFile()); //context.drawImage(item.getAsFile(), 0, 0);
document.getElementById('mycanvas').innerHTML='';
}
}
}
});

... which is explained to the user in the following way ...

Share with email or SMS happens via screenshots (macOS control-command-shift-3 or Windows Prnt-Scrn) followed by File menu Paste option causing chance to share after which File menu Undo can remove pasted part as required.

... in the changed "proof of concept" body_mouse_deepdive.html live run.


Previous relevant Keyboard Based Cursor Personalized Content Copy Tutorial is shown below.

Keyboard Based Cursor Personalized Content Copy Tutorial

Keyboard Based Cursor Personalized Content Copy Tutorial

On top of yesterday's Keyboard Based Cursor Content Copy Tutorial we wanted to offer the user the chance for them to tailor their foreground content on top of the Lorem Picsum background image.

The user can enter this via the keyboard because there is an HTML div contenteditable=true pallette to work with ...


<div id=mydiv onfocus='setTimeout(alte, 1000);' ondblclick="this.innerHTML='';" onclick='stamp(event);' title='Click and type and see the cursor change as you use Alt or Shift or Control that can be reset via Caps Lock with a click copying cursor into content ... RJM Programming ... May, 2022 ... thanks to https://picsum.photos/ Lorem Picsum You can change emojis if you know the \002602 form of UTF-16 (hex) entry (our example is umbrella and if you express it as \\002602 that leaves cursor just as your emoji). Double click existant foreground emoji element to clear all the foreground emoji elements.' spellcheck='false' contenteditable=true style='width:100vw;height:100%;color:transparent;text-color:transparent;' onkeypress=kpcursorlook(event); onkeydown=cursorlook(event); onmousemove=xycursorlook(event); ontouchmove=xycursorlook(event);></div>

It's "title" attribute now talks about two new pieces of functionality, those being ...

  • You can change emojis if you know the \002602 form of UTF-16 (hex) entry (our example is umbrella and if you express it as \\002602 that leaves cursor just as your emoji).
  • Double click existant foreground emoji element to clear all the foreground emoji elements.

The choice of keyboard input methodology also suits CSS "content" property definitions as one backslash followed by a hexidecimal value left padded with zeroes to a length of six. See us doing this below for an umbrella emoji (which could also be expressed in an HTML hexadecimal entity way &#x2602; ☂ the information for which you can find at Unicode Character 'UMBRELLA' (U+2602) we normally get to by entering "U+2602" at a web browser address bar, the knowledge for which we arrive at via entering "umbrella emojipedia" and moving down the top link's webpage to find the "U+2602") ...


<style> #myumbrella::after { content: '\002602'; } </style>

... that feeds into some new "onkeypress" keyboard event logic ...


function kpcursorlook(evt) {
var atofa=['a','b','c','d','e','f'];
var rgbit='';
if (evt.keyCode == 92) {
if (newu.length == 1) { gro=true; } else { gro=false; }
newu=("\\").substring(0,1);
} else if (evt.keyCode >= 48 && evt.keyCode <= 57) {
newu+=('' + eval(-48 + evt.keyCode));
} else if (evt.keyCode >= 65 && evt.keyCode <= 70) {
newu+=('' + atofa[eval(-65 + evt.keyCode)]);
} else if (evt.keyCode >= 97 && evt.keyCode <= 102) {
newu+=('' + atofa[eval(-97 + evt.keyCode)]);
}
if (newu.length == 7) {
if (lastcursor.indexOf(("\\\\").substring(0,2)) != -1) {
rgbit=lastcursor.split(("\\\\").substring(0,2))[1].substring(6);
lastcursor=lastcursor.split(("\\\\").substring(0,2))[0] + ("\\").substring(0,1) + newu + rgbit;
document.head.innerHTML+='<style> html { cursor: ' + lastcursor + '; } </style>';
} else if (lastcursor.indexOf(("\\").substring(0,1)) != -1) {
rgbit=lastcursor.split(("\\").substring(0,1))[1].substring(6);
lastcursor=lastcursor.split(("\\").substring(0,1))[0] + newu + rgbit;
if (gro) {
lastcursor=lastcursor.replace('>Shift/Alt/Ctrl', '>').replace('>Shift', '>').replace('>Alt', '>').replace('>Ctrl', '>').replace(" width='126'", " width='20'").replace(" width='66'", " width='20'").replace(" height='48'", " height='20'").replace('0 0 100 100', '0 0 20 20');
}
document.head.innerHTML+='<style> html { cursor: ' + lastcursor + '; } </style>';
}
}
// console.log(evt.keyCode);
}

... in the changed "proof of concept" body_mouse_deepdive.html live run.

Stop Press

Two more "title" attribute pieces of functionality are now ...

  • With complex emoji entries do not zero leftpad until your last simple entity eg. \\1F6A3\200D\2640\00FE0F could define a Woman Rowing complex emoji.
  • Optionally make emojis bigger after \ with + two time multipliers.

The choice of keyboard input methodology also suits CSS "content" property definitions as one backslash followed by "first off" sets of HTML entities they should not left zero pad in their entry, followed by a last HTML entity hexidecimal value left padded with zeroes to a length of six to finish up with. See us doing this below for a woman rowing emoji (which could also be expressed in an HTML hexadecimal entity way &#x1f6a3;&#x0200d;&#x02640;&#x0fe0f; the information for which you can find at 🚣‍♀️ Woman Rowing Boat Emoji we normally get to by entering "woman rowing emoji" at the web browser address bar) ...


<style> #myrowing::after { content: '\01f6a3\00200d\002640\00fe0f'; } </style>

... in the changed "proof of concept" body_mouse_deepdive.html live run.


Previous relevant Keyboard Based Cursor Content Copy Tutorial is shown below.

Keyboard Based Cursor Content Copy Tutorial

Keyboard Based Cursor Content Copy Tutorial

The "onkeydown" keyboard event can involve in its logic three mouse event (event object) property usages that caught our interest recently ...

... and we wanted to have "keyboard" meets "mouse" events, along with the brilliance of Lorem Picsum regarding background image randomosity and quality, working with HTML ...


<div id=mydiv onfocus='setTimeout(alte, 1000);' onclick='stamp(this);' title='Click and type and see the cursor change as you use Alt or Shift or Control that can be reset via Caps Lock with a click copying cursor into content ... RJM Programming ... May, 2022 ... thanks to https://picsum.photos/ Lorem Picsum' spellcheck='false' contenteditable=true style='width:100vw;height:100%;color:transparent;text-color:transparent;' data-onkeypress=xycursorlook(event); onkeydown=cursorlook(event); onmousemove=xycursorlook(event); ontouchmove=xycursorlook(event);></div>

... in a way we hadn't tried before that called on some inhouse cursor SVG creations (and so is, alas, just a non-mobile fully featured experience), in the sense that ...

  1. keyboard helps creating the "what" regarding content ...

    <script type='text/javascript'>
    var lastkeymodifier=''
    var lastcursor="Url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='126' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(0,255,0,0.3);fill:black;font-family:Verdana;font-size:16px;'><text y='80%'>Shift/Alt/Ctrl\\002753</text></svg>\") 16 0, crosshair";
    var pos3=-1, pos4=-1;
    var subdiv=1;
    var lastpos3=-2, lastpos4=-1;
    var allowable=false;

    function cursorlook(evt) {
    if (evt.altKey) {
    if (lastkeymodifier != 'alt') {
    lastcursor="Url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='66' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(0,0,255,0.3);fill:black;font-family:Verdana;font-size:17px;'><text y='80%'>Alt\\01f3d5</text></svg>\") 16 0, progress";
    document.head.innerHTML+='<style> html { cursor: ' + lastcursor + '; } </style>';
    lastkeymodifier='alt';
    }
    } else if (evt.ctrlKey) {
    if (lastkeymodifier != 'ctrl') {
    lastcursor="Url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='66' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(0,255,0,0.3);fill:black;font-family:Verdana;font-size:17px;'><text y='80%'>Ctrl\\01f333</text></svg>\") 16 0, pointer";
    document.head.innerHTML+='<style> html { cursor: ' + lastcursor + '; } </style>';
    lastkeymodifier='ctrl';
    }
    } else if (evt.shiftKey) {
    if (lastkeymodifier != 'shift') {
    lastcursor="Url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='66' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(255,0,0,0.3);fill:black;font-family:Verdana;font-size:17px;'><text y='80%'>Shift\\01f389</text></svg>\") 16 0, grab";
    document.head.innerHTML+='<style> html { cursor: ' + lastcursor + '; } </style>';
    lastkeymodifier='shift';
    }
    } else {
    if (lastkeymodifier != '') {
    lastcursor="Url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='126' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(0,255,0,0.3);fill:black;font-family:Verdana;font-size:16px;'><text y='80%'>Shift/Alt/Ctrl\\002753</text></svg>\") 16 0, crosshair";
    document.head.innerHTML+='<style> html { cursor: ' + lastcursor + '; } </style>';
    lastkeymodifier='';
    }
    }
    }
    </script>
  2. mouse "onmousemove" or "ontouchmove" helps with the "where" regarding content above ...

    <script type='text/javascript'>
    var pos3=-1, pos4=-1;
    var subdiv=1;
    var lastpos3=-2, lastpos4=-1;
    var allowable=false;

    function xycursorlook(e) {
    e = e || window.event;
    e.preventDefault();

    if (e.touches) {
    if (e.touches[0].pageX) {
    pos3 = e.touches[0].pageX;
    pos4 = e.touches[0].pageY;
    } else {
    pos3 = e.touches[0].clientX;
    pos4 = e.touches[0].clientY;
    }
    //console.log('pos3=' + pos3 + ',pos4=' + pos4);
    } else if (e.clientX || e.clientY) {
    pos3 = e.clientX;
    pos4 = e.clientY;
    } else {
    pos3 = e.pageX;
    pos4 = e.pageY;
    }
    }
    </script>
  3. preparations for "onclick" way a cursor can be plonked into (real lasting) content ...

    <script type='text/javascript'>
    var lastcursor="Url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='126' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(0,255,0,0.3);fill:black;font-family:Verdana;font-size:16px;'><text y='80%'>Shift/Alt/Ctrl\\002753</text></svg>\") 16 0, crosshair";
    var pos3=-1, pos4=-1;
    var subdiv=1;
    var lastpos3=-2, lastpos4=-1;
    var allowable=false;

    function stamp(divo) {
    if (('' + pos3).indexOf('-') == -1) {
    if (allowable) {
    //if (allowed) {
    //allowed=false;
    //setTimeout(reseta, 2000);
    divo.innerHTML+='<div id=div' + subdiv + ' style="position:absolute;top:' + pos4 + 'px;left:' + pos3 + 'px;width:126px;height:48px;background-color:transparent;"></div><style> #div' + subdiv + ' { background:' + lastcursor.split(') ')[0] + ') no-repeat; } </style>';
    subdiv++;
    //console.log('lastpos4=' + lastpos4 + ' and pos4=' + pos4);
    //console.log('lastpos3=' + lastpos3 + ' and pos3=' + pos3);
    lastpos3=pos3;
    lastpos4=pos4;
    //}
    }
    }
    }
    </script>

... with the "proof of concept" body_mouse_deepdive.html live run.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

CSS Transform Function Ideas Primer Tutorial

CSS Transform Function Ideas Primer Tutorial

CSS Transform Function Ideas Primer Tutorial

One of the most impactive CSS properties would have to be the …


transform

… property, to do with how a webpage look can be affected. It got a look in, as a CSS property when we presented a web application trying out some of the CSS functions that might appear ( after a colon : in some CSS (with selector) such as …

<style>

img { transform: scale(0.333); }

</style>

… ) to the right of the property above with the recent CSS Function Ideas Finally Finalized Tutorial.

As such, allowing a user to learn more, we’re hoping, we’ve written a pretty simple web application to see some of it’s work, in action, with today’s proof of concept transform_ideas.html web application you can also try below …

Okay Boomer Did You Know?

Was playing the “very transformative” Piña Colada Song as one does, the other day, and it finally occurred to me. It being …

  1. The Piña Colada Song was released in 1979 and at one stage it says …

    [Verse 1]
    I was tired of my lady
    We’d been together too long
    Like a worn out recording
    Of a favorite song
    So while she lay there sleeping
    I read the paper in bed
    And in the personal columns
    There was this letter I read

    [Chorus]
    If you like piña coladas
    And gettin’ caught in the rain
    If you’re not into yoga
    If you have half a brain
    If you like making love at midnight
    In the dunes on the cape
    Then I’m the love that you’ve looked for
    Write to me and escape

    [Verse 2]
    I didn’t think about my lady
    I know that sounds kind of mean
    But me and my old lady
    Had fallen into the same old dull routine
    So I wrote to the paper
    Took out a personal ad
    And though I’m nobody’s poet
    I thought it wasn’t half bad

    [Chorus]
    Yes, I like piña coladas
    And gettin’ caught in the rain
    I’m not much into health food
    I am into champagne
    I’ve got to meet you by tomorrow noon
    And cut through all this red tape
    At a bar called O’Malley’s
    Where we’ll plan our escape

    [Verse 3]
    So I waited with high hopes
    And she walked in the place
    I knew her smile in an instant
    I knew the curve of her face
    It was my own lovely lady
    And she said, “Aw, it’s you”
    Then we laughed for a moment
    And I said, “I never knew”

    [Chorus]
    That you like piña coladas
    And gettin’ caught in the rain
    And the feel of the ocean
    And the taste of champagne
    If you like making love at midnight
    In the dunes on the cape
    You’re the lady I’ve looked for
    Come with me and escape

  2. … okay, now hold that thought, as we recall being a child of the 60’s ( the 1960’s that is ) and hearing all the time (especially in the context of me being the youngest of 5) addressed to me …

    If you had half a brain, it’d be lonely.

And so, my question to you … yes, you … is …

So what happened between, say, 1969 and 1979 that started to accept “half a brain” being acceptable?!

Hmmmmm?


Previous relevant CSS Function Ideas Finally Finalized Tutorial is shown below.

CSS Function Ideas Finalized Tutorial

CSS Function Ideas Finally Finalized Tutorial

Of course, with yesterday’s CSS Function Ideas Finalized Tutorial …

We weren’t actually finalized!

But I might have been?

Aren’t you supposed to be faithful and loyal and forgiving?

But, just humans aside here, regarding the “C” (ie. “cascading”) in CSS, there are …

  • hierarchy … and …
  • order

… considerations with the CSS that can improve the functionality here. Take the CSS filter (and apparently “innerHTML” would like to come along for the ride) property …

… yes … to the beach would be ideal … thanks. And would you be able to give The Lu the afternoon off?!

That filter property can be space separated with it’s CSS so as to support many “filter clauses” and depending on the order you define, it can cause a different display effect. Similar is the CSS transform property, and so, today, we cater a bit for that idea by offering up a new “Compound” checkbox a user can use to see some of this “hierarchical order” CSS consideration, in action.

Feel free to try this out with a finally completed until further noted day 3 “Nuance Day” of css_function_ideas.html CSS Function ideas web application you can try below.


Previous relevant CSS Function Ideas Finalized Tutorial is shown below.

CSS Function Ideas Finalized Tutorial

CSS Function Ideas Finalized Tutorial

We’ve gone from “n to “z” today, completing yesterday’s CSS Function Ideas Tutorial‘s “a” to “m” start creating an inhouse look at CSS Functions usage converted into a web application you can try yourself, and inspired by the great W3school’s CSS Functions webpage, thanks.

And what was your biggest surprise?

We found the potential of CSS function ray() …

Defines the offset-path line segment that an animated element should follow

… pretty interesting, and totally new to us.

Try this out with the completed day 2 of css_function_ideas.html CSS Function ideas web application you can try below.


Previous relevant CSS Function Ideas Tutorial is shown below.

CSS Function Ideas Tutorial

CSS Function Ideas Tutorial

Can you just move a bit to the right?

Now a tad sideways? That’s almost it. If you’d just, now, stand on your head. Okay, that’s it, thank you kindly?!

We’re just reacclimatizing ourselves here, having had our eyes fully opened, having stumbled onto W3school’s CSS Functions webpage, thanks. We’ve only tipped our toes into the variety of CSS (Javascript script like) capabilities that are out there. And yes, we covered “invert” so you can stand up again now … ta, muchly.

We’re showing Keyboard Based Cursor Image CSS Filter Tutorial below because CSS Functions cover a lot of image (ie. img element) CSS styling smarts, and we have touched on this, as well as good ol’ “calc”.

In today’s two day project start we’ve allowed users the chance to try CSS Functions from “a” to “m”. In today’s work …

  1. we started the first draft a bit non-generically … and then …
  2. straightened up … ready to …
  3. fly … right …

    Oh … you’re there! You can move back to square one … ta, muchly, like?!

… with day 1 of 2 “a” to “m” css_function_ideas.html CSS Function ideas web application you can try below …


Previous relevant Keyboard Based Cursor Image CSS Filter Tutorial is shown below.

Keyboard Based Cursor Image CSS Filter Tutorial

Keyboard Based Cursor Image CSS Filter Tutorial

What next for the Lorem Picsum (or RJM Programming WordPress Blog Posting tutorial pictures) resource usage web application regarding the recent Keyboard Based Cursor Image Blog Source Link Tutorial?

We’re a bit sheepish about how easy it was to feel like we are in some Photoshop studio applying CSS such as …

<style>

html { filter: drop-shadow(16px 16px 20px blue); }

</style>

… to change how ever many background images you have involved with the background images of your webpage using the changed body_mouse_deepdive.html‘s “parent” single background image web application (or, for example, “parent” eight background RJM Programming Blog Tutorial Picture image web application).

The user access all hangs off a first Shift key press followed by a numeric key (on QWERTY keyboard the “0123456789” correspond to “)!@#$%^&*(” characters) point at the first ten entries in …


var kcmap=["filter: blur(5px);","filter: brightness(0.4);","filter: contrast(200%);","filter: drop-shadow(16px 16px 20px blue);","filter: grayscale(50%);","filter: hue-rotate(90deg);","filter: invert(75%);","filter: opacity(25%);","filter: saturate(30%);","filter: sepia(60%);","filter: none;];"]; // thanks to https://developer.mozilla.org/en-US/docs/Web/CSS/filter

… used in amongst the “onkeypress” event Javascript function …


if (evt.keyCode >= 48 && evt.keyCode <= 57) { newu+=('' + eval(-48 + evt.keyCode)); if (lastshiftcursor) { kpdone=false; document.head.innerHTML+=' <style> html { ' + kcmap[eval(-48 + evt.keyCode)] + ' } </style>'; lastbit=document.title.split('Cursor change ')[1]; document.title='' + kcmap[eval(-48 + evt.keyCode)] + ' ... Cursor change ' + lastbit; return true; }
}

Stop Press

Thinking on arrangements above we figured it would give the user more control so that if they repeatedly pressed the same numerical key that would increment or decrement numerical components within the CSS filter specification requiring a changed call …


if (evt.keyCode >= 48 && evt.keyCode <= 57) { newu+=('' + eval(-48 + evt.keyCode)); if (lastshiftcursor) { kpdone=false; dcr=doublecheck(kcmap[eval(-48 + evt.keyCode)]); document.head.innerHTML+=' <style> html { ' + dcr + ' } </style>'; lastbit=document.title.split('Cursor change ')[1]; document.title='' + dcr + ' ... Cursor change ' + lastbit; return true;
}

… of the new Javascript …


function doublecheck(infid) {
var outfid=infid;
var within=infid.split('(')[1].split(')')[0];
var entries=within.split(',');
if (entries[0].replace(/^\ /g,'').indexOf(' ') != -1) { entries=within.replace(/\(\ /g,'(').split(' '); }
var withind='';
if (document.title.indexOf('(') != -1) { withind=document.title.split('(')[1].split(')')[0]; }
var entriesd=withind.split(',');
if (entriesd[0].replace(/^\ /g,'').indexOf(' ') != -1) { entriesd=withind.replace(/\(\ /g,'(').split(' '); }
var anum=0.0, bnum=0.0;
var isdeg=false;
if ((entriesd[0] + 'x').indexOf(' ') != -1) { isdeg=true; }


if (document.title.indexOf(infid.split('(')[0]) == 0) {
for (var ii=0; ii<entriesd.length; ii++) {
if (entriesd[ii].indexOf('%') != -1) {
anum=eval(entriesd[ii].trim().replace('%',''));
bnum=eval(entries[ii].trim().replace('%',''));
if (anum < 100 && !isdeg) {
outfid=outfid.replace('' + bnum + '%', '' + eval(1 + anum) + '%');
} else if (anum == 0) {
isdeg=false;
outfid=outfid.replace(/\(\ /g,'(');
outfid=outfid.replace('' + bnum + '%', '' + eval(1 + anum) + '%');
} else {
isdeg=true;
outfid=outfid.replace('' + bnum + '%', '' + eval(-1 + anum) + '%');
}
} else if (entriesd[ii].indexOf('px') != -1) {
console.log('entries[' + ii + ']=' + entriesd[ii] + ' within outfid=' + outfid)
anum=eval(entriesd[ii].trim().replace('px',''));
bnum=eval(entries[ii].trim().replace('px',''));
if (anum < 100 && !isdeg) {
outfid=outfid.replace('' + bnum + 'px', '' + eval(1 + anum) + 'px');
} else if (anum == 0) {
isdeg=false;
outfid=outfid.replace(/\(\ /g,'(');
outfid=outfid.replace('' + bnum + 'px', '' + eval(1 + anum) + 'px');
} else {
isdeg=true;
outfid=outfid.replace('' + bnum + 'px', '' + eval(-1 + anum) + 'px');
}
} else if (entriesd[ii].indexOf('deg') != -1) {
anum=eval(entriesd[ii].trim().replace('deg',''));
bnum=eval(entries[ii].trim().replace('deg',''));
if (anum < 90 && !isdeg) {
outfid=outfid.replace('' + bnum + 'deg', '' + eval(1 + anum) + 'deg');
} else if (anum == 0) {
isdeg=false;
outfid=outfid.replace(/\(\ /g,'(');
outfid=outfid.replace('' + bnum + 'deg', '' + eval(1 + anum) + 'deg');
} else {
isdeg=true;
outfid=outfid.replace('' + bnum + 'deg', '' + eval(-1 + anum) + 'deg');
}
} else if (entriesd[ii].indexOf('.') != -1) {
anum=eval(entriesd[ii].trim());
bnum=eval(entries[ii].trim());
if (anum < 1.0 && !isdeg) {
outfid=outfid.replace('' + bnum + '', '' + eval(0.1 + anum) + '');
} else if (anum == 0.0) {
isdeg=false;
outfid=outfid.replace(/\(\ /g,'(');
outfid=outfid.replace('' + bnum + '', '' + eval(0.1 + anum) + '');
} else {
isdeg=true;
outfid=outfid.replace('' + bnum + '', '' + eval(-0.1 + anum) + '');
}
}
}
if (isdeg) { outfid=outfid.replace(/\(\ /g,'(').replace('(', '( '); }
}
return outfid;
}


Previous relevant Keyboard Based Cursor Image Source Tutorial is shown below.

Keyboard Based Cursor Image Source Tutorial

Keyboard Based Cursor Image Source Tutorial

Another layer of functionality thinking on top of the work of yesterday’s Keyboard Based Cursor Multiple Background Images Tutorial …

  • multiple background image functionality … could be today’s …
  • image source choice to add to the generous Lorem Picsum image resource … thanks … that of a resource of the tutorial images amongst those of this RJM Programming WordPress Blog you are reading

… channelling the ever nuanced start we made in this regard when we presented Image Pair Fitting into a Given Dimension Sources Tutorial, with its interfacing to an increasing role for the WordPress codex TwentyTen theme 404.php role dealing with the HTTP error 404 well known as “Webpage Not Found”.

To make this happen, in code, we had to start breaking up (parameterizing, if you prefer) the hardcoding …

//picsum.photos

… into (variable) …


thesource

… and …

?random=

… into (variable usage) …


themp + '?random='

… reflected into code snippet example below …


var thesource=location.search.split('numbi=')[1] ? (decodeURIComponent(location.search.split('numbi=')[1].split('&')[0]).replace('+',' ').replace(' ',' ').replace('-',' ').substring(0,1) == ' ' ? '//www.rjmprogramming.com.au/ITblog' : '//picsu' + 'm.photos') : '//picsu' + 'm.photos';
var themp='';
if (thesource != '//picsu' + 'm.photos') {
themp='/';
}

if (numbi != '') {
if (eval('' + numbi) == 2) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top right; background-size: 50% 100%, 50% 100%; background-repeat: no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 3) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top center, top right; background-size: 33% 100%, 34% 100%, 33% 100%; background-repeat: no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 4) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top right, bottom left, bottom right; background-size: 50% 50%, 50% 50%, 50% 50%, 50% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 5) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 50147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top center, top right, bottom left, bottom right; background-size: 33% 50%, 34% 50%, 33% 50%, 50% 50%, 50% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 6) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 10143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 50147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top center, top right, bottom left, bottom center, bottom right; background-size: 33% 50%, 34% 50%, 33% 50%, 33% 50%, 34% 50%, 33% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 7) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 27143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 10143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 50147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top center, top right, center center, bottom left, bottom center, bottom right; background-size: 33% 50%, 34% 33%, 33% 50%, 34% 34%, 33% 50%, 34% 33%, 33% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 8) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 27143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 87123646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 10143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 50147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top center, top right, center left, center center, bottom left, bottom center, bottom right; background-size: 33% 33%, 34% 33%, 33% 50%, 33% 34%, 34% 34%, 33% 33%, 34% 33%, 33% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 9) {
document.head.innerHTML+='<style> #mydiv, body { background: url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76547646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 27143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 67143446) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 87123646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 10143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70143646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 50147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 70147646) + '), url(' + thesource + '/1000/1000' + themp + '?random=0' + Math.floor(Math.random() * 76147646) + '); background-position: top left, top center, top right, center left, center center, center right, bottom left, bottom center, bottom right; background-size: 33% 33%, 34% 33%, 33% 33%, 33% 34%, 34% 34%, 33% 34%, 33% 33%, 34% 33%, 33% 33%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (thesource != '//picsu' + 'm.photos') {
document.head.innerHTML+='<style> ' + document.head.innerHTML.split('<style>')[1].split('</style>')[0].replace(/\/\/picsum\.photos/g, thesource).replace(/\?random\=/g, themp + '?random=').replace(/00\)/g, '00' + themp + '?random=' + Math.floor(Math.random() * 198765434) + ')') + ' </style>';
}
} else if (thesource != '//picsu' + 'm.photos') {
document.head.innerHTML+='<style> ' + document.head.innerHTML.split('<style>')[1].split('</style>')[0].replace(/\/\/picsum\.photos/g, thesource).replace(/\?random\=/g, themp + '?random=').replace(/00\)/g, '00' + themp + '?random=' + Math.floor(Math.random() * 198765434) + ')') + ' </style>';
}

… in our changed body_mouse_deepdive.html‘s “parent” single background image web application (or, for example, “parent” eight background RJM Programming Blog Tutorial Picture image web application) where a user can latch onto the new image source via a first key press is a + plus character …

Click and type and see the cursor change as you use Alt or Shift or Control that can be reset via Caps Lock with a click copying cursor into content … RJM Programming … May, 2022 … thanks to https://picsum.photos/ Lorem Picsum You can change emojis if you know the \002602 form of UTF-16 (hex) entry (our example is umbrella and if you express it as \\002602 that leaves cursor just as your emoji). Double click existant foreground emoji element to clear all the foreground emoji elements. With complex emoji entries do not zero leftpad until your last simple entity eg. \\1F6A3\200D\2640\00FE0F could define a Woman Rowing complex emoji. Optionally make emojis bigger after \ with + two time multipliers. Share with email or SMS happens via screenshots (macOS control-command-shift-3 or Windows Prnt-Scrn) followed by File menu Paste option causing chance to share after which File menu Undo can work. If first key is (+ is RJM image else) from 1 to 9 that will be number of background images displayed.


Previous relevant Keyboard Based Cursor Multiple Background Images Tutorial is shown below.

Keyboard Based Cursor Multiple Background Images Tutorial

Keyboard Based Cursor Multiple Background Images Tutorial

For the images, those background ones, used in the recent Canvas Graphics Editing in Zoomed Webpage Tutorial, we use the great Lorem Picsum resource. So far that has been the one background image covering the background of the webpage …


<style>

body {
display: inline-block;
font-size: 128px;
line-height: 1.2;
text-align: center;
background: url(//picsum.photos/1000/1000) center center no-repeat;
background-size: cover;
background-clip: text;
-webkit-background-clip: text;


color: rgba(255,0,0,0.6);

span { color: transparent; }
}

div {
background-color: transparent;
caret-color: transparent;
}

@media only screen and (max-width: 1000px) {
div {
background: url(//picsum.photos/1000/1000) center center no-repeat;
}
}

div:focus {
outline: none !important;
}

html {
height: 100%;
display: flex;
cursor: Url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='126' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(0,255,0,0.3);fill:black;font-family:Verdana;font-size:16px;'><text y='80%'>Shift/Alt/Ctrl\002753</text></svg>") 16 0, crosshair;
}

</style>

… nominally background-positioned “center center”. But there are 9 background-position of that similar ilk available …

  • top left
  • top center
  • top right
  • center left
  • center center
  • center right
  • bottom left
  • bottom center
  • bottom right

… which we’d like to, optionally, be involved with how a user uses our changed body_mouse_deepdive.html‘s “parent” single background image web application (or, for example, “parent” four background image web application).

So, how to make it be able to be controlled by those users? Well, those previous keyboard logics involving emojis always involved a leading “\” backslash, so that leaves open numbers from 1 to 9 entered as a first keyboard character entered meaning that that is how many background images is wanted by that user …

Click and type and see the cursor change as you use Alt or Shift or Control that can be reset via Caps Lock with a click copying cursor into content … RJM Programming … May, 2022 … thanks to https://picsum.photos/ Lorem Picsum You can change emojis if you know the \002602 form of UTF-16 (hex) entry (our example is umbrella and if you express it as \\002602 that leaves cursor just as your emoji). Double click existant foreground emoji element to clear all the foreground emoji elements. With complex emoji entries do not zero leftpad until your last simple entity eg. \\1F6A3\200D\2640\00FE0F could define a Woman Rowing complex emoji. Optionally make emojis bigger after \ with + two time multipliers. Share with email or SMS happens via screenshots (macOS control-command-shift-3 or Windows Prnt-Scrn) followed by File menu Paste option causing chance to share after which File menu Undo can remove pasted part as required. If first key is from 1 to 9 that will be number of background images displayed.

… supported by …


var numbi=location.search.split('numbi=')[1] ? reduce(decodeURIComponent(location.search.split('numbi=')[1].split('&')[0])) : '1';

if (numbi != '') {
if (eval('' + numbi) == 2) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top right; background-size: 50% 100%, 50% 100%; background-repeat: no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 3) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top center, top right; background-size: 33% 100%, 34% 100%, 33% 100%; background-repeat: no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 4) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=70143646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top right, bottom left, bottom right; background-size: 50% 50%, 50% 50%, 50% 50%, 50% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 5) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=70143646), url(//picsum.photos/1000/1000?random=50147646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top center, top right, bottom left, bottom right; background-size: 33% 50%, 34% 50%, 33% 50%, 50% 50%, 50% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 6) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=10143646), url(//picsum.photos/1000/1000?random=70143646), url(//picsum.photos/1000/1000?random=50147646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top center, top right, bottom left, bottom center, bottom right; background-size: 33% 50%, 34% 50%, 33% 50%, 33% 50%, 34% 50%, 33% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 7) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=27143646), url(//picsum.photos/1000/1000?random=10143646), url(//picsum.photos/1000/1000?random=70143646), url(//picsum.photos/1000/1000?random=50147646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top center, top right, center center, bottom left, bottom center, bottom right; background-size: 33% 50%, 34% 33%, 33% 50%, 34% 34%, 33% 50%, 34% 33%, 33% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 8) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=27143646), url(//picsum.photos/1000/1000?random=87123646), url(//picsum.photos/1000/1000?random=10143646), url(//picsum.photos/1000/1000?random=70143646), url(//picsum.photos/1000/1000?random=50147646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top center, top right, center left, center center, bottom left, bottom center, bottom right; background-size: 33% 33%, 34% 33%, 33% 50%, 33% 34%, 34% 34%, 33% 33%, 34% 33%, 33% 50%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
} else if (eval('' + numbi) == 9) {
document.head.innerHTML+='<style> body { background: url(//picsum.photos/1000/1000?random=76547646), url(//picsum.photos/1000/1000?random=27143646), url(//picsum.photos/1000/1000?random=67143446), url(//picsum.photos/1000/1000?random=87123646), url(//picsum.photos/1000/1000?random=10143646), url(//picsum.photos/1000/1000?random=70143646), url(//picsum.photos/1000/1000?random=50147646), url(//picsum.photos/1000/1000?random=70147646), url(//picsum.photos/1000/1000?random=76147646); background-position: top left, top center, top right, center left, center center, center right, bottom left, bottom center, bottom right; background-size: 33% 33%, 34% 33%, 33% 33%, 33% 34%, 34% 34%, 33% 34%, 33% 33%, 34% 33%, 33% 33%; background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat; } </style>';
}
}


function reduce(invl) {
if (('' + invl).trim() == '') { return '1'; }
if (('' + invl).trim().replace(/0/g,'').replace(/1/g,'').replace(/0/g,'').replace(/2/g,'').replace(/3/g,'').replace(/4/g,'').replace(/5/g,'').replace(/6/g,'').replace(/7/g,'').replace(/8/g,'').replace(/9/g,'') != '') { return '1'; }
var retval=0, ij=0;
var cinvl='' + invl;
var xcinvl='';
for (ij=0; ij<cinvl.length; ij++) {
if (cinvl.substring(ij).substring(0,1) != '-') {
retval+=eval(cinvl.substring(ij).substring(0,1));
}
}
xcinvl='' + retval;
while (xcinvl.length > 1) {
retval=0;
for (ij=0; ij<xcinvl.length; ij++) {
if (xcinvl.substring(ij).substring(0,1) != '-') {
retval+=eval(xcinvl.substring(ij).substring(0,1));
}
}
xcinvl='' + retval;
}
if (retval == 0) { retval=1; }
return '' + retval;
}


Previous relevant Keyboard Based Cursor Canvas Content Copy Tutorial is shown below.

Keyboard Based Cursor Canvas Content Copy Tutorial

Keyboard Based Cursor Canvas Content Copy Tutorial

You may have noticed with yesterday’s Keyboard Based Cursor Share Content Copy Tutorial, crucial to the sharing code, was the use of the incredible HTML5 introduced canvas element, helped by that middleperson link to those public email and SMS sharing conduits, overseeing the great random Lorem Picsum background images and user created emoji and/or text initial annotations.

And this got us wondering whether there was a private (ie. inhouse) web application of the past that could further value add as another optional middleperson tool for (user) personalization (of the content) purposes. And yes, do you remember the canvas work involved in the featured web application of Emoji Borders and Backgrounds Canvas Annotation Tutorial?

It uses an interesting approach with the transference of data across from a canvas in one application to the canvas in that user_of_signature_signature.htm web application. Once our changed body_mouse_deepdive.html‘s “parent” web application has organized its canvas contents, it’s just a matter of …


var awo=null;
awo=window.open('./user_of_signature_signature.htm','_blank','top=100,left=100,width=800,height=800');

… for the “child” canvas annotator to effectively “suck up” the canvas data into its canvas via …


var cancont='';
var elemode=location.search.split('elemode=')[1] ? (location.search.split('elemode=')[1].split('&')[0]) : "canvas";

if (('' + window.opener).replace('null','') != '') {
var cans=window.opener.document.getElementsByTagName(elemode);
if (cans.length > 0) {
if (elemode == 'img') {
cancont=cans[0].src;
} else {
cancont=cans[0].toDataURL('image/png');
}
if (cancontw < 0 && canconth < 0) { cancontw=cans[0].width; canconth=cans[0].height; } } }

... possible because both "parent" and "child" exist on the same RJM Programming domain (web server).

Once there, another woooooorrrrrlllddd of image manipulations, via canvas, can await the user, perhaps ready for ongoing sharing possibilities with that "child".


Previous relevant Keyboard Based Cursor Share Content Copy Tutorial is shown below.

Keyboard Based Cursor Share Content Copy Tutorial

Keyboard Based Cursor Share Content Copy Tutorial

Yesterday's Keyboard Based Cursor Personalized Content Copy Tutorial has probably reached a point where some sharing mechanism is apt, for accountability and usefulness purposes, at the very least, regarding our recent web application allowing for foreground content on top of a random Lorem Picsum background image.

We've been helped out greatly by javascript - Can I take a screenshot from the clipboard? - Stack Overflow and html - How to render a blob on a canvas element? - Stack Overflow in the following new relevant Javascript code ...


function renderNoImage(canvas, blob) { // thanks to https://stackoverflow.com/questions/38004917/how-to-render-a-blob-on-a-canvas-element
const ctx = canvas.getContext('2d');
const img = new Image();
img.onload = (event) => {
URL.revokeObjectURL(event.target.src) // This is important. If you are not using the blob, you should release it if you don't want to reuse it. It's good for memory.
ctx.drawImage(event.target, 0, 0)
img.style.display='none';
img.style.zIndex='-123';
};
img.src = URL.createObjectURL(blob);
}


function renderImage(canvas, blob) { // thanks to https://stackoverflow.com/questions/38004917/how-to-render-a-blob-on-a-canvas-element
const ctx = canvas.getContext('2d');
const img = new Image();
img.onload = (event) => {
URL.revokeObjectURL(event.target.src) // This is important. If you are not using the blob, you should release it if you don't want to reuse it. It's good for memory.
ctx.drawImage(event.target, 0, 0)
};
img.src = URL.createObjectURL(blob);
}


addEventListener("paste", ev => { // thanks to https://stackoverflow.com/questions/55559432/can-i-take-a-screenshot-from-the-clipboard
for(const item of ev.clipboardData.items) { /// Clipboard may contain multiple elements of different type -- text, image, etc
if(item.type.startsWith("image/")) { /// We are only interested in clipboard data that is an image
if (emailee == '') {
emailee=prompt('Your clipboard has a useful image you could share the image with. Optionally, please enter an email address or SMS number to share with.');
if (emailee == null) { emailee=''; }
}
if (emailee.indexOf('@') != -1) {
document.getElementById('mydiv').style.overflow='scroll';
document.getElementById('mycanvas').innerHTML='<br><canvas style="position:absolute;z-index:98;top:0px;left:0px;" id=thecanvas width=' + screen.width + ' height=' + screen.height + '></canvas>';
elem=document.getElementById('thecanvas');
context=elem.getContext('2d');
renderImage(elem, item.getAsFile()); //context.drawImage(item.getAsFile(), 0, 0);
document.getElementById('aemail').href=document.getElementById('aemail').href.replace(':?', ':' + emailee + '?');
document.getElementById('aemail').click();
document.getElementById('mycanvas').innerHTML='';
} else if (emailee != '' && emailee.replace(/0/g,'').replace(/1/g,'').replace(/2/g,'').replace(/3/g,'').replace(/4/g,'').replace(/5/g,'').replace(/6/g,'').replace(/7/g,'').replace(/8/g,'').replace(/9/g,'') == '') {
document.getElementById('mydiv').style.overflow='scroll';
document.getElementById('mycanvas').innerHTML='<br><canvas style="position:absolute;z-index:98;top:0px;left:0px;" id=thecanvas width=' + screen.width + ' height=' + screen.height + '></canvas>';
elem=document.getElementById('thecanvas');
context=elem.getContext('2d');
renderImage(elem, item.getAsFile()); //context.drawImage(item.getAsFile(), 0, 0);
document.getElementById('asms').href=document.getElementById('asms').href.replace(':&', ':' + emailee + '&');
document.getElementById('asms').click();
document.getElementById('mycanvas').innerHTML='';
} else {
//document.getElementById('mydiv').style.overflow='scroll';
document.getElementById('mycanvas').innerHTML='<br><canvas style="display:none;position:absolute;z-index:-98;top:0px;left:0px;" id=thecanvas width=' + screen.width + ' height=' + screen.height + '></canvas>';
elem=document.getElementById('thecanvas');
context=elem.getContext('2d');
renderNoImage(elem, item.getAsFile()); //context.drawImage(item.getAsFile(), 0, 0);
document.getElementById('mycanvas').innerHTML='';
}
}
}
});

... which is explained to the user in the following way ...

Share with email or SMS happens via screenshots (macOS control-command-shift-3 or Windows Prnt-Scrn) followed by File menu Paste option causing chance to share after which File menu Undo can remove pasted part as required.

... in the changed "proof of concept" body_mouse_deepdive.html live run.


Previous relevant Keyboard Based Cursor Personalized Content Copy Tutorial is shown below.

Keyboard Based Cursor Personalized Content Copy Tutorial

Keyboard Based Cursor Personalized Content Copy Tutorial

On top of yesterday's Keyboard Based Cursor Content Copy Tutorial we wanted to offer the user the chance for them to tailor their foreground content on top of the Lorem Picsum background image.

The user can enter this via the keyboard because there is an HTML div contenteditable=true pallette to work with ...


<div id=mydiv onfocus='setTimeout(alte, 1000);' ondblclick="this.innerHTML='';" onclick='stamp(event);' title='Click and type and see the cursor change as you use Alt or Shift or Control that can be reset via Caps Lock with a click copying cursor into content ... RJM Programming ... May, 2022 ... thanks to https://picsum.photos/ Lorem Picsum You can change emojis if you know the \002602 form of UTF-16 (hex) entry (our example is umbrella and if you express it as \\002602 that leaves cursor just as your emoji). Double click existant foreground emoji element to clear all the foreground emoji elements.' spellcheck='false' contenteditable=true style='width:100vw;height:100%;color:transparent;text-color:transparent;' onkeypress=kpcursorlook(event); onkeydown=cursorlook(event); onmousemove=xycursorlook(event); ontouchmove=xycursorlook(event);></div>

It's "title" attribute now talks about two new pieces of functionality, those being ...

  • You can change emojis if you know the \002602 form of UTF-16 (hex) entry (our example is umbrella and if you express it as \\002602 that leaves cursor just as your emoji).
  • Double click existant foreground emoji element to clear all the foreground emoji elements.

The choice of keyboard input methodology also suits CSS "content" property definitions as one backslash followed by a hexidecimal value left padded with zeroes to a length of six. See us doing this below for an umbrella emoji (which could also be expressed in an HTML hexadecimal entity way &#x2602; ☂ the information for which you can find at Unicode Character 'UMBRELLA' (U+2602) we normally get to by entering "U+2602" at a web browser address bar, the knowledge for which we arrive at via entering "umbrella emojipedia" and moving down the top link's webpage to find the "U+2602") ...


<style> #myumbrella::after { content: '\002602'; } </style>

... that feeds into some new "onkeypress" keyboard event logic ...


function kpcursorlook(evt) {
var atofa=['a','b','c','d','e','f'];
var rgbit='';
if (evt.keyCode == 92) {
if (newu.length == 1) { gro=true; } else { gro=false; }
newu=("\\").substring(0,1);
} else if (evt.keyCode >= 48 && evt.keyCode <= 57) {
newu+=('' + eval(-48 + evt.keyCode));
} else if (evt.keyCode >= 65 && evt.keyCode <= 70) {
newu+=('' + atofa[eval(-65 + evt.keyCode)]);
} else if (evt.keyCode >= 97 && evt.keyCode <= 102) {
newu+=('' + atofa[eval(-97 + evt.keyCode)]);
}
if (newu.length == 7) {
if (lastcursor.indexOf(("\\\\").substring(0,2)) != -1) {
rgbit=lastcursor.split(("\\\\").substring(0,2))[1].substring(6);
lastcursor=lastcursor.split(("\\\\").substring(0,2))[0] + ("\\").substring(0,1) + newu + rgbit;
document.head.innerHTML+='<style> html { cursor: ' + lastcursor + '; } </style>';
} else if (lastcursor.indexOf(("\\").substring(0,1)) != -1) {
rgbit=lastcursor.split(("\\").substring(0,1))[1].substring(6);
lastcursor=lastcursor.split(("\\").substring(0,1))[0] + newu + rgbit;
if (gro) {
lastcursor=lastcursor.replace('>Shift/Alt/Ctrl', '>').replace('>Shift', '>').replace('>Alt', '>').replace('>Ctrl', '>').replace(" width='126'", " width='20'").replace(" width='66'", " width='20'").replace(" height='48'", " height='20'").replace('0 0 100 100', '0 0 20 20');
}
document.head.innerHTML+='<style> html { cursor: ' + lastcursor + '; } </style>';
}
}
// console.log(evt.keyCode);
}

... in the changed "proof of concept" body_mouse_deepdive.html live run.

Stop Press

Two more "title" attribute pieces of functionality are now ...

  • With complex emoji entries do not zero leftpad until your last simple entity eg. \\1F6A3\200D\2640\00FE0F could define a Woman Rowing complex emoji.
  • Optionally make emojis bigger after \ with + two time multipliers.

The choice of keyboard input methodology also suits CSS "content" property definitions as one backslash followed by "first off" sets of HTML entities they should not left zero pad in their entry, followed by a last HTML entity hexidecimal value left padded with zeroes to a length of six to finish up with. See us doing this below for a woman rowing emoji (which could also be expressed in an HTML hexadecimal entity way &#x1f6a3;&#x0200d;&#x02640;&#x0fe0f; the information for which you can find at 🚣‍♀️ Woman Rowing Boat Emoji we normally get to by entering "woman rowing emoji" at the web browser address bar) ...


<style> #myrowing::after { content: '\01f6a3\00200d\002640\00fe0f'; } </style>

... in the changed "proof of concept" body_mouse_deepdive.html live run.


Previous relevant Keyboard Based Cursor Content Copy Tutorial is shown below.

Keyboard Based Cursor Content Copy Tutorial

Keyboard Based Cursor Content Copy Tutorial

The "onkeydown" keyboard event can involve in its logic three mouse event (event object) property usages that caught our interest recently ...

... and we wanted to have "keyboard" meets "mouse" events, along with the brilliance of Lorem Picsum regarding background image randomosity and quality, working with HTML ...


<div id=mydiv onfocus='setTimeout(alte, 1000);' onclick='stamp(this);' title='Click and type and see the cursor change as you use Alt or Shift or Control that can be reset via Caps Lock with a click copying cursor into content ... RJM Programming ... May, 2022 ... thanks to https://picsum.photos/ Lorem Picsum' spellcheck='false' contenteditable=true style='width:100vw;height:100%;color:transparent;text-color:transparent;' data-onkeypress=xycursorlook(event); onkeydown=cursorlook(event); onmousemove=xycursorlook(event); ontouchmove=xycursorlook(event);></div>

... in a way we hadn't tried before that called on some inhouse cursor SVG creations (and so is, alas, just a non-mobile fully featured experience), in the sense that ...

  1. keyboard helps creating the "what" regarding content ...

    <script type='text/javascript'>
    var lastkeymodifier=''
    var lastcursor="Url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='126' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(0,255,0,0.3);fill:black;font-family:Verdana;font-size:16px;'><text y='80%'>Shift/Alt/Ctrl\\002753</text></svg>\") 16 0, crosshair";
    var pos3=-1, pos4=-1;
    var subdiv=1;
    var lastpos3=-2, lastpos4=-1;
    var allowable=false;

    function cursorlook(evt) {
    if (evt.altKey) {
    if (lastkeymodifier != 'alt') {
    lastcursor="Url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='66' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(0,0,255,0.3);fill:black;font-family:Verdana;font-size:17px;'><text y='80%'>Alt\\01f3d5</text></svg>\") 16 0, progress";
    document.head.innerHTML+='<style> html { cursor: ' + lastcursor + '; } </style>';
    lastkeymodifier='alt';
    }
    } else if (evt.ctrlKey) {
    if (lastkeymodifier != 'ctrl') {
    lastcursor="Url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='66' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(0,255,0,0.3);fill:black;font-family:Verdana;font-size:17px;'><text y='80%'>Ctrl\\01f333</text></svg>\") 16 0, pointer";
    document.head.innerHTML+='<style> html { cursor: ' + lastcursor + '; } </style>';
    lastkeymodifier='ctrl';
    }
    } else if (evt.shiftKey) {
    if (lastkeymodifier != 'shift') {
    lastcursor="Url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='66' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(255,0,0,0.3);fill:black;font-family:Verdana;font-size:17px;'><text y='80%'>Shift\\01f389</text></svg>\") 16 0, grab";
    document.head.innerHTML+='<style> html { cursor: ' + lastcursor + '; } </style>';
    lastkeymodifier='shift';
    }
    } else {
    if (lastkeymodifier != '') {
    lastcursor="Url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='126' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(0,255,0,0.3);fill:black;font-family:Verdana;font-size:16px;'><text y='80%'>Shift/Alt/Ctrl\\002753</text></svg>\") 16 0, crosshair";
    document.head.innerHTML+='<style> html { cursor: ' + lastcursor + '; } </style>';
    lastkeymodifier='';
    }
    }
    }
    </script>
  2. mouse "onmousemove" or "ontouchmove" helps with the "where" regarding content above ...

    <script type='text/javascript'>
    var pos3=-1, pos4=-1;
    var subdiv=1;
    var lastpos3=-2, lastpos4=-1;
    var allowable=false;

    function xycursorlook(e) {
    e = e || window.event;
    e.preventDefault();

    if (e.touches) {
    if (e.touches[0].pageX) {
    pos3 = e.touches[0].pageX;
    pos4 = e.touches[0].pageY;
    } else {
    pos3 = e.touches[0].clientX;
    pos4 = e.touches[0].clientY;
    }
    //console.log('pos3=' + pos3 + ',pos4=' + pos4);
    } else if (e.clientX || e.clientY) {
    pos3 = e.clientX;
    pos4 = e.clientY;
    } else {
    pos3 = e.pageX;
    pos4 = e.pageY;
    }
    }
    </script>
  3. preparations for "onclick" way a cursor can be plonked into (real lasting) content ...

    <script type='text/javascript'>
    var lastcursor="Url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='126' height='48' viewport='0 0 100 100' style='border-radius:15px;background-color:rgba(0,255,0,0.3);fill:black;font-family:Verdana;font-size:16px;'><text y='80%'>Shift/Alt/Ctrl\\002753</text></svg>\") 16 0, crosshair";
    var pos3=-1, pos4=-1;
    var subdiv=1;
    var lastpos3=-2, lastpos4=-1;
    var allowable=false;

    function stamp(divo) {
    if (('' + pos3).indexOf('-') == -1) {
    if (allowable) {
    //if (allowed) {
    //allowed=false;
    //setTimeout(reseta, 2000);
    divo.innerHTML+='<div id=div' + subdiv + ' style="position:absolute;top:' + pos4 + 'px;left:' + pos3 + 'px;width:126px;height:48px;background-color:transparent;"></div><style> #div' + subdiv + ' { background:' + lastcursor.split(') ')[0] + ') no-repeat; } </style>';
    subdiv++;
    //console.log('lastpos4=' + lastpos4 + ' and pos4=' + pos4);
    //console.log('lastpos3=' + lastpos3 + ' and pos3=' + pos3);
    lastpos3=pos3;
    lastpos4=pos4;
    //}
    }
    }
    }
    </script>

... with the "proof of concept" body_mouse_deepdive.html live run.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Animated GIF Slides via Landing Page Scrolling and Scaling Tutorial

Animated GIF Slides via Landing Page Scrolling and Scaling Tutorial

Animated GIF Slides via Landing Page Scrolling and Scaling Tutorial

Onto yesterday’s Animated GIF Slides via Landing Page Browsing and Pasting Tutorial it’s little surprise that functionality we finalized revolved around …

  • scrolling …
    <?php echo ”

    var curtd=1;

    function viacurtd() {
    var tonum=eval('' + document.getElementById('goright').title.split('to slide ')[1].split(' ')[0]);
    var fromnum=eval('' + document.getElementById('goright').title.split('from slide ')[1].split(' ')[0]);
    var ofnum=eval('' + document.getElementById('goright').title.split(' of ')[1]);
    if (document.getElementById('td' + eval(1 + curtd))) {
    document.getElementById('td' + eval(1 + curtd)).scrollIntoView();
    curtd=eval(1 + curtd);
    if (eval(1 + tonum) > ofnum) {
    document.getElementById('goright').title=document.getElementById('goright').title.replace('to slide ' + tonum + ' from slide ' + fromnum, 'to slide 1 from slide ' + eval(1 + fromnum));
    } else {
    document.getElementById('goright').title=document.getElementById('goright').title.replace('to slide ' + tonum + ' from slide ' + fromnum, 'to slide ' + eval(1 + tonum) + ' from slide ' + eval(1 + fromnum));
    }
    } else {
    document.getElementById('goright').title=document.getElementById('goright').title.replace('to slide ' + tonum + ' from slide ' + fromnum, 'to slide 2 from slide 1')
    if (1 == 1) {
    window.scrollTo(0,0);
    curtd=1;
    } else {
    document.getElementById('td1').scrollIntoView();
    curtd=1;
    }
    }
    }

    “; ?>
  • scaling …
    <?php echo ”

    var door=false, curzoom=1.0;

    function zoomin() {
    var rtab=null;
    rtab=document.getElementById('tableslideshow').getBoundingClientRect();
    if (door) {
    door=false;
    document.getElementById('tableslideshow').style.transformOrigin='top left'; //'' + eval(rtab.left + eval(rtab.width / 2)) + ' ' + eval(rtab.top + eval(rtab.height / 2));
    }
    curzoom*=2.0;
    document.getElementById('tableslideshow').style.transform='scale(' + curzoom + ')';
    }

    function zoomout() {
    var rtab=null;
    rtab=document.getElementById('tableslideshow').getBoundingClientRect();
    if (door) {
    door=false;
    document.getElementById('tableslideshow').style.transformOrigin='top left'; //'' + eval(rtab.left + eval(rtab.width / 2)) + ' ' + eval(rtab.top + eval(rtab.height / 2));
    }
    curzoom/=2.0;
    document.getElementById('tableslideshow').style.transform='scale(' + curzoom + ')';
    }

    “; ?>
    … as well as …
  • uniquifying filenames including an IP address reference part …
    <?php

    function server_remote_addr() {
    global $stfle, $precow;
    $rma = $_SERVER['REMOTE_ADDR'];
    $ua = strtolower((isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''));
    // you can add different browsers with the same way ..
    if(preg_match('/(chromium)[ \/]([\w.]+)/', $ua))
    $rma = '000000'.$rma;
    elseif(preg_match('/(chrome)[ \/]([\w.]+)/', $ua))
    $rma = '00000'.$rma;
    elseif(preg_match('/(safari)[ \/]([\w.]+)/', $ua))
    $rma = '0000'.$rma;
    elseif(preg_match('/(opera)[ \/]([\w.]+)/', $ua))
    $rma = '000'.$rma;
    elseif(preg_match('/(msie)[ \/]([\w.]+)/', $ua))
    $rma = '00'.$rma;
    elseif(preg_match('/(mozilla)[ \/]([\w.]+)/', $ua))
    $rma = '0'.$rma;
    return str_replace(":", "_", $rma);
    }

    $fullprefix=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'diffident_' . server_remote_addr() . '_';
    $lesserprefix='/tmp/' . 'diffident_' . server_remote_addr() . '_';

    ?>
    … so fewer users will clobber other user’s work

… and because allowing scrolling is involved the HTML span elements added for this are arranged with position:fixed properties …

<?php

$atwopenend="\n document.getElementById('datend').innerHTML+='<span style=\"position:fixed;top:0px;left:0px;z-index:1345;opacity:0.5;cursor:e-resize;\" title=\"Scroll to right\" onclick=viacurtd(); id=goright>&#x27A1;&#xFE0F;</span><span style=\"position:fixed;top:0px;left:50px;z-index:1345;opacity:0.5;cursor:sw-resize;\" title=\"Zoom out\" onclick=zoomout(); id=zoomout>&#x2796;</span><span style=\"position:fixed;top:0px;left:100px;z-index:1345;opacity:0.5;cursor:ne-resize;\" title=\"Zoom in\" onclick=zoomin(); id=zoomin>&#x2795;</span>'; \n if (document.getElementById('goright')) { document.getElementById('goright').title+=' ... to slide 1 from slide 1 of 0'; } \n";

?>

… so that they remain in the user’s vision in the top left corner of the screen overlayed with some transparency applied in the changed animated_gif_slides.php‘s live run.


Previous relevant Animated GIF Slides via Landing Page Browsing and Pasting Tutorial is shown below.

Animated GIF Slides via Landing Page Browsing and Pasting Tutorial

Animated GIF Slides via Landing Page Browsing and Pasting Tutorial

Two additional means of user input onto yesterday’s Animated GIF Slides via Landing Page Dropdown Tutorial‘s …

  • textbox image URL keyboard entry or dropdown select entry means … are, as of today …
    1. a new local image file browsing button click/tap to reach a browsing scenario … and …
    2. a new image copy buffer pasting scenario in span elements to the right of the browsing button

    … via PHP writes HTML like …
    <?php

    $ifstuff='  <span id=spagspan><iframe class="spag" scrolling="no" onload="checkit(this);" id="cbi" frameborder="0" style="width:173px;height:218px;margin-top:-194px;" src="/HTMLCSS/client_browsing.htm?d=312160562686&wording=Allimages%20images%2E%20"></iframe></span>';

    ?>

… where, today, we allow for image data that is not animated GIF …


function laterisgif() {
if (document.getElementById('selname').value.indexOf('.gif') != -1) {
prefetch(document.getElementById('selname').value);
} else if (document.getElementById('selname').value.trim() != '') {
document.body.style.backgroundRepeat='no-repeat';
document.body.style.backgroundSize='contain';
document.body.style.background='linear-gradient(rgba(255,255,255,0.6),rgba(255,255,255,0.6)),url(' + document.getElementById('selname').value + ')';
if (document.getElementById('selname').placeholder != '' && document.getElementById('selname').placeholder == lastduri) {
document.getElementById('selname').value='';
lastduri='';
} else {
document.getElementById('selname').placeholder=document.getElementById('selname').value;
}
document.getElementById('selname').value='';
}
}

function prefetch(whatgifmaybe) { // thanks to https://stackoverflow.com/questions/69564118/how-to-get-duration-of-gif-image-in-javascript#:~:text=Mainly%20use%20parseGIF()%20%2C%20then,duration%20of%20a%20GIF%20image.
if ((whatgifmaybe.toLowerCase().trim().split('#')[0] + '?').indexOf('.gif?') != -1 || whatgifmaybe.indexOf('data:image/gif') != -1 || whatgifmaybe.indexOf('gif;base64,') == 0) {
ingif=whatgifmaybe;
//document.body.style.cursor='progress';
fetch(whatgifmaybe)
.then(res => res.arrayBuffer())
.then(ab => isGifAnimated(new Uint8Array(ab)))
.then(console.log);
}
}

function isGifAnimated(uint8) { // thanks to https://stackoverflow.com/questions/69564118/how-to-get-duration-of-gif-image-in-javascript#:~:text=Mainly%20use%20parseGIF()%20%2C%20then,duration%20of%20a%20GIF%20image.
let duration = 0;
for (let i = 0, len = uint8.length; i < len; i++) {
if (uint8[i] == 0x21
&& uint8[i + 1] == 0xF9
&& uint8[i + 2] == 0x04
&& uint8[i + 7] == 0x00)
{
const delay = (uint8[i + 5] << 8) | (uint8[i + 4] & 0xFF);
duration += delay < 2 ? 10 : delay;
}
}
if (eval(duration / 100) < 0.11) {
document.body.style.backgroundRepeat='no-repeat';
document.body.style.backgroundSize='contain';
document.body.style.background='linear-gradient(rgba(255,255,255,0.6),rgba(255,255,255,0.6)),url(' + document.getElementById('selname').value + ')';
if (document.getElementById('selname').placeholder != '' && document.getElementById('selname').placeholder == lastduri) {
document.getElementById('selname').value='';
lastduri='';
} else {
document.getElementById('selname').placeholder=document.getElementById('selname').value;
}
document.getElementById('selname').value='';
//alert('POST');
document.getElementById('myform').method='POST';
} else if (gresis != '') {
//alert('GET');
document.getElementById('myform').method='POST'; //'GET';
document.getElementById('myform').action=document.getElementById('myform').action.split('.php')[0] + '.php#75586#' + encodeURIComponent(document.getElementById('selname').value + '#' + document.getElementById('selname').title);
//} else {
// alert('why');
}
//alert('' + eval(duration / 100));
return duration / 100; // if 0.1 is not an animated GIF
}

… be recognized as a document.body background image. As well as that, the textbox can accept data URI entries.

Try this out with the changed animated_gif_slides.php‘s live run.


Previous relevant Animated GIF Slides via Landing Page Dropdown Tutorial is shown below.

Animated GIF Slides via Landing Page Dropdown Tutorial

Animated GIF Slides via Landing Page Dropdown Tutorial

Some of the reason we are so keen on blog animated GIF forms of presentation at this blog you can read about with Animated GIF versus PDF Presentation Considerations Tutorial.

But, on occasions, when you see a slide of interest zip past you when looking at an animated GIF presentation image at this blog, do you ever want to see the slides presented that went to make up that animated GIF, perhaps presented in a single horizontal row of still image slides you can scroll among, from left to right, in order?

Sorry, that’s rhetorical. Anyway, revisiting the PHP (exec calling ImageMagick) web application of Animated GIF Slides via ImageMagick Primer Tutorial we’ve found scope for including new …

  1. dropdown suggestions for animated GIFs (as a tutorial picture for a blog posting here at this blog) to try, as gleaned from the dropdown among the Landing Page suite of webpages, and now so much easier since the work of Crontab and Curl Rearrangements Tutorial started placing URL references to tutorial pictures within a data-img global data attribute of the option subelements of the dropdown (ie. select) element referencing blog postings here on this blog
  2. method=POST and hashtag (via dynamically hashtagged form action attribute) we mentioned with Cowsay Cartoon Ordered Recursion Tutorial

… usage, and it that way associating …

  • animated GIF presentations … with …
  • WordPress Blog postings

… the user can double click the textbox to open, and/or share via email or SMS with other recipients who “see what you see” with the changed animated_gif_slides.php‘s live run.


Previous relevant Animated GIF Slides via ImageMagick Primer Tutorial is shown below.

Animated GIF Slides via ImageMagick Primer Tutorial

Animated GIF Slides via ImageMagick Primer Tutorial

Animated GIFs are a means to store a slideshow or visual performance of some kind, that consists of several photograph stills, into the one image GIF file, which displays as an animation.

The last time we talked about Animated GIFs at this blog we wrote a web application to construct Animated GIFs from its constituent parts, when we presented Animated GIF via PHP Writing PHP Primer Tutorial as shown below.

If you guessed that today, instead, we were going to “take a walk in the Black Forest” or “catch an Ordon Catfish in a fish hole” … well, no … but … yes … well.

Today, we are going to use the PHP ImageMagick class (as we did yesterday with ImageMagick and Three Ps Affine Transformation Tutorial) to deconstruct an Animated GIF to show you its constituent photograph still parts, presented in one row of table cell elements, any/all of which you could right click and use a “Save Image As” option on your web browser to download these images, as necessary.

ImageMagick knows no bounds, and we continue to find good uses for it, though if you expect it to make you breakfast in bed before you ordered it, or even know that you wanted it, please think again would recommend the eggs benedict.

Two websites spring to my mind when you talk about Animated GIFs …

  • Tumblr … which uses them a lot man person
  • Gifpal … which helps you to construct your own man person

We have PHP serverside code to show you today with animated_gif_slides.php and we have a live run link too. And yes.


Previous relevant Animated GIF via PHP Writing PHP Primer Tutorial is shown below.

Animated GIF via PHP Writing PHP Primer Tutorial

Animated GIF via PHP Writing PHP Primer Tutorial

We find another very useful reason for PHP to write PHP. Today we establish a PHP web application to dynamically create Animated GIF images via some still images, like Gifpal would do.

We have some great open source PHP code to thank for the basis of the functionality we found at Jeroen van Wissen’s very useful link, thanks.

Then we added a more user friendly interface to get the information off the user we need. We present this in an HTML form, which navigates to the same PHP to do the actual assembly of the Animated GIF via techniques where PHP writes PHP … and really needs to, to be useful.

Do you remember, last, when we did some PHP writing PHP functionality … PHP Writes PHP Vertical TextBoxes Primer Tutorial?

And inside the PHP it makes big use of the GD and Image Functions to read and write the image data we assemble via the user information.

This Animated GIF form of animation is the easiest to implement, as it consists of just the one GIF image file, but the user has very little control over the animation settings, such as the delay between stills, one of the settings we ask about in our web application.

Our PHP source code today you could call tutorial_to_animated_gif.php and we redirect you to some live run ideas …

  • normal run with HTML form which posts back to itself … live run
  • example GET parameters run (like our tutorial picture)

Hope you find this tutorial useful.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Animated GIF Slides via Landing Page Browsing and Pasting Tutorial

Animated GIF Slides via Landing Page Browsing and Pasting Tutorial

Animated GIF Slides via Landing Page Browsing and Pasting Tutorial

Two additional means of user input onto yesterday’s Animated GIF Slides via Landing Page Dropdown Tutorial‘s …

  • textbox image URL keyboard entry or dropdown select entry means … are, as of today …
    1. a new local image file browsing button click/tap to reach a browsing scenario … and …
    2. a new image copy buffer pasting scenario in span elements to the right of the browsing button

    … via PHP writes HTML like …
    <?php

    $ifstuff='  <span id=spagspan><iframe class="spag" scrolling="no" onload="checkit(this);" id="cbi" frameborder="0" style="width:173px;height:218px;margin-top:-194px;" src="/HTMLCSS/client_browsing.htm?d=312160562686&wording=Allimages%20images%2E%20"></iframe></span>';

    ?>

… where, today, we allow for image data that is not animated GIF …


function laterisgif() {
if (document.getElementById('selname').value.indexOf('.gif') != -1) {
prefetch(document.getElementById('selname').value);
} else if (document.getElementById('selname').value.trim() != '') {
document.body.style.backgroundRepeat='no-repeat';
document.body.style.backgroundSize='contain';
document.body.style.background='linear-gradient(rgba(255,255,255,0.6),rgba(255,255,255,0.6)),url(' + document.getElementById('selname').value + ')';
if (document.getElementById('selname').placeholder != '' && document.getElementById('selname').placeholder == lastduri) {
document.getElementById('selname').value='';
lastduri='';
} else {
document.getElementById('selname').placeholder=document.getElementById('selname').value;
}
document.getElementById('selname').value='';
}
}

function prefetch(whatgifmaybe) { // thanks to https://stackoverflow.com/questions/69564118/how-to-get-duration-of-gif-image-in-javascript#:~:text=Mainly%20use%20parseGIF()%20%2C%20then,duration%20of%20a%20GIF%20image.
if ((whatgifmaybe.toLowerCase().trim().split('#')[0] + '?').indexOf('.gif?') != -1 || whatgifmaybe.indexOf('data:image/gif') != -1 || whatgifmaybe.indexOf('gif;base64,') == 0) {
ingif=whatgifmaybe;
//document.body.style.cursor='progress';
fetch(whatgifmaybe)
.then(res => res.arrayBuffer())
.then(ab => isGifAnimated(new Uint8Array(ab)))
.then(console.log);
}
}

function isGifAnimated(uint8) { // thanks to https://stackoverflow.com/questions/69564118/how-to-get-duration-of-gif-image-in-javascript#:~:text=Mainly%20use%20parseGIF()%20%2C%20then,duration%20of%20a%20GIF%20image.
let duration = 0;
for (let i = 0, len = uint8.length; i < len; i++) {
if (uint8[i] == 0x21
&& uint8[i + 1] == 0xF9
&& uint8[i + 2] == 0x04
&& uint8[i + 7] == 0x00)
{
const delay = (uint8[i + 5] << 8) | (uint8[i + 4] & 0xFF);
duration += delay < 2 ? 10 : delay;
}
}
if (eval(duration / 100) < 0.11) {
document.body.style.backgroundRepeat='no-repeat';
document.body.style.backgroundSize='contain';
document.body.style.background='linear-gradient(rgba(255,255,255,0.6),rgba(255,255,255,0.6)),url(' + document.getElementById('selname').value + ')';
if (document.getElementById('selname').placeholder != '' && document.getElementById('selname').placeholder == lastduri) {
document.getElementById('selname').value='';
lastduri='';
} else {
document.getElementById('selname').placeholder=document.getElementById('selname').value;
}
document.getElementById('selname').value='';
//alert('POST');
document.getElementById('myform').method='POST';
} else if (gresis != '') {
//alert('GET');
document.getElementById('myform').method='POST'; //'GET';
document.getElementById('myform').action=document.getElementById('myform').action.split('.php')[0] + '.php#75586#' + encodeURIComponent(document.getElementById('selname').value + '#' + document.getElementById('selname').title);
//} else {
// alert('why');
}
//alert('' + eval(duration / 100));
return duration / 100; // if 0.1 is not an animated GIF
}

… be recognized as a document.body background image. As well as that, the textbox can accept data URI entries.

Try this out with the changed animated_gif_slides.php‘s live run.


Previous relevant Animated GIF Slides via Landing Page Dropdown Tutorial is shown below.

Animated GIF Slides via Landing Page Dropdown Tutorial

Animated GIF Slides via Landing Page Dropdown Tutorial

Some of the reason we are so keen on blog animated GIF forms of presentation at this blog you can read about with Animated GIF versus PDF Presentation Considerations Tutorial.

But, on occasions, when you see a slide of interest zip past you when looking at an animated GIF presentation image at this blog, do you ever want to see the slides presented that went to make up that animated GIF, perhaps presented in a single horizontal row of still image slides you can scroll among, from left to right, in order?

Sorry, that’s rhetorical. Anyway, revisiting the PHP (exec calling ImageMagick) web application of Animated GIF Slides via ImageMagick Primer Tutorial we’ve found scope for including new …

  1. dropdown suggestions for animated GIFs (as a tutorial picture for a blog posting here at this blog) to try, as gleaned from the dropdown among the Landing Page suite of webpages, and now so much easier since the work of Crontab and Curl Rearrangements Tutorial started placing URL references to tutorial pictures within a data-img global data attribute of the option subelements of the dropdown (ie. select) element referencing blog postings here on this blog
  2. method=POST and hashtag (via dynamically hashtagged form action attribute) we mentioned with Cowsay Cartoon Ordered Recursion Tutorial

… usage, and it that way associating …

  • animated GIF presentations … with …
  • WordPress Blog postings

… the user can double click the textbox to open, and/or share via email or SMS with other recipients who “see what you see” with the changed animated_gif_slides.php‘s live run.


Previous relevant Animated GIF Slides via ImageMagick Primer Tutorial is shown below.

Animated GIF Slides via ImageMagick Primer Tutorial

Animated GIF Slides via ImageMagick Primer Tutorial

Animated GIFs are a means to store a slideshow or visual performance of some kind, that consists of several photograph stills, into the one image GIF file, which displays as an animation.

The last time we talked about Animated GIFs at this blog we wrote a web application to construct Animated GIFs from its constituent parts, when we presented Animated GIF via PHP Writing PHP Primer Tutorial as shown below.

If you guessed that today, instead, we were going to “take a walk in the Black Forest” or “catch an Ordon Catfish in a fish hole” … well, no … but … yes … well.

Today, we are going to use the PHP ImageMagick class (as we did yesterday with ImageMagick and Three Ps Affine Transformation Tutorial) to deconstruct an Animated GIF to show you its constituent photograph still parts, presented in one row of table cell elements, any/all of which you could right click and use a “Save Image As” option on your web browser to download these images, as necessary.

ImageMagick knows no bounds, and we continue to find good uses for it, though if you expect it to make you breakfast in bed before you ordered it, or even know that you wanted it, please think again would recommend the eggs benedict.

Two websites spring to my mind when you talk about Animated GIFs …

  • Tumblr … which uses them a lot man person
  • Gifpal … which helps you to construct your own man person

We have PHP serverside code to show you today with animated_gif_slides.php and we have a live run link too. And yes.


Previous relevant Animated GIF via PHP Writing PHP Primer Tutorial is shown below.

Animated GIF via PHP Writing PHP Primer Tutorial

Animated GIF via PHP Writing PHP Primer Tutorial

We find another very useful reason for PHP to write PHP. Today we establish a PHP web application to dynamically create Animated GIF images via some still images, like Gifpal would do.

We have some great open source PHP code to thank for the basis of the functionality we found at Jeroen van Wissen’s very useful link, thanks.

Then we added a more user friendly interface to get the information off the user we need. We present this in an HTML form, which navigates to the same PHP to do the actual assembly of the Animated GIF via techniques where PHP writes PHP … and really needs to, to be useful.

Do you remember, last, when we did some PHP writing PHP functionality … PHP Writes PHP Vertical TextBoxes Primer Tutorial?

And inside the PHP it makes big use of the GD and Image Functions to read and write the image data we assemble via the user information.

This Animated GIF form of animation is the easiest to implement, as it consists of just the one GIF image file, but the user has very little control over the animation settings, such as the delay between stills, one of the settings we ask about in our web application.

Our PHP source code today you could call tutorial_to_animated_gif.php and we redirect you to some live run ideas …

  • normal run with HTML form which posts back to itself … live run
  • example GET parameters run (like our tutorial picture)

Hope you find this tutorial useful.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Animated GIF Slides via Landing Page Dropdown Tutorial

Animated GIF Slides via Landing Page Dropdown Tutorial

Animated GIF Slides via Landing Page Dropdown Tutorial

Some of the reason we are so keen on blog animated GIF forms of presentation at this blog you can read about with Animated GIF versus PDF Presentation Considerations Tutorial.

But, on occasions, when you see a slide of interest zip past you when looking at an animated GIF presentation image at this blog, do you ever want to see the slides presented that went to make up that animated GIF, perhaps presented in a single horizontal row of still image slides you can scroll among, from left to right, in order?

Sorry, that’s rhetorical. Anyway, revisiting the PHP (exec calling ImageMagick) web application of Animated GIF Slides via ImageMagick Primer Tutorial we’ve found scope for including new …

  1. dropdown suggestions for animated GIFs (as a tutorial picture for a blog posting here at this blog) to try, as gleaned from the dropdown among the Landing Page suite of webpages, and now so much easier since the work of Crontab and Curl Rearrangements Tutorial started placing URL references to tutorial pictures within a data-img global data attribute of the option subelements of the dropdown (ie. select) element referencing blog postings here on this blog
  2. method=POST and hashtag (via dynamically hashtagged form action attribute) we mentioned with Cowsay Cartoon Ordered Recursion Tutorial

… usage, and it that way associating …

  • animated GIF presentations … with …
  • WordPress Blog postings

… the user can double click the textbox to open, and/or share via email or SMS with other recipients who “see what you see” with the changed animated_gif_slides.php‘s live run.


Previous relevant Animated GIF Slides via ImageMagick Primer Tutorial is shown below.

Animated GIF Slides via ImageMagick Primer Tutorial

Animated GIF Slides via ImageMagick Primer Tutorial

Animated GIFs are a means to store a slideshow or visual performance of some kind, that consists of several photograph stills, into the one image GIF file, which displays as an animation.

The last time we talked about Animated GIFs at this blog we wrote a web application to construct Animated GIFs from its constituent parts, when we presented Animated GIF via PHP Writing PHP Primer Tutorial as shown below.

If you guessed that today, instead, we were going to “take a walk in the Black Forest” or “catch an Ordon Catfish in a fish hole” … well, no … but … yes … well.

Today, we are going to use the PHP ImageMagick class (as we did yesterday with ImageMagick and Three Ps Affine Transformation Tutorial) to deconstruct an Animated GIF to show you its constituent photograph still parts, presented in one row of table cell elements, any/all of which you could right click and use a “Save Image As” option on your web browser to download these images, as necessary.

ImageMagick knows no bounds, and we continue to find good uses for it, though if you expect it to make you breakfast in bed before you ordered it, or even know that you wanted it, please think again would recommend the eggs benedict.

Two websites spring to my mind when you talk about Animated GIFs …

  • Tumblr … which uses them a lot man person
  • Gifpal … which helps you to construct your own man person

We have PHP serverside code to show you today with animated_gif_slides.php and we have a live run link too. And yes.


Previous relevant Animated GIF via PHP Writing PHP Primer Tutorial is shown below.

Animated GIF via PHP Writing PHP Primer Tutorial

Animated GIF via PHP Writing PHP Primer Tutorial

We find another very useful reason for PHP to write PHP. Today we establish a PHP web application to dynamically create Animated GIF images via some still images, like Gifpal would do.

We have some great open source PHP code to thank for the basis of the functionality we found at Jeroen van Wissen’s very useful link, thanks.

Then we added a more user friendly interface to get the information off the user we need. We present this in an HTML form, which navigates to the same PHP to do the actual assembly of the Animated GIF via techniques where PHP writes PHP … and really needs to, to be useful.

Do you remember, last, when we did some PHP writing PHP functionality … PHP Writes PHP Vertical TextBoxes Primer Tutorial?

And inside the PHP it makes big use of the GD and Image Functions to read and write the image data we assemble via the user information.

This Animated GIF form of animation is the easiest to implement, as it consists of just the one GIF image file, but the user has very little control over the animation settings, such as the delay between stills, one of the settings we ask about in our web application.

Our PHP source code today you could call tutorial_to_animated_gif.php and we redirect you to some live run ideas …

  • normal run with HTML form which posts back to itself … live run
  • example GET parameters run (like our tutorial picture)

Hope you find this tutorial useful.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , | Leave a comment