Week2 Function with B1&B3
Zhaoliang Zhang
by Zhaoliang
HTML
<div id="drawing"></div>
JavaScript
/*
W2 House B4 Functions Homework 2 with B1&B3 Parts
Zhaoliang Zhang
09/30/2018
*/
"use strict"
let draw = SVG('drawing').size(600, 400);
//Set the housebody as base
function makeBaseB4(basex,basey,c){
let BaseB4 = draw.rect(550,200).x(basex).y(basey).fill(c)
BaseB4.stroke('black').stroke({width:2});
}
//Set roof
function makeRoofB4(roofx,roofy){
let roof= draw.polygon([[roofx-150,roofy], [roofx+50,roofy-150], [roofx+250,roofy]]).fill("#8a8a5c")
roof.stroke('black').stroke({width:2});
}
//Here is the door from B3
function makeDoorb3(x,y,c){
let door = draw.ellipse(175,300);
//fill it in periwinkle blue
door.fill({color: '#7986cb'});
door.stroke({width: 2});
//move to correct position using given variables: center at (x,y)
//position: (290,375)
door.cx(x+115);
door.cy(y+75);
//trim door using white box overlay
let trimDoor = draw.rect(200,100);
//fill it in white
trimDoor.fill({color: '#fdfefe'});
//position: (200,376)
trimDoor.x(x+25);
trimDoor.y(y+76);
//add border for bottom of door
let doorBottom = draw.line('200,375 375,375');
doorBottom.stroke({width: 2});
//create black doorhandle
let doorHandle = draw.circle(15);
//move to correct position: center sits at x,y coord
doorHandle.cx(350);
doorHandle.cy(325);
}
//Set the bottom windows and windowline
function makeWindowB4(windowx,windowy){
let window3= draw.rect(125,150).x(windowx+375).y(windowy).fill("#c0c059")
window3.stroke("black").stroke({width:2})
window3.radius(10);
let window33= draw.rect(115,140).x(windowx+380).y(windowy+5).fill("#b3f0ff")
window33.stroke("black").stroke({width:2})
window33.radius(10);
let windowline4= draw.line(windowx+380,windowy+75,windowx+495,windowy+75).stroke({width:2})
}
//window from B1
function drawwindow1 (x, y, c) {
let window1 = draw.rect(150, 150).fill('#92F1E2');
window1.x(50);
window1.y(225);
window1.stroke({width: 2});
// and now horizontal lines on window 1
var l1 = draw.line(50, 270, 200,...