“GUI 3d Demo” by Quark
https://openprocessing.org/sketch/1620578
License CreativeCommons Attribution NonCommercial ShareAlike
https://creativecommons.org/licenses/by-nc-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
Use the mouse to interact with the controls
CC Attribution NonCommercial ShareAlike
GUI 3d Demo
xxxxxxxxxx
/*
The 3d animation for this sketch was taken from one of Processing's examples
so I can not take credit for that. :-)
I simply use it to show that my GUI works on a 3D sketch.
*/
let sketch_3D = function (p) {
p.preload = function () {
p.cSwatch = p.loadImage('c_swatch.png');
p.cPresets = p.loadImage('c_presets.png');
p.cMixer = p.loadImage('c_mixer.png');
}
p.setup = function () {
let p5canvas = p.createCanvas(450, 360, p.WEBGL);
// This next instruction MUST be used to initialise the GUI controller
p.gui = GUI.get(p5canvas, p);
p.gui.scheme('blue').textSize(12);
p.r = 200, p.g = 180, p.b = 20;
p.createColorSchemePane();
p.createColorPresets();
p.createColorMixer();
p.gui.checkbox('cbx1', 0, 0, 120, 60).text('Hide\nTabs', p.LEFT).textSize(9).shrink()
.tooltip('Hide / show tabs', 2000)
.scheme('green')
.setAction(function (ei) {
if (ei.selected) p.gui.hideAll(); else p.gui.showAll();
});
}
p.draw = function () {
p.push();
p.background(220);
p.stroke(0);
p.fill(p.r, p.g, p.b);
p.strokeWeight(0.5);
p.rotateY(p.frameCount * 0.005);
for (let j = 0; j < 5; j++) {
p.push();
for (let i = 0; i < 80; i++) {
p.translate(
Math.sin(p.frameCount * 0.0005 + j) * 80,
Math.sin(p.frameCount * 0.0005 + j) * 80,
i * 0.1
);
p.rotateZ(p.frameCount * 0.001);
p.push();
p.sphere(8, 6, 4);
p.pop();
}
p.pop();
}
p.pop();
p.gui.draw();
}
p.createColorMixer = function () {
let pane = p.gui.pane('mixer', 'south', 90).text('RGB Color Mixer').icon(p.cMixer);
let gap = 10, sw = 120;
let sx = p.gui.canvasWidth() / 2 - gap - 1.5 * sw;
p.sdrR = p.gui.slider('sdrR', sx, 4, sw, 20).limits(0, 255).value(p.r).parent(pane)
.setAction(function (info) { p.r = p.round(info.value) });
p.gui.label('lblR', sx + 10, 26, sw - 20, 14).text('Red').parent(pane);
sx += sw + gap;
p.sdrG = p.gui.slider('sdrG', sx, 4, sw, 20).limits(0, 255).value(p.g).parent(pane)
.setAction(function (info) { p.g = p.round(info.value) });
p.gui.label('lblG', sx + 10, 26, sw - 20, 14).text('Green').parent(pane);
sx += sw + gap;
p.sdrB = p.gui.slider('sdrB', sx, 4, sw, 20).limits(0, 255).value(p.b).parent(pane)
.setAction(function (info) { p.b = p.round(info.value) });
p.gui.label('lblB', sx + 10, 26, sw - 20, 14).text('Blue').parent(pane);
}
p.createColorPresets = function () {
let pane = p.gui.pane('presets', 'south', 110).text('Color Presets').icon(p.cPresets)
let gap = 10, bw = 120;
let bx = p.gui.canvasWidth() / 2 - gap - 1.5 * bw;
p.gui.button('ps1', bx, 4, bw, 20).text('Burnt Sienna').parent(pane)
.icon(p.getColorIcon(12, 12, 218, 95, 28))
.setAction(function () {
p.sdrR.value(p.r = 218); p.sdrG.value(p.g = 95); p.sdrB.value(p.b = 28)
});
p.gui.button('ps4', bx, 40, bw, 20).text('Harvest Gold').parent(pane)
.icon(p.getColorIcon(12, 12, 252, 185, 77))
.setAction(function () {
p.sdrR.value(p.r = 252); p.sdrG.value(p.g = 185); p.sdrB.value(p.b = 77)
});
bx += bw + gap;
p.gui.button('ps2', bx, 4, bw, 20).text('Blue Mustang').parent(pane)
.icon(p.getColorIcon(12, 12, 56, 135, 157))
.setAction(function () {
p.sdrR.value(p.r = 56); p.sdrG.value(p.g = 135); p.sdrB.value(p.b = 157)
});
p.gui.button('ps5', bx, 40, bw, 20).text('Teak').parent(pane)
.icon(p.getColorIcon(12, 12, 170, 108, 24))
.setAction(function () {
p.sdrR.value(p.r = 170); p.sdrG.value(p.g = 108); p.sdrB.value(p.b = 24)
});
bx += bw + gap;
p.gui.button('ps3', bx, 4, bw, 20).text('Natural').parent(pane)
.icon(p.getColorIcon(12, 12, 218, 191, 151))
.setAction(function () {
p.sdrR.value(p.r = 218); p.sdrG.value(p.g = 191); p.sdrB.value(p.b = 151)
});
p.gui.button('ps6', bx, 40, bw, 20).text('Avacado').parent(pane)
.icon(p.getColorIcon(12, 12, 135, 155, 66))
.setAction(function () {
p.sdrR.value(p.r = 135); p.sdrG.value(p.g = 155); p.sdrB.value(p.b = 66)
});
}
p.createColorSchemePane = function () {
let pane = p.gui.pane('colScheme', 'east', 120).text('GUI Color Scheme').icon(p.cSwatch)
let top = 40;
p.gui.label('cslabel', 10, top, 70, 20).text('Select GUI\ncolor scheme')
.textSize(14).parent(pane)
p.gui.option('red', 10, top + 50, 70, 20).text('Red').group('scheme').parent(pane)
.setAction(p.csAction)
p.gui.option('green', 10, top + 80, 70, 20).text('Green').group('scheme').parent(pane)
.setAction(p.csAction)
p.gui.option('blue', 10, top + 110, 70, 20).text('Blue').group('scheme').parent(pane)
.setAction(p.csAction).select()
p.gui.option('yellow', 10, top + 140, 70, 20).text('Yellow').group('scheme').parent(pane)
.setAction(p.csAction)
p.gui.option('purple', 10, top + 170, 70, 20).text('Purple').group('scheme').parent(pane)
.setAction(p.csAction)
p.gui.option('cyan', 10, top + 200, 70, 20).text('Cyan').group('scheme').parent(pane)
.setAction(p.csAction)
p.gui.option('orange', 10, top + 230, 70, 20).text('Orange').group('scheme').parent(pane)
.setAction(p.csAction)
}
p.csAction = function (ei) {
//console.log('Selected', a.source.name(), ' Deselected', a.previous.name())
p.gui.scheme(ei.source.name())
}
p.getColorIcon = function (w, h, r, g, b) {
let img = p.createImage(w, h);
img.loadPixels();
for (let i = 0; i < img.pixels.length; i += 4) {
img.pixels[i] = r;
img.pixels[i + 1] = g;
img.pixels[i + 2] = b;
img.pixels[i + 3] = 255;
}
img.updatePixels();
return img;
}
}
let p1 = new p5(sketch_3D);
See More Shortcuts