Newsletter #205 - Summertime is VB Scripting time!
For full newsletters please look here: https://www.thebest3d.com/dogwaffle/newsletter
Hello again!
Don't have PD Howler yet? Save 50% now!
Save 50% off our regular price! Save price as upgrade, for the full installer of PD Howler 2024.
Order here: https://www.thebest3d.com/sales
- Select Howler 2024
- The discount is applied automagically, no code needed.
Starts now, runs through July 4 - Independence Day, and ends July 15 - 1 day after Bastille Day. Vive la Révolution!
- Happy 4th of July and enjoy!
Thank you for waffling and howling, have a wonderful and creative rest of July! If you attend ComicCon be sure to share your experience on our Facebook group, PD Howler - Project Dogwaffle.
Dan's Patreon with Details on VB Scripting from Bing Copilot
Dan has posted something on his Patreon page. You can see most of it below but you might be interested also in joining Patreon to follow him on future announcements through that channel.
https://www.patreon.com/posts/scripting-with-106945985?utm_medium=clipboard_copy&utm_source=copyLink&utm_campaign=postshare_creator&utm_content=join_link
Howler’s API - Where to Go and Learn More
For those eager to explore further, Howler’s API provides a treasure trove of functions for creative scripting. You can find the API documentation https://www.pdhowler.com/API_And_Scripting.htm. Stay tuned for future newsletters where we’ll delve into more advanced features of Howler’s API.
And now for the main treat: (drumroll)....
Automate Your Howler Experience with VBScript
Unlock the power of automation by using VBScript to control Howler through its API. VBScript is a scripting language that allows you to write quick and efficient scripts for task automation in a Windows environment.
What is VBScript?
VBScript stands for Visual Basic Scripting Edition, a scripting language by Microsoft that’s designed for quick development. It’s used to automate tasks on Windows, making it a perfect tool for interacting with Howler’s API.
Using VBScript with Howler’s API
With VBScript, you can automate repetitive tasks, manage Howler settings, and much more. Here’s a basic example of how VBScript can be used to send a request to Howler’s API:
Dive into VBScript for Howler
With VBScript, you can effortlessly automate your Howler tasks. Below is an example of a VBScript that applies a Gaussian blur to an image in Howler:
Sub main()
' Save the current state for undo
dogwaffle.dog_saveundo "Gaussian blur kernel"
' Set the kernel to Gaussian
kernel.SetGaussian
' Apply the Gaussian kernel to the image
kernel.ApplyToImage
' Refresh the canvas to show changes
dogwaffle.dog_Refresh
End Sub
This script performs the following actions:
- Saves the current state for undo, allowing you to revert back if needed.
- Sets the kernel to a Gaussian blur, a common effect for softening images.
- Applies the Gaussian blur to the current image.
To use this script, simply copy and paste it into a VBScript editor like Notepad and save it in the VBScripts folder where Howler is installed. That's usually on the C: drive in \Program Files(x86)\Howler but could be different in your installation. Then, run it within the Howler environment. It’s a practical example of how VBScript can interact with Howler’s API to modify images with ease. (to run it, go to the menu: Filters > Scripts)
- Refreshes the canvas to update the visual display.
Explore and Expand
This VBScript is just the beginning. As you become more comfortable with the scripting language and Howler’s API, you’ll find countless ways to enhance your workflow. Experiment with different effects, automate complex sequences, and transform your creative process.
Deeper Dive: Accessing Pixels Individually with VBScript
In this section, we’ll explore how to manipulate image pixels directly using VBScript. While you can draw shapes like ellipses, recangles, and polygones with the drawing class, this technique allows for fine-grained control over the visual elements of your images in Howler.
Understanding Pixel Access in VBScript
VBScript does not natively support byte arrays, which are typically used for pixel manipulation. However, Howler provides a special class that utilizes arrays of variants to overcome this limitation. Keep in mind that VBScript is an interpreted language and may not be the fastest option for pixel processing. For more intensive tasks, consider using Howler’s Lua compiler for better performance.
Example Script: Random Pixel Rendering
Here’s a VBScript example that randomly alters the RGB values of each pixel in an image:
function main()
' Always start with a main() function
' Save the current state for undo
dogwaffle.dog_saveundo "Render pixels"
' Retrieve the width and height of the image
w = pixels.width
h = pixels.height
' Get the red, green, and blue buffers
rbuf = pixels.getrbuf
gbuf = pixels.getgbuf
bbuf = pixels.getbbuf
' Loop through each pixel
for y = 0 to h - 1
for x = 0 to w - 1
' Access the pixel's RGB values
r = rbuf(x, y)
g = gbuf(x, y)
b = bbuf(x, y)
' Randomly alter the RGB values
r = rnd * r
g = rnd * g
b = rnd * b
' Update the pixel's RGB values in the buffers
rbuf(x, y) = r
gbuf(x, y) = g
bbuf(x, y) = b
next
next
' Set the updated buffers back to the image
pixels.setrbuf rbuf
pixels.setgbuf gbuf
pixels.setbbuf bbuf
' Blend the current image with the undo image through the alpha
pixels.alphablend
' Refresh the image to display changes
pixels.refresh
end function
This script saves the current image state for undo, iterates over each pixel, and applies a random factor to the RGB values, creating a random noise effect. It then updates the image with the altered pixels and refreshes the canvas.
Note on Clamping Values
In previous versions of Howler, you would need to clamp the RGB values to ensure they remain within the valid range. However, Howler now automatically clamps these values for you.
function Clamp(byval v, byval l, byval h)
if v < l then v = l
if v > h then v = h
Clamp = v
end function
While the Clamp function is provided, it’s no longer necessary for this script due to Howler’s automatic clamping.
Experiment and Learn
This example is a starting point for pixel manipulation. As you experiment with VBScript and Howler’s API, you’ll discover more ways to create dynamic and engaging visual effects.
Exploring VBScript with Howler: For/Next Loops and If/Then Statements
In this edition of our Howler newsletter, we dive into the basics of VBScript to manipulate images with Howler’s powerful API. Let’s unravel the mysteries of For/Next loops and If/Then statements, essential tools for any scripter’s toolkit.
For/Next Loops The For/Next loop in VBScript is a workhorse for repetitive tasks. It allows you to execute a block of code a specific number of times. Here’s the structure:
For counter = start To end [Step step]
' Code to be executed
Next
In our Howler scripts, we use For/Next loops to process image pixels. For example:
For y = 0 To h - 1
For x = 0 To w - 1
' Pixel manipulation code goes here
Next
Next
This nested loop runs through each pixel in the image, where w is the image width and h is the image height.
If/Then Statements The If/Then statement is the decision-maker in VBScript. It executes a block of code only if a specified condition is true. Here’s how it looks:
If condition Then
' Code to be executed if condition is true
End If
In our pixel manipulation script, we might use an If/Then statement to apply changes only to certain pixels, like so:
If r > threshold Then
' Apply changes to the red channel
End If
Happy scripting!
Here are more Video Tutorials and Samples
https://youtu.be/wYJ5qW3uwLw - Scripting with AI (Bing Copilot)
https://youtu.be/xs-oznoIfNo - Galaxy Script
https://youtu.be/P7WGDjKgHYE - Lightning Bolts
Team Dogwaffle:
https://www.pdhowler.com & https://www.thebest3d.com
------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- -------
How to unsubscribe:
To remove yourself from our newsletter, please unsubscribe here: http://www.thebest2d.com/feedback/
Thank you.
------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- -------