ladybird/Userland/Games/GameOfLife/Pattern.cpp
Linus Groh 57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00

37 lines
862 B
C++

/*
* Copyright (c) 2021, Ryan Wilson <ryan@rdwilson.xyz>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "Pattern.h"
#include <AK/DeprecatedString.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <LibGUI/Action.h>
#include <stdio.h>
Pattern::Pattern(Vector<DeprecatedString> pattern)
{
m_pattern = move(pattern);
}
void Pattern::set_action(GUI::Action* action)
{
m_action = action;
}
void Pattern::rotate_clockwise()
{
Vector<DeprecatedString> rotated;
for (size_t i = 0; i < m_pattern.first().length(); i++) {
StringBuilder builder;
for (int j = m_pattern.size() - 1; j >= 0; j--) {
builder.append(m_pattern.at(j).substring(i, 1));
}
rotated.append(builder.to_deprecated_string());
}
m_pattern = move(rotated);
}