-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated and moved new image file generation examples.
- Loading branch information
1 parent
2215eec
commit eda40d9
Showing
9 changed files
with
98 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/local/bin/sms -qm225 | ||
# Demonstrates generating a black and white striped TGA image with 3 shades | ||
|
||
{ | ||
# Include the bwImg library | ||
eval(fileParse("bwImg.sms")); | ||
|
||
# Image dimensions | ||
let width = 256; | ||
let height = 256; | ||
|
||
# Create an array for the striped pattern | ||
let grayscaleArray = ui8Repeat(ui8[0], width * height); | ||
|
||
# Define 3 shades of gray | ||
let shade1 = ui8(85); # Light gray | ||
let shade2 = ui8(170); # Medium gray | ||
let shade3 = ui8(255); # White | ||
|
||
# Size of each stripe | ||
let stripeSize = 32; | ||
|
||
# Fill the array with a striped pattern | ||
for (let i = 0; i < height; i++) { | ||
for (let j = 0; j < width; j++) { | ||
# Determine the column position, rounding to the nearest integer | ||
let blockCol = round(j / stripeSize); | ||
|
||
# Alternate between shades based on column position | ||
if (mod(blockCol, 3) == 0) { | ||
grayscaleArray[i * width + j] = shade1; | ||
} else if (mod(blockCol, 3) == 1) { | ||
grayscaleArray[i * width + j] = shade2; | ||
} else { | ||
grayscaleArray[i * width + j] = shade3; | ||
}; | ||
}; | ||
}; | ||
|
||
# Use the bwImg.write function to create the TGA file | ||
let result = bwImg.write("striped_pattern.tga", width, height, grayscaleArray); | ||
if (result == true) { | ||
putLn("Striped pattern TGA file 'striped_pattern.tga' has been created."); | ||
} else { | ||
putLn("Error: " str+ result); | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/local/bin/sms -m196 | ||
# Usage: This script demonstrates creating a rainbow gradient using colorImg.write | ||
|
||
{ | ||
# Evaluate and include the colorImg library | ||
eval(fileParse("colorImg.sms")); | ||
|
||
# Image dimensions | ||
let width = 256; | ||
let height = 256; | ||
let bytesPerPixel = 3; | ||
|
||
# Create an RGB array for the rainbow gradient | ||
let rgbArray = ui8Repeat([ui8(0)], width * height * bytesPerPixel); | ||
|
||
# Fill the RGB array with a rainbow gradient | ||
for (let i = 0; i < height; i++) { | ||
for (let j = 0; j < width; j++) { | ||
# Calculate the pixel index in the RGB array | ||
let rgbIndex = (i * width + j) * bytesPerPixel; | ||
|
||
# Create a gradient with varying colors (RGB order) | ||
let r = ui8((i * 255) / height); # Red varies by height | ||
let g = ui8((j * 255) / width); # Green varies by width | ||
let b = ui8(((i + j) * 255) / (width + height)); # Blue varies by combined position | ||
|
||
# Assign the RGB values to the array | ||
rgbArray[rgbIndex] = r; | ||
rgbArray[rgbIndex + 1] = g; | ||
rgbArray[rgbIndex + 2] = b; | ||
}; | ||
}; | ||
|
||
# Call the colorImg.write function to create the TGA file | ||
let result = colorImg.write("rainbow.tga", width, height, rgbArray); | ||
if (result == true) { | ||
putLn("Rainbow gradient TGA file 'rainbow_gradient.tga' has been created."); | ||
} else { | ||
putLn("Error: " str+ result); | ||
}; | ||
}; | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters