Skip to content

Румянцев Даниил - #1

Open
RDaniil wants to merge 3 commits into
trpomoais2017:masterfrom
RDaniil:master
Open

Румянцев Даниил#1
RDaniil wants to merge 3 commits into
trpomoais2017:masterfrom
RDaniil:master

Conversation

@RDaniil

@RDaniil RDaniil commented Mar 12, 2017

Copy link
Copy Markdown

No description provided.

@disturm disturm changed the title Сделал задание с Л-Системами Румянцев Даниил Mar 19, 2017
Comment thread index.html
<canvas height='200' width='200' id='canvas1'></canvas>
<canvas height='200' width='200' id='canvas2'></canvas>
<canvas height='200' width='200' id='canvas3'></canvas>
<body onload="setup">

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сложный UI... Слишком много кнопок и не понятно в каком порядке их нажимать.
Я в итоге справился, но все же слишком много кнопок.

Comment thread lsystem.js
var lSysString = axiom;
var drawLetters = [];
var moveLetters = [];
var backgroundColor = 80;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты похоже здесь подразумевал константу BACKGROUND_COLOR

Comment thread lsystem.js
if (currentSymbol == rule.pred) {
resultString += rule.succ;
} else {
//Если не нашли символ, удовлетворяющий правилам, то просто пишем в строку текущий символ

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот одинокий комментарий в гуще сложного алгоритма выглядит как газета над головой во время тайфуна...

Comment thread lsystem.js
resultString += currentSymbol;
}
}
lSysString = resultString;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Было бы круче, чтобы у тебя была функция, которая возвращает resultString (без побочных эффектов), а вот функция applyRule уже присваивает lSysString и stepSize

Comment thread lsystem.js

var currentSymbol = lSysString.charAt(i);

if (drawLetters.includes(currentSymbol)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут бы выделить функцию drawSymbol(currentSymbol). Текущая функция бы стала меньше. И continue не пришлось бы писать - вместо них был бы return. Да и вообще разделять код на мелкие, но логически целостные блоки в виде функций с правильными названиями - это благо.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants