Code Sketch
sanskruti amol kawde
Category: Art
cleari()
originBottomLeft()
class Sketch {
var t = 0.0
var bob = 0.0
var arm = 0.0
var robotX = cwidth * 0.43
var robotY = cheight * 0.43
// GLOBAL ROBOT SCALE
val S = 1.65
def setup(c: CanvasDraw): Unit = {
c.background(2, 3, 20)
}
// =========================================
// DEEP SPACE + NEBULA
// =========================================
def drawBackground(c: CanvasDraw): Unit = {
c.background(2, 3, 20)
// Nebula rings
c.noFill()
for (i <- 0 until 9) {
val pulse =
math.sin(t * 1.2 + i * 0.4) * 12.0
c.stroke(90, 30, 220, 18 + i * 3)
c.strokeWeight(2)
c.ellipse(
cwidth * 0.43,
cheight * 0.53,
270 + i * 30 + pulse,
270 + i * 30 + pulse
)
}
// Stars and sparkling constellations
for (i <- 0 until 180) {
val sx =
((i * 137 + 29) % cwidth).toDouble
val sy =
((i * 83 + 47) % cheight).toDouble
val a =
(70 + math.abs(
math.sin(t * 2.0 + i * 0.31)
) * 185).toInt
val sz =
1.0 + math.abs(math.sin(t + i)) * 2.0
c.noStroke()
if (i % 9 == 0) {
c.fill(205, 105, 255, a)
} else {
c.fill(115, 220, 255, a)
}
c.ellipse(sx, sy, sz, sz)
if (i % 25 == 0) {
c.stroke(150, 225, 255, a)
c.strokeWeight(1)
c.line(sx - 4, sy, sx + 4, sy)
c.line(sx, sy - 4, sx, sy + 4)
}
}
// Neon floor
c.stroke(0, 180, 255, 65)
c.strokeWeight(1)
for (i <- 0 until 17) {
val fy = 8.0 + i * 6.0
c.line(0, fy, cwidth, fy)
}
c.stroke(155, 45, 255, 190)
c.strokeWeight(2)
c.line(0, 108, cwidth, 108)
// HUD frame
c.stroke(0, 225, 255, 190)
c.strokeWeight(2)
c.line(12, 12, 48, 12)
c.line(12, 12, 12, 45)
c.line(cwidth - 12, 12, cwidth - 48, 12)
c.line(cwidth - 12, 12, cwidth - 12, 45)
c.line(12, cheight - 12, 48, cheight - 12)
c.line(12, cheight - 12, 12, cheight - 45)
c.line(cwidth - 12, cheight - 12,
cwidth - 48, cheight - 12)
c.line(cwidth - 12, cheight - 12,
cwidth - 12, cheight - 45)
}
// =========================================
// GIANT ENERGY WINGS
// =========================================
def drawWings(c: CanvasDraw): Unit = {
val x = robotX
val y = robotY + bob + 26 * S
val flap = math.sin(arm) * 15 * S
// Outer wings
c.noFill()
c.stroke(0, 225, 255, 65)
c.strokeWeight(8)
c.line(x - 27*S, y + 12*S,
x - 92*S, y + 65*S + flap)
c.line(x - 92*S, y + 65*S + flap,
x - 72*S, y - 28*S + flap)
c.line(x - 72*S, y - 28*S + flap,
x - 27*S, y + 12*S)
c.stroke(0, 225, 255, 230)
c.strokeWeight(3)
c.line(x - 27*S, y + 12*S,
x - 92*S, y + 65*S + flap)
c.line(x - 92*S, y + 65*S + flap,
x - 72*S, y - 28*S + flap)
c.line(x - 72*S, y - 28*S + flap,
x - 27*S, y + 12*S)
// Right wing
c.stroke(180, 65, 255, 65)
c.strokeWeight(8)
c.line(x + 27*S, y + 12*S,
x + 92*S, y + 65*S - flap)
c.line(x + 92*S, y + 65*S - flap,
x + 72*S, y - 28*S - flap)
c.line(x + 72*S, y - 28*S - flap,
x + 27*S, y + 12*S)
c.stroke(185, 75, 255, 240)
c.strokeWeight(3)
c.line(x + 27*S, y + 12*S,
x + 92*S, y + 65*S - flap)
c.line(x + 92*S, y + 65*S - flap,
x + 72*S, y - 28*S - flap)
c.line(x + 72*S, y - 28*S - flap,
x + 27*S, y + 12*S)
// Wing circuitry
c.stroke(100, 200, 255, 200)
c.strokeWeight(2)
c.line(x - 35*S, y + 8*S,
x - 77*S, y + 35*S + flap)
c.line(x - 77*S, y + 35*S + flap,
x - 65*S, y - 8*S + flap)
c.line(x + 35*S, y + 8*S,
x + 77*S, y + 35*S - flap)
c.line(x + 77*S, y + 35*S - flap,
x + 65*S, y - 8*S - flap)
// Glowing wing cores
c.noStroke()
c.fill(0, 220, 255, 45)
c.ellipse(x - 77*S, y + 22*S + flap,
24*S, 24*S)
c.fill(0, 235, 255, 255)
c.ellipse(x - 77*S, y + 22*S + flap,
7*S, 7*S)
c.fill(185, 65, 255, 50)
c.ellipse(x + 77*S, y + 22*S - flap,
24*S, 24*S)
c.fill(210, 140, 255, 255)
c.ellipse(x + 77*S, y + 22*S - flap,
7*S, 7*S)
// Wing tip sparks
c.fill(235, 255, 255, 245)
c.ellipse(x - 92*S, y + 65*S + flap,
7*S, 7*S)
c.ellipse(x + 92*S, y + 65*S - flap,
7*S, 7*S)
}
// =========================================
// MASSIVE POWER ORBIT
// =========================================
def drawOrbit(c: CanvasDraw): Unit = {
val x = robotX
val y = robotY - 38*S + bob
c.noFill()
for (i <- 0 until 5) {
val w =
(125 + i * 24).toDouble * S +
math.sin(t * 2 + i) * 10
val h =
(12 + i * 4).toDouble * S +
math.abs(math.sin(t + i)) * 6
val a =
(65 + math.abs(
math.sin(t * 3 + i)
) * 180).toInt
if (i % 2 == 0) {
c.stroke(0, 230, 255, a)
} else {
c.stroke(190, 65, 255, a)
}
c.strokeWeight(2.5)
c.ellipse(x, y, w, h)
}
// Orbiting plasma
for (i <- 0 until 18) {
val angle =
t * 1.4 + i * math.Pi / 9
val px = x + math.cos(angle) * 90*S
val py = y + math.sin(angle) * 22*S
c.noStroke()
c.fill(0, 220, 255, 65)
c.ellipse(px, py, 13*S, 13*S)
c.fill(230, 255, 255, 255)
c.ellipse(px, py, 4*S, 4*S)
}
}
// =========================================
// MEGA ARMORED BODY
// =========================================
def drawBody(c: CanvasDraw): Unit = {
val x = robotX
val y = robotY + bob
// Neck
c.fill(25, 55, 100)
c.stroke(0, 225, 255)
c.strokeWeight(3)
c.rect(x - 13*S, y + 35*S,
26*S, 24*S)
// Shoulder armor
c.fill(55, 100, 155)
c.stroke(0, 220, 255)
c.strokeWeight(3)
c.ellipse(x - 35*S, y + 25*S,
29*S, 29*S)
c.ellipse(x + 35*S, y + 25*S,
29*S, 29*S)
c.noStroke()
c.fill(0, 235, 255, 210)
c.ellipse(x - 35*S, y + 25*S,
11*S, 11*S)
c.ellipse(x + 35*S, y + 25*S,
11*S, 11*S)
// Main torso
c.fill(105, 140, 185)
c.stroke(195, 225, 250)
c.strokeWeight(3)
c.ellipse(x, y + 4*S,
82*S, 88*S)
// Armor highlights
c.stroke(0, 220, 255, 220)
c.strokeWeight(2)
c.line(x - 25*S, y + 24*S,
x - 18*S, y + 39*S)
c.line(x + 25*S, y + 24*S,
x + 18*S, y + 39*S)
// Chest armor
c.fill(8, 18, 50)
c.stroke(0, 225, 255)
c.strokeWeight(3)
c.rect(x - 27*S, y - 16*S,
54*S, 45*S)
// Reactor glow
val glow =
(80 + math.abs(math.sin(t * 3)) * 175).toInt
c.noStroke()
c.fill(0, 175, 255, glow)
c.ellipse(x, y + 7*S,
48*S, 48*S)
// Reactor rings
c.noFill()
c.stroke(0, 245, 255, 255)
c.strokeWeight(3)
c.ellipse(x, y + 7*S,
34*S, 34*S)
c.stroke(190, 75, 255, 240)
c.strokeWeight(2)
c.ellipse(x, y + 7*S,
23*S, 23*S)
// Core
c.noStroke()
c.fill(0, 230, 255, 245)
c.ellipse(x, y + 7*S,
17*S, 17*S)
c.fill(255, 255, 255)
c.ellipse(x, y + 7*S,
7*S, 7*S)
// Chest bolts
c.fill(220, 245, 255)
c.ellipse(x - 21*S, y + 20*S, 4*S, 4*S)
c.ellipse(x + 21*S, y + 20*S, 4*S, 4*S)
c.ellipse(x - 21*S, y - 9*S, 4*S, 4*S)
c.ellipse(x + 21*S, y - 9*S, 4*S, 4*S)
// Waist
c.fill(35, 70, 125)
c.stroke(0, 220, 255)
c.strokeWeight(3)
c.rect(x - 24*S, y - 39*S,
48*S, 15*S)
c.noStroke()
c.fill(0, 235, 255)
c.rect(x - 13*S, y - 36*S,
26*S, 4*S)
// Legs
c.fill(125, 160, 195)
c.stroke(35, 70, 115)
c.strokeWeight(3)
c.rect(x - 22*S, y - 59*S,
16*S, 25*S)
c.rect(x + 6*S, y - 59*S,
16*S, 25*S)
// Knees
c.fill(30, 65, 110)
c.stroke(0, 225, 255)
c.ellipse(x - 14*S, y - 52*S,
14*S, 14*S)
c.ellipse(x + 14*S, y - 52*S,
14*S, 14*S)
// Heavy boots
c.fill(20, 40, 85)
c.stroke(0, 220, 255)
c.strokeWeight(3)
c.ellipse(x - 14*S, y - 64*S,
32*S, 17*S)
c.ellipse(x + 14*S, y - 64*S,
32*S, 17*S)
c.noStroke()
c.fill(0, 240, 255)
c.ellipse(x - 14*S, y - 66*S,
19*S, 4*S)
c.ellipse(x + 14*S, y - 66*S,
19*S, 4*S)
}
// =========================================
// GIANT CYBER HELMET
// =========================================
def drawHead(c: CanvasDraw): Unit = {
val x = robotX
val y = robotY + bob + 66*S
val eyeAlpha =
(80 + math.abs(math.sin(t * 4)) * 175).toInt
// Side armor
c.fill(40, 75, 125)
c.stroke(0, 225, 255)
c.strokeWeight(3)
c.ellipse(x - 40*S, y,
17*S, 30*S)
c.ellipse(x + 40*S, y,
17*S, 30*S)
// Helmet shell
c.fill(155, 190, 220)
c.stroke(225, 245, 255)
c.strokeWeight(4)
c.rect(x - 35*S, y - 27*S,
70*S, 55*S)
// Crown armor
c.fill(35, 70, 125)
c.stroke(0, 220, 255)
c.strokeWeight(3)
c.rect(x - 25*S, y + 14*S,
50*S, 10*S)
// Crown light
c.noStroke()
c.fill(0, 240, 255)
c.ellipse(x, y + 18*S,
15*S, 5*S)
// Visor
c.fill(3, 10, 32)
c.stroke(0, 220, 255)
c.strokeWeight(3)
c.rect(x - 29*S, y - 11*S,
58*S, 26*S)
// Eye sockets
c.noStroke()
c.fill(0, 3, 18)
c.ellipse(x - 14*S, y + 2*S,
18*S, 14*S)
c.ellipse(x + 14*S, y + 2*S,
18*S, 14*S)
// Eye aura
c.fill(0, 220, 255, 65)
c.ellipse(x - 14*S, y + 2*S,
22*S, 19*S)
c.ellipse(x + 14*S, y + 2*S,
22*S, 19*S)
// Neon eyes
c.fill(0, 240, 255, eyeAlpha)
c.ellipse(
x - 14*S + math.sin(t * 1.5)*2*S,
y + 2*S,
12*S, 8*S
)
c.ellipse(
x + 14*S + math.sin(t * 1.5)*2*S,
y + 2*S,
12*S, 8*S
)
c.fill(255, 255, 255)
c.ellipse(x - 15*S, y + 4*S, 4*S, 4*S)
c.ellipse(x + 13*S, y + 4*S, 4*S, 4*S)
// Mouth display
c.stroke(0, 225, 255)
c.strokeWeight(3)
c.line(x - 9*S, y - 18*S,
x + 9*S, y - 18*S)
c.line(x - 5*S, y - 22*S,
x + 5*S, y - 22*S)
// Ear lights
c.noStroke()
c.fill(0, 235, 255, eyeAlpha)
c.ellipse(x - 40*S, y,
6*S, 14*S)
c.ellipse(x + 40*S, y,
6*S, 14*S)
// Antenna
c.fill(40, 75, 125)
c.stroke(0, 220, 255)
c.strokeWeight(2)
c.ellipse(x, y + 29*S,
17*S, 8*S)
c.stroke(190, 220, 240)
c.strokeWeight(4)
c.line(x, y + 30*S,
x, y + 44*S)
// Beacon
c.noStroke()
c.fill(0, 230, 255, eyeAlpha)
c.ellipse(x, y + 48*S,
17*S, 17*S)
c.fill(255, 255, 255)
c.ellipse(x, y + 48*S,
6*S, 6*S)
}
// =========================================
// ROBOT ARMS
// =========================================
def drawArms(c: CanvasDraw): Unit = {
val x = robotX
val y = robotY + bob
val swing = math.sin(arm) * 8*S
// Upper arm metal
c.stroke(30, 60, 105)
c.strokeWeight(17*S)
c.line(x - 30*S, y + 23*S,
x - 46*S, y - 5*S)
c.line(x + 30*S, y + 23*S,
x + 46*S, y - 5*S + swing)
// Silver plating
c.stroke(185, 215, 240)
c.strokeWeight(9*S)
c.line(x - 30*S, y + 23*S,
x - 46*S, y - 5*S)
c.line(x + 30*S, y + 23*S,
x + 46*S, y - 5*S + swing)
// Neon lines
c.stroke(0, 225, 255)
c.strokeWeight(2*S)
c.line(x - 34*S, y + 15*S,
x - 47*S, y - 5*S)
c.line(x + 34*S, y + 15*S,
x + 47*S, y - 5*S + swing)
// Hands
c.fill(190, 220, 245)
c.stroke(0, 190, 255)
c.strokeWeight(3)
c.ellipse(x - 46*S, y - 6*S,
18*S, 18*S)
c.ellipse(x + 46*S, y - 6*S + swing,
18*S, 18*S)
// Fingers
c.stroke(0, 230, 255)
c.strokeWeight(2)
c.line(x - 49*S, y - 10*S,
x - 54*S, y - 16*S)
c.line(x - 44*S, y - 10*S,
x - 47*S, y - 17*S)
c.line(x + 49*S, y - 10*S + swing,
x + 54*S, y - 16*S + swing)
c.line(x + 44*S, y - 10*S + swing,
x + 47*S, y - 17*S + swing)
}
// =========================================
// FLOATING HOLOGRAM
// =========================================
def drawHologram(c: CanvasDraw): Unit = {
val x = robotX + 118*S
val y = robotY + 40*S +
math.sin(t * 1.4) * 6*S
// Panel aura
c.noFill()
c.stroke(0, 200, 255, 55)
c.strokeWeight(8)
c.rect(x - 4*S, y - 4*S,
155*S, 102*S)
// Panel
c.fill(4, 12, 40, 245)
c.stroke(0, 225, 255)
c.strokeWeight(3)
c.rect(x, y, 147*S, 94*S)
// Header
c.stroke(185, 70, 255)
c.strokeWeight(3)
c.line(x + 8*S, y + 83*S,
x + 138*S, y + 83*S)
// Text
c.noStroke()
c.fill(0, 240, 255)
c.text("NEXUS X", x + 12*S, y + 67*S)
c.fill(210, 235, 255)
c.text("CORE ACTIVE", x + 12*S, y + 49*S)
c.fill(0, 255, 145)
c.text("SYSTEM ONLINE", x + 12*S, y + 33*S)
// Animated equalizer
for (i <- 0 until 8) {
val h =
(5 + math.abs(
math.sin(t * 3 + i * 0.7)
) * 20) * S
c.fill(0, 220, 255, 230)
c.rect(
x + (12 + i * 16)*S,
y + 10*S,
7*S,
h
)
}
// Online light
c.noStroke()
c.fill(0, 255, 130, 240)
c.ellipse(x + 129*S, y + 67*S,
8*S, 8*S)
}
// =========================================
// ENERGY PARTICLES
// =========================================
def drawParticles(c: CanvasDraw): Unit = {
for (i <- 0 until 30) {
val angle =
t * 0.7 + i * math.Pi / 15
val radius =
(100 + (i % 4) * 15).toDouble * S
val px =
robotX + math.cos(angle) * radius
val py =
robotY + 20*S +
math.sin(angle * 1.3) * 90*S
val a =
(60 + math.abs(
math.sin(t * 2 + i)
) * 190).toInt
if (i % 2 == 0) {
c.fill(0, 225, 255, a)
} else {
c.fill(190, 65, 255, a)
}
c.noStroke()
c.ellipse(px, py, 5*S, 5*S)
if (i % 5 == 0) {
c.fill(255, 255, 255, 240)
c.ellipse(px, py, 2*S, 2*S)
}
}
}
// =========================================
// FUTURISTIC HUD
// =========================================
def drawStatus(c: CanvasDraw): Unit = {
c.noStroke()
c.fill(185, 225, 255)
c.text(
"ADVANCED ARTIFICIAL INTELLIGENCE",
cwidth / 2.0 - 115,
12
)
c.fill(0, 235, 255)
c.text(
"N E X U S X",
cwidth / 2.0 - 55,
cheight - 27
)
c.fill(0, 255, 145)
c.text("ONLINE", 22, cheight - 28)
c.fill(190, 100, 255)
c.text("POWER 99%", cwidth - 95, cheight - 28)
// Progress bar
c.noFill()
c.stroke(0, 220, 255, 200)
c.strokeWeight(2)
c.rect(cwidth / 2.0 - 50,
cheight - 45, 100, 5)
val progress =
65 + math.abs(math.sin(t * 1.5)) * 35
c.noStroke()
c.fill(0, 230, 255, 230)
c.rect(cwidth / 2.0 - 49,
cheight - 44, progress * 0.98, 3)
}
// =========================================
// ANIMATION
// =========================================
def drawLoop(c: CanvasDraw): Unit = {
t += 0.04
arm += 0.08
bob = math.sin(t * 2) * 4*S
drawBackground(c)
drawOrbit(c)
drawWings(c)
drawArms(c)
drawBody(c)
drawHead(c)
drawParticles(c)
drawHologram(c)
drawStatus(c)
}
}
val sketch = new Sketch
canvasSketch(sketch)