Skip to content

Commit

Permalink
]+][><][+[
Browse files Browse the repository at this point in the history
  • Loading branch information
bbaudry committed Jan 17, 2025
1 parent fce38da commit 0f55b37
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 38 deletions.
85 changes: 73 additions & 12 deletions ift6251/nannou/ikeda/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ fn main() {
struct Model {
nbcols:i64,
nbrows:i64,
grow:bool
grow:bool,
speed:i64,
current:i64,
field:Vec<Box>
}

fn model(app: &App) -> Model {
Expand All @@ -29,16 +32,29 @@ fn model(app: &App) -> Model {
Model{
nbcols:2,
nbrows:1,
grow:true
grow:true,
speed:44,
current:0,
field:Vec::new()
}
}

struct Box {
x:f32,
y:f32,
width:f32,
height:f32,
speed:i64,
black:bool
}

fn update(app: &App, model: &mut Model, _update: Update) {
if model.grow && model.nbrows < 84 {
model.nbrows+=1;
}
else {
if app.elapsed_frames() > 42{
if model.current % model.speed == 0 {
if model.grow && model.nbrows < 84 {
model.nbrows+=1;
}
else {
if app.elapsed_frames() > 42{
if model.nbcols<142 {
model.nbcols+=1;
}
Expand All @@ -49,23 +65,68 @@ fn update(app: &App, model: &mut Model, _update: Update) {
model.nbrows -= 1;
}
else {

model.grow = true;
}
}

}
}
model.field=newField(app,model);

println!("{} boxes", model.field.len());
}
for i in 0..model.field.len() {
let b = &mut model.field[i];
if model.current % b.speed==0 {b.black=!b.black}
}
model.current+=1;
}

fn newField(app: &App,model: &Model) -> Vec<Box>{
let mut f = Vec::new();
let mut black: bool;
let h = app.window_rect().h();
let w = app.window_rect().w();
let left = -w*0.5;
let top = h*0.5;
let boxw = w/(model.nbcols as f32);
let boxh = h/(model.nbrows as f32);
for i in 0..model.nbcols {
for j in 0..model.nbrows {
if random_range(0.0,1.0)<0.5 {black=true}
else {black=false}
let b = Box{
x:left + (i as f32)*boxw + boxw*0.5,
y:top - (j as f32)*boxh - boxh*0.5,
width:boxw,
height:boxh,
speed:11,
black:black
};
f.push(b)
}
}
return f;
}

fn view(app: &App, model: &Model, frame: Frame){
let draw = app.draw();
draw.background().color(BLACK);
let h = app.window_rect().h();
let w = app.window_rect().w();
let blockw = w/(model.nbcols as f32);
let blockh = h/(model.nbrows as f32);
for i in 0..model.field.len() {
let b = &model.field[i];
let c : Color;
if b.black {c=hsl((20.0 / 360.0),1.0,0.0).into()}
else {c=hsl((230.0 / 360.0),1.0,1.0).into()}
draw.rect()
.color(c)
.x_y(b.x,b.y)
.w_h(b.width,b.height);
}

for i in 0..model.nbcols{
/*for i in 0..model.nbcols{
for j in 0..model.nbrows{
if random_range(0.0,1.0)<0.5 {
draw.rect()
Expand All @@ -74,7 +135,7 @@ fn view(app: &App, model: &Model, frame: Frame){
.w_h(blockw,blockh);
}
}
}
}*/
draw.to_frame(app,&frame).unwrap();


Expand Down
11 changes: 8 additions & 3 deletions ift6251/processing/demos/src/main/java/art/algo/Truchet.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ public void setup() {

@Override
public void draw() {
int size = 100;
int size = 20;
noFill();
stroke(0, 0, 100);
strokeWeight((float) (size * 0.1));
tiling(size);
noLoop();
}

public void tiling(int size) {
for (int x = size; x < w - size; x += size) {
for (int y = size; y < h - size; y += size) {
int vera = rand.nextInt(0, 2);
Expand All @@ -43,7 +48,6 @@ public void draw() {
}
}
}
noLoop();
}

public void tile1(int x, int y, int size) {
Expand All @@ -53,11 +57,12 @@ public void tile1(int x, int y, int size) {
}

public void tile2(int x, int y, int size) {
strokeWeight((float) (size * 0.1));
arc(x + size, y, size, size, PI / 2, PI);
arc(x, y + size, size, size, 3 * PI / 2, 2 * PI);
}

public void mouseClicked(){
public void mouseClicked() {
exit();
}

Expand Down
2 changes: 1 addition & 1 deletion p5-experiments/field/field004.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function drawart() {
if(random()<0.8){eye(s)}
else{eye2(s)}
}
strokeWeight(3)
strokeWeight(1)
drawflower()
}

Expand Down
42 changes: 22 additions & 20 deletions p5-experiments/lfsldemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ function setup() {
centerCanvas();
colorMode(HSB, 360, 100, 100, 250);
background(0, 0, 0)
balle=new Balle()
balle = new Balle()
//noLoop()
}

function centerCanvas() {
var x = (windowWidth - 800) / 2;
var y = (windowHeight - 800) / 2;
cnv.position(x, y);
}

var balles=[]
var offset=90
var balles = []
var offset = 90
var balle

function draw() {
background(0,0,0)
if(frameCount==1){ajouter_des_balles(11)}
for(var i=0;i<balles.length;i++){
balle=balles[i]
balle.dessine()
balle.bouge()
balle.rebondi()
}
background(0, 0, 0)
if (frameCount == 1) { ajouter_des_balles(11) }
for (var i = 0; i < balles.length; i++) {
balle = balles[i]
balle.dessine()
balle.bouge()
balle.rebondi()
}
sol()
plafond()
}
Expand All @@ -48,22 +48,24 @@ function draw() {



function sol(){
stroke(330,100,100)
line(0,h,w,h)
function sol() {
stroke(330, 100, 100)
line(0, h, w, h)
strokeWeight(7)
noStroke()
}

function plafond(){
stroke(180,100,100)
line(0,0,w,0)
function plafond() {
stroke(180, 100, 100)
line(0, 0, w, 0)
noStroke()
}

function ajouter_des_balles(nombre){
for(var b=1;b<=nombre;b++){
function ajouter_des_balles(nombre) {
for (var b = 1; b <= nombre; b++) {
balles.push(new Balle())
}
}



4 changes: 2 additions & 2 deletions p5-experiments/plottable/etemontreal003.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ function draw() {
rect(midw + wpostcard, midh + hpostcard, wpostcard, hpostcard)
*/
stroke(0,0,0);
/* cartepostale(midw, midh)
cartepostale(midw, midh)
cartepostale(midw + wpostcard, midh)
cartepostale(midw, midh + hpostcard)
cartepostale(midw + wpostcard, midh + hpostcard)
*/

codeetadresse(midw, midh, destinataires[0])
codeetadresse(midw + wpostcard, midh, destinataires[1])
/* codeetadresse(midw, midh + hpostcard, destinataires[2])
Expand Down

0 comments on commit 0f55b37

Please sign in to comment.