I'm trying to do some basic 2.D transformations. I was hoping to create an animation sketch translating 2D shapes in three-dimensional perspective. I figure making use of
z axis translations is the best method for this, but I'm not so sure how to approach this; I'm intentionally avoiding the use of 3D shapes.
Looking at some references and tool tips, I've managed to get as far as translating 3 sided shapes to create a "spin animation" (e.g. triangle) by translating points, but it's pretty messy and uses a lot
if statements and line objects. Ideally I'd like to include z axis rotating.
I thought a good starting point would be getting a handle on basic shape transformations. So I've been looking at creating and translating drawn shapes. I believe using SVG graphics is another possible option I can attempt for this[?] but at the moment this is what I'm working with.
The following sketch is my attempt at emulating a triangle rotation on a 0axis. I was wondering if anyone would be able to suggest how to do this without the cumbersome use of loops I'm attempting? I'm sure there's a cleaner, clearer way to do this.
N.B. I'm not focusing on including a z axis roation on 'this' sketch, as I can't even seem to get a simple 2D rotation.
This is a simple exercise in getting to grips with colour values and animation in Processing. I'm trying to figure out how to create colour tweens, without the use of a library. I was hoping to apply this to some animation e.g. such as a changing background for an animation. So far this is what I have, it's pretty messy, and only uses if statements to change colour values. I had to look at colour value changes on an RGB scale to get the difference in values.
There's a bit of lag between
green and
cyan. The green values don't decrease immediately when the if statements called. I put in a print statement to check the values, but they seem to stick at 255 for while before decreasing.
If anyone can offer any help pointers, or advice for a better method to do this, with the exception of using libraries, it would be much appreciated; thanks
P.S. Can this be done with for loops?
//Colour tween animation
//Set starting colour values
int r = 255;
int g = 0;
int b = 0;
//Control rate of colour change
int speed = 4;
void setup() {
size(400, 400);
}
void draw() {
//Assign int values to background
background(r, g, b);
//Start, increase green RGB value
//Red to yellow
g = g + 1;
//Yellow to green
if(g >= 255) {
g = 255;
r = r - speed;
}
//Green to cyan
if( r <= 0) {
r = 0;
b = b + speed; //lag between change
println("green: " + g);
}
//cyan to blue
if(b >= 255){
b = 255;
g = g - speed;
}
//Blue to purple
if(g <= 0){
g = 0;
r = r + speed;
}
I'm working with an edit of
"Till Nagel's SimpleFeedVisualizer" trying to gather numerical data from
: http://www.newyorkfed.org/xml/data/ff/ffd.xml <base: OBS_VALUE> XMLElement. Unfortunately I have some poor understanding of the code. I'm trying to gather numerical data from a string a variable so e.g.
String s; and parse
int values into a variable e.g.
int I = Integer.parseInt(s); I'm not clear on the where I should be declaring these statements, and if at there's is any need to edit the section loading RSS Feeds.
/**
* Loads RSS feed and visualizes the titles in a very simple manner.
* Color and bar depend on the length of the corresponding title.
This code was originally set as part of a class exercise/task several semesters ago when I started Programming.The task is to write some code for a basic alarm using set variables for the designated alarm time. I want to make it so when my Alarm is active an audio file (sound of an alarm) is played, the alarm should only last 8 seconds, during which time my forever loop --my while loop printing a full stop every second-- is paused for this amount of time after which it should return back to printing a series of full stops every second
//import processing.video.Movie;
int alarm_time;
int alarm_hour;
int alarm_minute;
int current_time;
int t,count;
boolean alarm;
void setup(){
//Set alarm time
alarm_hour = 17;
alarm_minute = 54;
//Define alarm time & curent time
alarm_time = alarm_hour + alarm_minute;
current_time = hour() + minute();
}
void draw(){
//"forever while loop" infinite loop, prints (or rather should) a full stop every half second
So I'm trying to write some code for a basic alarm programme. The alarm uses an m4v file to play an audio file when triggered, and I want to make it so that when my alarm plays there is a delay of 8 seconds. In addition the delay time in numbers (
int values) should be displayed in the console window along with a print statement to mark the alarm as on e.g:
//Alarm
//Counting: 1 2 3 4 5 6 7 8
My code so far:
import processing.video.Movie;
int alarm_hour;
int alarm_minute;
int alarm;
int current_time;
alarm_hour = 11;
alarm_minute = 44;
alarm = alarm_hour + alarm_minute;
current_time = hour() + minute();
//Where I'm attempting to place a delay that prints out the number of seconds (8 seconds) in int values
So I recently started coding as part of my course curriculum, I lack quite a lot of experience with programs as a result am unsure about how to handle my current problem:
I'm working on a short Processing exercise that uses While Loops and For Loops with the intention to purposefully delay a calculation program, at least that's the half of it. The aim so far is to create a For Loop that runs a sqrt calculation a specified amount of times, in this instance a billion times (100,000,000). With the addition of a While Loop using a print function as part of the statement to print out a series of full stops. The final aim is to include the calculation loop INSIDE the forever while loop to delay the amount of times a full stop is printed. The end result should see a full stop being printed every half a second. Just to make sure I'm explaining myself clearly here are the actual instructions given:
float c = sqrt(257);
boolean always_true = true;
//commented lines - print functions marking start and end
//println("Starting calculations");
//My attempt at nesting the for loop within the while loop, unsure as to how to actually do this with the desired effect :/
while(always_true){
for(c = 0; c < 1000; c++){
print(".");
}
}
//println("Finished Calculation");
N.B. I realise this is really mediocre but I really want to get this complete and help myself understand this. Desperately want to improve my coding abilities.